how set row selected with p:contextMenu on p:dataTable

UI Components for JSF
Post Reply
bug007
Posts: 39
Joined: 07 Oct 2015, 12:08

30 Oct 2017, 18:51

Hi,
I have implemented a p:contextMenu in a p:dataTable like example in https://www.primefaces.org/showcase/ui/ ... Menu.xhtml but I find an issue when you use right click to open contextMenu and use at same time space bar for exemple. In this case, the row selected is not the row where you have click, but the last selected !

Test it on the Show Case :

- selected one line (left click)
- go to another on open context menu (right click)
- select "view", you can see data corresponding on this row **(OK)**

Now :

- selected one line (left click)
- go to another on open context menu (right click)
- press space bar => the row selected change !!!!
- select "view", you can see data NOT corresponding at the row where the menu is **(KO)**

It's very strange because it's not what we hope to find on the view. And if you implement scrolling on the dadaTable, each time you press on space bar, each time you scrolling down and menu have no link on the row you see .... Is it a bug ?

I test to solve this issues by this way : add ajax event

Code: Select all

<p:ajax event="rowSelect" listener="#{myBean.onRowSelect}" update="msgs"/> 
    <p:ajax event="contextMenu" listener="#{myBean.onRowSelect}" update="msgs"/>
and on my bean, I define the new row and see his value correct :

Code: Select all

public void onRowSelect(SelectEvent event) {
        selectionRow = (ClassRow) event.getObject();
        FacesMessage msg = new FacesMessage("Object selected", selectionRow.toString());
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
row is selected correctly when I open the context menu, but last row was reselected when i want to view data !

So , how is it possible the set new row selected when context menu is open (rigth click) ?
Thanks you for your help


Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

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