1 Reply Latest reply on Jul 30, 2008 7:44 AM by leelavathic leelavathic

    How to determine which panelBarItem is selected

    Tim Grant Newbie

      Does anyone here know how to programmatically determine which panelBarItem a user has just selected?

      Consider this code:

       <a4j:jsFunction name="setMenuSelection">
       <a4j:actionparam name="panelItem"
       assignTo="#{menuController.selection}" />
      <a4j:form id="theIndex">
       <rich:panelBar id="theMenu"
       onclick="setMenuSelection( this )}"
       <rich:panelBarItem id="firstItem"
       label="First Item">
       blah blah
       <rich:panelBarItem id="secondItem"
       label="Second Item">
       <rich:tree> ... </rich:tree>

      @Name( "menuController" )
      public class menuController implements Serializable {
       private String currentMenuItem = "theIndex:firstItem";
       private Object selection;
       public void setCurrentMenuItem( String currentMenuItem ) {
       logger.debug( "setCurrentMenuItem( " + currentMenuItem + " )" );
       this.currentMenuItem = currentMenuItem;
       public void setSelection( Object selection ) {
       logger.debug( "setSelection( " + selection.getClass().getName() + " )" );
       this.selection = selection;

      setCurrentMenuItem is called only after making a selection in my tree control, I can't rely on the value of my panelBar being set when an panelBarItem is clicked.

      setSelection is not called at all unless I pass "this.value" as an argument, in which case I get the String "undefined" passed to the method.

      Any help would be appreciated.