Drag and Drop - droppable area

UI Components for JSF
Post Reply
BojanSM
Posts: 5
Joined: 05 Jul 2011, 16:15

13 Sep 2011, 00:38

First of all I must say that I did everything exactly the same like it is in showcase: http://www.primefaces.org/showcase-labs/ui/dndGrid.jsf
Everything is same except I have my custom class: Cena. Anyway, the problem is not here. What I get is panels that I can drag, but when I drag them to '<p:outputPanel id="dropArea">' nothing happens. Output panel is not highlighted, it is white as usual. And, of course I never reach onCenaDrop method.

I can not describe how frustrated I am, currently.

This is my jsf page:

Code: Select all

<h:body>
        <div style="padding-top: 30px; padding-left: 30px; width: 100%; min-height: 500px;">
            <p:growl id="obavestenja"/>
            <h:form id="carForm">
                <p:fieldset legend="AvailableCars">

                    <p:dataGrid id="availableCars" var="car"
                                value="#{pmBean.cenaList}" columns="3">

                        <p:column>

                            <p:panel id="pnl" header="#{car.kriterijum.kriterijumPK.nazivKriterijuma}" style="text-align:center">
                                <h:panelGrid columns="1" style="width:100%">
                                    <h:outputText value="#{car.cena}"/>
                                </h:panelGrid>
                            </p:panel>
                            
                            <p:draggable for="pnl" revert="true"
                                         handle=".ui-panel-titlebar" stack=".ui-panel"/>

                        </p:column>
                    </p:dataGrid>
                </p:fieldset>

                <p:fieldset id="selectedCars" legend="Selected Cars" style="margin-top:20px">
                    <p:outputPanel id="dropArea">
                        <h:outputText value="!!!Drop here!!!"
                                      rendered="#{empty pmBean.droppedCenaList}"
                                      style="font-size:24px;" />

                        <p:dataTable var="car" value="#{pmBean.droppedCenaList}"
                                     rendered="#{not empty pmBean.droppedCenaList}">

                            <p:column headerText="Model">
                                <h:outputText value="#{car.kriterijum.kriterijumPK.nazivKriterijuma}" />
                            </p:column>

                            <p:column headerText="Year">
                                <h:outputText value="#{car.kriterijum.kriterijumPK.velicina}" />
                            </p:column>

                            <p:column headerText="Manufacturer">
                                <h:outputText value="#{car.cena}" />
                            </p:column>
                        </p:dataTable>
                    </p:outputPanel>
                </p:fieldset>

                <p:droppable for="selectedCars" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="availableCars" onDrop="handleDrop">
                    <p:ajax listener="#{pmBean.onCenaDrop}" update="dropArea availableCars"/>
                </p:droppable>
            </h:form>
        </div>
    </h:body>
Here is onCenaDrop method:

Code: Select all

public void onCenaDrop(DragDropEvent ddEvent) {
        System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaa");
        Cena c = ((Cena) ddEvent.getData());

        droppedCenaList.add(c);
        cenaList.remove(c);
    }
PrimeFaces 3.0.M3
Mojarra 2.0.2 (FCS b10)
Glassfish 3.0.1
JSF 2.1.1 RI
Netbeans IDE 6.9.1

mask_hot
Posts: 34
Joined: 27 May 2011, 10:52

13 Sep 2011, 22:14

take a look at the examples and check the full source code. You need a javascript function which corresponds to onDrop="handleDrop" .

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 32 guests