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
d859e55e1972FordSilver
769370631985VolkswagenYellow
eb2856851995BMWRed
1113a2341978VolkswagenBlack
59a834861989FiatOrange
09a762e61978RenaultBrown
4dff5b0d2007VolkswagenBlue
460c0e572000VolkswagenYellow
2e2af2061970JaguarMaroon
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.