2 Replies Latest reply on Feb 5, 2009 2:38 PM by argonist

    call action of rich:panelMenuGroup/a4j:support to another pa

    argonist

      Hello,

      I am developing a dynamic navigationsmenu with datas from database. The navigation on the same page isn't problem, but the navigation to another page isn't working.
      I am using Ricefaces 3.1.6 GA, JBoss 4.0.5

      The panelMenu is binding to the jsp-compontent.
      navigation.jsp

      <t:div>
       <rich:panelMenu binding="#{navigationMenu.panelMenu}"
       style="width:160px" mode="server" expandSingle="true">
       </rich:panelMenu>
      </t:div>
      


      The calling the action of rich:panelMenuGroup isn't working, that I am taking a4j:support to call the action.

      Bean #{navigationMenu}
      private HtmlPanelMenu;
      ....
      ....
       @SuppressWarnings("deprecation")
       public void loadNavigation(User user) {
      
       panelMenu = new HtmlPanelMenu();
      
       if(user == null){
       user = ejbHandler.authSession.find("unknown");
       }
      
       Collection<HtmlContentNavigation> htmlNaviItems = this.ejbHandler.contentSession.getNavigationItems();
       FacesContext context = FacesContext.getCurrentInstance();
       Application app = context.getApplication();
      
      
       for (HtmlContentNavigation n : htmlNaviItems) {
      
       String action = "#{navigationMenu.map." + myKey(n.getNodeName()) + ".action}";
       HtmlPanelMenuGroup group = new HtmlPanelMenuGroup();
      
       HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();
       ajaxSupport.setAction(app.createMethodBinding( action, null));
       ajaxSupport.setEvent("onclick");
       ajaxSupport.setReRender("content");
       ajaxSupport.setImmediate(true);
       group.getFacets().put("a4jsupport", ajaxSupport);
      
       group.setImmediate(true);
       group.setLabel(n.getNodeName());
      
      
       group.setRendered(user.isSubscribedToTopic(n.getTopic()));
      
       if (!n.getChilds().isEmpty()) {
       group.setIconCollapsed("chevron");
       group.setIconExpanded("chevronDown");
       }
      
       TX tx = new TX();
       tx.value = n.getNodeName();
       tx.naviItem = n;
       tx.menu = this;
       map.put(myKey(n.getNodeName()), tx);
      
       panelMenu.getChildren().add(addChilds(user,n, group));
       }
       }
      
       private String myKey(String nodeName) {
       return "K" + Math.abs(nodeName.hashCode()) + "_";
       }
      
       @SuppressWarnings("deprecation")
       private HtmlPanelMenuGroup addChilds(User user, HtmlContentNavigation nav, HtmlPanelMenuGroup group) {
      
       FacesContext context = FacesContext.getCurrentInstance();
       Application app = context.getApplication();
      
       if(nav == null){
       return group;
       }
      
       for(HtmlContentNavigation c: nav.getChilds()){
      
       String action = "#{navigationMenu.map." + myKey(c.getNodeName())+ ".action}";
      
       if ((c.getChilds() != null && c.getChilds().isEmpty())) {
      
       HtmlPanelMenuItem item = new HtmlPanelMenuItem();
       item.setAction(app.createMethodBinding(action, null));
       item.setRendered(user.isSubscribedToTopic(c.getTopic()));
       item.setLabel(c.getNodeName());
       item.setImmediate(true);
       item.setReRender("content");
       group.getChildren().add(item);
       }
      
       if ((c.getChilds() != null && !c.getChilds().isEmpty())) {
      
       HtmlPanelMenuGroup subgroup = new HtmlPanelMenuGroup();
       subgroup.setLabel(c.getNodeName());
       subgroup.setRendered(user.isSubscribedToTopic(c.getTopic()));
       subgroup.setIconCollapsed("disc");
       subgroup.setIconExpanded("disc");
       subgroup.setAction(app.createMethodBinding( action, null));
       subgroup.setReRender("content");
       subgroup.setImmediate(true);
      
       HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();
       ajaxSupport.setAction(app.createMethodBinding( action, null));
       ajaxSupport.setEvent("onclick");
       ajaxSupport.setReRender("content");
       subgroup.getFacets().put("a4jsupport", ajaxSupport);
      
       group.getChildren().add(addChilds(user,c,subgroup));
       }
      
       TX tx = new TX();
       tx.value = c.getNodeName();
       tx.menu = this;
       tx.naviItem = c;
       map.put(myKey(c.getNodeName()), tx );
       }
      
       return group;
       }
      


      Have you idea to solve that problem?

      Manu