0
votes

I am using the PrimeFaces 3.5 in my application.

  1. I have made some changes in my code and I started using Dynamic Context Menu using server side code instead on static simple context menu of primefaces.

sample code

        MenuItem menu1= new MenuItem();
        menu1.setValue(Label);
        menu1.setActionExpression(expFact.createMethodExpression(elCtx, "#{classname.methodname}", Void.class, new Class[0]));
        menu1.setOncomplete("Dialog1.show()");
        model.addMenuItem(menu1);
  1. this dynamic menu is working fine.
  2. In this context menu on oncomplete event a Dialog is popup-ed. I am using another simple context menu for this dialog. Earlier I was able to handle context menu on Dialog box but as I have changed dynamic context menu on my main xhtml page. The context menu is not appearing on dialog box now.

I am not getting any exception or error on browser so I am unable to trace the cause why my simple context menu is lost or what extra I need to do to handle simple context menu on dialog now?

Please help me and thanks in advance.

1

1 Answers

0
votes

ACtually I am using a Datatable and in datatable I was unable to implement the context menu. But I have used simple solution and my problem got resolved.

<p:contextMenu for="Tableid" id="contextid" widgetVar="contextwidgetvar">
  <p:menuitem value="Menu 1"  oncomplete="confirmationdialog.show()" />
</p:contextMenu>
<p:dataTable id="Tableid" widgetVar="Table" var="sItem" 
   value="#{classname.methodname}"  rowKey="#{sItem.id}" selection="#{classname.methodname.selectedObject}"selectionMode="single" lazy="true" editable="true">
<p:ajax event="contextMenu" oncomplete="contextwidgetvar.show();" />
</p:dataTable>

This simple steps solved the problem. some time you may need to add some javascript to avoid the always getting the first row in selected object.