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"/>
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);
}
So , how is it possible the set new row selected when context menu is open (rigth click) ?
Thanks you for your help