5 Replies Latest reply on Aug 18, 2008 2:53 AM by Ranveer Singh

    want to add action and actionListener to h:commandLink in ja

    Ranveer Singh Newbie

      I need to add action and actionListener to h:commandLink in java.

      I hava written like this..


      HtmlCommandLink cLink= new HtmlCommandLink();
       cLink.setValue("products");
      
      cLink.setActionExpression(getActionExpression("prod"));
      
      
      


      getActionExpression method is as follows
      public MethodExpression getActionExpression(String action){
       //System.out.println("inside method expression");
       ExpressionFactory fac = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
       ELContext elContext = FacesContext.getCurrentInstance().getELContext();
       MethodExpression exp =
       fac.createMethodExpression(elContext,action, null, new Class[] {});
       return exp;
      
       }
      


      now i have created the navigation rule in faces-config..

      I am able to get this as commandLink on page but when i click on the link
      i am getting following error.


      un 24, 2008 6:24:41 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/D:/richfaces-bsmr/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/BSMR1/WEB-INF/lib/jsf-facelets-1.1.12.jar!/META-INF/jsf-core.taglib.xml
      Jun 24, 2008 6:24:43 PM org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      java.lang.ExceptionInInitializerError
       at com.sun.el.parser.AstValue.getTarget(Unknown Source)
       at com.sun.el.parser.AstValue.setValue(Unknown Source)
       at com.sun.el.ValueExpressionImpl.setValue(Unknown Source)
       at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
       at javax.faces.component.ValueBindingValueExpressionAdapter.setValue(ValueBindingValueExpressionAdapter.java:141)
       at org.richfaces.component.UIPanelBar.broadcast(UIPanelBar.java:94)
       at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
       at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
       at org.ajax4jsf.component.AjaxViewRoot.processUpdates(AjaxViewRoot.java:309)
       at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:101)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Unknown Source)
      Caused by: java.util.MissingResourceException: Can't find bundle for base name com.sun.el.Messages, locale en_US
       at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
       at java.util.ResourceBundle.getBundleImpl(Unknown Source)
       at java.util.ResourceBundle.getBundle(Unknown Source)
       at com.sun.el.util.MessageFactory.<clinit>(Unknown Source)
       ... 32 more