java - How can i bind an ace:menuItem in ace:menuButton component -


in icefaces 3 application have drop down menu. populate dynamicaly. in managedbean have methode define menuitem. label , actionmethod, , valued them on menuitem. when launch application, item of drop down menu empty.

managedbean :

package com.omb.view;  import java.io.serializable;  import javax.el.methodexpression;  import org.apache.commons.logging.log; import org.apache.commons.logging.logfactory;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.context.annotation.scope; import org.springframework.stereotype.controller;  import com.icesoft.faces.component.menubar.menuitem;  @controller @scope("session") public class mybean implements serializable {      private static final log logger = logfactory.getlog(mybean.class);      private menuitem menuitem1;      public string initmybean() {          try {             initmenuitem();         } catch (exception e) {             logger.error(e.getmessage(), e);         }     }      private void initmenuitem() {          menuitem1 = new menuitem();         menuitem1.setvalue("menu 1");          methodexpression actionexpression = facesutils.createaction("#{menu1bean.display}", string.class);         menuitem1.setactionexpression(actionexpression);      }      public menuitem getmenuitem1() {         return this.menuitem1;     }      public void setmenuitem1(menuitem menuitem1) {         this.menuitem1 = menuitem1;     }  } 

faceutils

package com.omb.view;  import javax.el.methodexpression; import javax.faces.context.facescontext; import javax.faces.event.actionevent; import javax.faces.event.methodexpressionactionlistener;  /**  * jsf utilities.  */ public class facesutils {      public static methodexpression createaction(string actionexpression, class<?> returntype) {         facescontext context = facescontext.getcurrentinstance();         return context.getapplication().getexpressionfactory()                 .createmethodexpression(context.getelcontext(), actionexpression, returntype, new class[0]);     }      public static methodexpressionactionlistener createactionlistener(string actionlistenerexpression) {         facescontext context = facescontext.getcurrentinstance();         return new methodexpressionactionlistener(context                 .getapplication()                 .getexpressionfactory()                 .createmethodexpression(context.getelcontext(), actionlistenerexpression, null,                         new class[] {actionevent.class}));     } } 

screen.xhtml

<?xml version="1.0" encoding="utf-8"?> <html xmlns="http://www.w3.org/1999/xhtml"     xmlns:ui="http://java.sun.com/jsf/facelets">  <body>     <ui:composition>         <ice:form id="headerform" xmlns:h="http://java.sun.com/jsf/html"             xmlns:f="http://java.sun.com/jsf/core"             xmlns:ice="http://www.icesoft.com/icefaces/component"             xmlns:ace="http://www.icefaces.org/icefaces/components"             xmlns:c="http://java.sun.com/jstl/core"             xmlns:ui="http://java.sun.com/jsf/facelets">              <div class="menu">                 <ace:menubutton id="menubutton" effect="slide" effectduration="200" value="menu button">                     <ace:menuitem binding="#{mybean.menuitem1}"/>                 </ace:menubutton>              </div>         </ice:form>     </ui:composition> </body> </html> 

i use standard solution :

<ace:menubutton id="menubutton" effect="slide" effectduration="200" value="menu button">        <ace:menuitem value="menu 1" action="#{mybean.display}"/> </ace:menubutton> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -