JARCH SHOWCASE
JARCH SHOWCASE
DragDrop - DataTable DragDrop components have special integration with data components. Drag the cars using the drag icon to the drop area.
Available Cars
IdYearBrandColor
3f25d4701971HondaSilver
dcf463661965MercedesMaroon
48a0e98d2009BMWOrange
070b03501977FordYellow
950ed9c02006MercedesOrange
76741cd02007VolvoWhite
bedc8d422003FiatOrange
f586964d1987VolkswagenGreen
356d621c1974VolkswagenBlack
Selected Cars
!!!Drop here!!!
Car Detail
<script type="text/javascript">
    function handleDrop(event, ui) {
        var droppedCar = ui.draggable;

        droppedCar.fadeOut('fast');
    }
</script>

<a:form id="carForm">
    <a:fieldset id="availableCarsField" legend="Available Cars">
        <a:dataTable id="availableCars" var="car" value="#{dndCarsView.cars}">
            <a:column style="width:20px">
                <h:outputText id="dragIcon" styleClass="ui-icon ui-icon-arrow-4" />
                <a:draggable for="dragIcon" revert="true" helper="clone"/>
            </a:column>

            <a:column headerText="Id">
                <h:outputText value="#{car.id}" />
            </a:column>

            <a:column headerText="Year">
                <h:outputText value="#{car.year}" />
            </a:column>

            <a:column headerText="Brand">
                <h:outputText value="#{car.brand}" />
            </a:column>

            <a:column headerText="Color">
                <h:outputText value="#{car.color}" />
            </a:column>
        </a:dataTable>
    </a:fieldset>

    <a:fieldset id="selectedCars" legend="Selected Cars" style="margin-top:20px">
        <a:outputPanel id="dropArea">
            <h:outputText value="!!!Drop here!!!" rendered="#{empty dndCarsView.droppedCars}" style="font-size:24px;" />
            <a:dataTable id="selectedCarsTable" var="car" value="#{dndCarsView.droppedCars}" rendered="#{not empty dndCarsView.droppedCars}">
                <a:column headerText="Id">
                    <h:outputText value="#{car.id}" />
                </a:column>

                <a:column headerText="Year">
                    <h:outputText value="#{car.year}" />
                </a:column>

                <a:column headerText="Brand">
                    <h:outputText value="#{car.brand}" />
                </a:column>

                <a:column headerText="Color">
                    <h:outputText value="#{car.color}" />
                </a:column>

                <a:column style="width:32px">
                    <a:commandButton update=":carForm:display" oncomplete="PF('carDialog').show()" icon="ui-icon-search">
                        <f:setPropertyActionListener value="#{car}" target="#{dndCarsView.selectedCar}" />
                    </a:commandButton>
                </a:column>
            </a:dataTable>
        </a:outputPanel>
    </a:fieldset>

    <a:droppable for="selectedCars" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="availableCars" onDrop="handleDrop">
        <a:ajax listener="#{dndCarsView.onCarDrop}" update="dropArea availableCars" />
    </a:droppable>

    <a:dialog header="Car Detail" widgetVar="carDialog" resizable="false" draggable="false"
                showEffect="fade" hideEffect="fade" modal="true">

        <a:outputPanel id="display">
            <h:panelGrid columns="2" cellpadding="4" rendered="#{not empty dndCarsView.selectedCar}">
                <f:facet name="header">
                    <a:graphicImage name="demo/images/car/#{dndCarsView.selectedCar.brand}.gif"/>
                </f:facet>

                <h:outputText value="Id:" />
                <h:outputText value="#{dndCarsView.selectedCar.id}" style="font-weight:bold"/>

                <h:outputText value="Year:" />
                <h:outputText value="#{dndCarsView.selectedCar.year}" style="font-weight:bold"/>

                <h:outputText value="Brand:" />
                <h:outputText value="#{dndCarsView.selectedCar.brand}" style="font-weight:bold"/>

                <h:outputText value="Color:" />
                <h:outputText value="#{dndCarsView.selectedCar.color}" style="font-weight:bold"/>
            </h:panelGrid>
        </a:outputPanel>
    </a:dialog>
</a:form>
                
JARCH, Copyright © 2022 All rights reserved. Running JARCH 24.3.0-SNAPSHOT on PrimeFaces-12.0.0 on Mojarra-2.3.13.