Two quick questions. I am using the jscookmenu. I have an actionListener set on a menu item. Here is the JSF code:
------------------------------
     <t:jscookMenu id="cmsMenu" layout="hbr" theme="ThemeOffice">
<t:navigationMenuItem id="nav_1" actionListener="#{menu.onMenuItemAction}"
                 itemLabel="TEST LABEL" itemValue="#{menu.test}"
                 action="#{menu.menuItemAction}"/>
     </t:jscookMenu>
------------------------------

The java code of the menu backing bean...
------------------------------
public class CMSMenu {
   public MenuItem getTest() {
       Site site = this.getSiteInstance();
       List<MenuItem> list = site.getMenuItems();
       return list.get(0);
   }
   public void onMenuItemAction(ActionEvent event) {
       if (event.getComponent() instanceof HtmlCommandNavigationItem) {
System.out.println(" ActionListener (HtmlCommandNavigationItem):" + ((HtmlCommandNavigationItem)event.getComponent()).getValue());
       } else {
String outcome = (String)((HtmlCommandJSCookMenu) event.getComponent()).getValue(); System.out.println(" ActionListener (HtmlCommandJSCookMenu): " + outcome);
       }
   }
}
------------------------------

Okay.. the two questions:
1. Why is the object returned by event.getComponent() always a HtmlCommandJSCookMenu object and never a HtmlCommandNavigationItem? (having the 'if' in the action listener is something I saw the jscookmenu using.) 2. Why is what the following (which is in the code above) returns always a String? It seems a toString() is ran on whatever the menu item's value is.
      (String)((HtmlCommandJSCookMenu) event.getComponent()).getValue()
Is there a way to get the actual object of the item's value instead of the string representation of it?

(I am using the nightly build of myfaces & tomahawk.)

Thanks,
David

Reply via email to