开发者

Why does event listener not get called?

开发者 https://www.devze.com 2023-01-11 21:49 出处:网络
I\'m using ice:menuPopup to dynamically create menus on tree nodes. In jsf page I\'ve something like this

I'm using ice:menuPopup to dynamically 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 dynamically created by this code:

  public List<MenuItem> getMenuModel() {
    List<MenuItem> items = new LinkedList<MenuItem>();
    MenuItem mi = new MenuI开发者_运维百科tem();
    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 am I going wrong?


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

   mi.setId("myUniqueId");

and it works as expected.

0

精彩评论

暂无评论...
验证码 换一张
取 消