I am testing a little code, I am not sure if I am doing the right thing or not, but I am little curious that how can I do that.Here is the step by step process of what I want to do .1- In web-client-config-custom.xml I have defined an action, put it in a action-group and attached an action-listener as well.<config>
<actions>
<action id="lookup_table">
<label>Create Lookup Table</label>
<image>/images/icons/edit_icon.gif</image>
<action-listener>#{WebSettingsBean.setActive}</action-listener>
</action>
<action-group id="browse_create_menu">
<action idref="lookup_table" />
</action-group>
</actions>
</config>2- Created a Java class "WebSettingsBean", a method "setAction" is defined in it that does nothing but a sysout…
public void setActive(ActionEvent event) {
System.out.println("— in setActive —"); }
3- defined a managed bean in faces-config-custom
<managed-bean>
<managed-bean-name>WebSettingsBean</managed-bean-name>
<managed-bean-class>com.someco.web.bean.WebSettingsBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>browseBean</property-name>
<value>#{BrowseBean}</value>
</managed-property>
</managed-bean>
This examples works fine and when I click on the link output line is printed on the server console.4 -Now I have another class "DummyClass" created in the same package as the above class it has a fucntion function "getRandValue"
public Integer getRandValue(){
int i = 123;
return new Integer(i);
}
5- I modified the function mentioned defined in step 2
public DummyClass setActive(ActionEvent event) {
DummyClass obj = new DummyClass();
return obj;
}
Now this function return a DummyClass type object.My question here is that how can action-listener call getRandValue function so that I can print the Integer value '123' on the console.I modified action-listener like this ( which is not right i think )<action-listener>#{WebSettingsBean.setActive.getRandValue}</action-listener> and when run I get this exception javax.faces.el.EvaluationException: Exception while invoking expression #{WebSettingsBean.setActive.getRandValue}
caused by:
javax.faces.el.PropertyNotFoundException: Bean: com.someco.web.bean.WebSettingsBean, property: setActive
Hide Details
javax.faces.el.EvaluationException: Exception while invoking expression #{WebSettingsBean.setActive.getRandValue}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:168)
at javax.faces.component.UICommand.broadcast(UICommand.java:89)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.faces.el.PropertyNotFoundException: Bean: com.someco.web.bean.WebSettingsBean, property: setActive
at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:500)
at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:472)
at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:436)
at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:85)
at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:535)
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:473)
at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:183)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:117)
… 22 more What more should I do to get the value printed on the console