5 Replies Latest reply on Feb 21, 2008 11:04 AM by Dongyao Zhao

    How to generate context menu programatically on each show re

    Petr Gola Newbie

      Hi,

      I am searching the way to generate context menu programatically on each show request? I have tried to do this but without any success - for long time:). It is still generated only once - at the beginning when page is loaded. I want to regenerate this menu on each user request - on each user's right click. Is it possible to tell rich faces to "rerender" context menu when componentControl's event launch?

      My binding (index.xhtml):

       <h:form>
       <rich:tree id="folderTree"
       switchType="client"
       nodeSelectListener="#{folderTreeBean.processSelection}"
       ajaxSubmitSelection="true"
       var="node">
       <rich:recursiveTreeNodesAdaptor roots="#{folderTreeBean.roots}" var="folderNode" nodes="#{folderNode.subfolders}"/>
       <rich:componentControl event="oncontextmenu" for="folderTreeMenu" operation="show">
       </rich:componentControl>
       </rich:tree>
       <rich:contextMenu id="folderTreeMenu" binding="#{folderTreeBean.contextMenu}" attached="false" submitMode="ajax">
       </rich:contextMenu>
       </h:form>
      


      My code (FolderTreeBean.java):

       public ContextMenu getContextMenu() {
       ContextMenu contextMenu = new ContextMenu();
      
       HtmlMenuItem menuItem = new HtmlMenuItem();
       menuItem.setAjaxSingle(true);
       menuItem.setValue("Hello at "+System.currentTimeMillis());
      
       contextMenu.getChildren().add(menuItem);
      
       return contextMenu;
       }
      


      Can anyone help me?