views:

27

answers:

1

Hi all, I'm using ice:menuPopup to dinamically create menus on tree nodes. In jsf page I've something like this

  <f:facet name="content">
     <ice:panelGroup id="faccont" style="display: inline" menuPopup="qtaPupMenu"><ice:menuPopup imageDir="/images">
           <ice:menuItems  id="qtaPupMenu" value="#{item.userObject.menuModel}"/>
   . . .

Menu items are dinamically created by this code:

  public List<MenuItem> getMenuModel() {
    List<MenuItem> items = new LinkedList<MenuItem>();
    MenuItem mi = new MenuItem();
    mi.setValue("menu text");    
    ExpressionFactory expf = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
    MethodExpression mthd = expf
    .createMethodExpression(FacesContext.getCurrentInstance().getELContext(), "#{beanmodel.clickMenuContx}", void.class, new Class[] { ActionEvent.class });
    mi.setActionExpression(mex);           
    items.add(mi);
    return items;
  }

The problem is that the event listener "#{beanmodel.clickMenuContx}" never gets called. I've tried also with methodBinding and setActionListener method of MenuItem, but doesn't work. Where I'm wrong?

A: 

Found it! It was missing the MenuItem id attribute. I added

   mi.setId("myUniqueId");

and it works as expected.

Pier Luigi