2 Replies Latest reply on Jan 15, 2011 3:03 AM by kitto pang

    Why the 'itemChangeListener' work, but the 'action' do not work ?

    kitto pang Newbie

      Here is the code:(richfaces version: richfaces-4.0.0.20101226-M5)

      panelMenu.xhtml

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

      xmlns:h="http://java.sun.com/jsf/html"

      xmlns:a4j="http://richfaces.org/a4j"

      xmlns:rich="http://richfaces.org/rich"

      xmlns:f="http://java.sun.com/jsf/core"

      xmlns:ui="http://java.sun.com/jsf/facelets">

      <h:head>

      </h:head>

      <body>

      <h:form id="panelMenuFormId">

         <rich:panelMenu mode="server" itemChangeListener="#{panelMenuBean.updateCurrent}">

          <rich:panelMenuGroup label="affix center">

           <rich:panelMenuItem label="affix" name="INFO_affix" action="#{panelMenuBean.action}"/>

           <rich:panelMenuItem label="INFO_announce" name="INFO_announce" />

           <rich:panelMenuItem label="INFO_feedBack" name="INFO_feedBack" />

           <rich:panelMenuItem label="INFO_receiver" name="INFO_receiver" />

          </rich:panelMenuGroup>

          <rich:panelMenuGroup label="PER_performance">

           <rich:panelMenuItem label="PER_performanDDD" name="PER_performance" action="#{panelMenuBean.action()}"/>

          </rich:panelMenuGroup>

         </rich:panelMenu>

      </h:form>

      </body>

      </html>

       

      PanelMenuBean.java

      @ManagedBean
      @SessionScoped
      public class PanelMenuBean implements Serializable{
      private String selectedChild = null;

       


      public void updateCurrent(ItemChangeEvent event){
        selectedChild = event.getNewItem();
        System.out.println(event.getNewItem());
      }

       

      public String action(){
        if(selectedChild == null || selectedChild.equals(""))
         return null;
       

        System.out.println(selectedChild);
        String action = selectedChild.split("_")[1];
        return action + "List";
      }

      public String getSelectedChild() {
       
        return selectedChild;
      }

      public void setSelectedChild(String selectedChild) {
        this.selectedChild = selectedChild;
      }
      }

       

      Is any error in the code?

      Thanks!