drag & drop implementation (value of droped item)

UI Components for JSF
Post Reply
reloaded
Posts: 1
Joined: 28 Jul 2010, 13:15

28 Jul 2010, 13:39

Hi,

im currently developing my first jsf webapplication and at the very beginning i want to say tanks a lot to optimus and all the guys who support primefaces.

I want to get the value of the draged object and i have absolutly no idear how to solve this.

Here's my code:
Later it should merge the content of the draged and droped items but that will be no problem. My only problem is to get the #{album.id} in my bean.

Code: Select all

<p:dataGrid value="#{albumController.currentUserAlbums}" var="album" columns="4" rows="12" paginator="true" effect="true" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="15,30">
            <p:column>
                <p:commandLink action="#" oncomplete="imageDialogWidget.show()" update="albumDialogFormular">
                    <f:param id="albumId" value="#{album.id} />
                    <p:droppable dropListener="#{manageAlbums.onDrop}" tolerance="intersect" />
                    <p:draggable revert="true" zindex="1000" />
                    <p:graphicImage url="#{resource['img/manageAlbums/folder.png']}" width="130" style="border:0px;" />
                </p:commandLink>
            </p:column>
        </p:dataGrid>
The commandLink opens the clicked album but thats not important at this point so i only write # in my code.

my bean looks like this:

Code: Select all

@ManagedBean(name = "manageAlbums")
@SessionScoped
public class ManageAlbums implements Serializable {

    private Album dragedAlbum;
    private Album targetAlbum;

    /*
    some irrelevant stuff
    ....
    */

    public void onDrop(DragDropEvent ddEvent) {

        System.out.println("test1: " + ddEvent.getDragId());
        System.out.println("test2: " + ddEvent.getDropId());
       
    }
}
I can receive the id's of the draged and droped items but i want to receive some additional data, in this case the albumID.

so my first approach was simply to set the id of the wrapped element to the album id value but this is not posibile because it's in a loob and jsf ignores the value.

Code: Select all

<p:dataGrid value="#{albumController.currentUserAlbums}" var="album" columns="4" rows="12" paginator="true" effect="true" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="15,30">
            <p:column>
                <p:commandLink id="#{album.id}" action="#" oncomplete="imageDialogWidget.show()" update="albumDialogFormular">
                    <p:droppable dropListener="#{manageAlbums.onDrop}" tolerance="intersect" />
                    <p:draggable revert="true" zindex="1000" />
                    <p:graphicImage url="#{resource['img/manageAlbums/folder.png']}" width="130" style="border:0px;" />
                </p:commandLink>
            </p:column>
        </p:dataGrid>
so, is there any solution to get the album id of the draged and droped item in my backingbean? currentcontext or something like this? i'm new to jsf development and i'm sure there is a very simple solution for this problem.

I'm using jsf 2.0 and primefaces 2.1rc1 running on glasfish v3, but i think the only interesting information about my problem ist the primefaces version :)

thanks and best regards

matthias

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 50 guests