Can anyone tell me what the functional difference between these two snippets is (besides the fact that the java code version doesn't work)

           <tr:inputText label="test declarative"
                         value="#{helloWorldBacking.sessionText}"
                         partialTriggers="buttonId"/>
           <tr:commandButton id="buttonId"
                             text="lib"
                             windowWidth="500" windowHeight="500"
                             partialSubmit="true"
                             useWindow="true"
                             action="#{helloWorldBacking.onOpenPage2}"
returnListener="#{helloWorldBacking.returnedFromPage2}"/>

and

   private void addContent()
   {
Application app = FacesContext.getCurrentInstance().getApplication();

CoreInputText txt = (CoreInputText) app.createComponent( CoreInputText.COMPONENT_TYPE );
       txt.setLabel( "test dynamic" );
       txt.setId( "txtID" );
txt.setValueBinding("value", app.createValueBinding("#{helloWorldBacking.sessionText}"));
       txt.setPartialTriggers( new String[] { "btnID" } );
       m_MainPanel.getChildren().add(txt);

CoreCommandButton btn = (CoreCommandButton) app.createComponent( CoreCommandButton.COMPONENT_TYPE );
       btn.setText("lib");
       btn.setId( "btnID" );
btn.setActionListener(app.createMethodBinding("#{helloWorldBacking.onOpenPage2}", null )); // an empty array doesn't work either
       btn.setImmediate(true);
       btn.setPartialSubmit(true);
       btn.setUseWindow(true);
       btn.setWindowWidth(600);
       btn.setWindowHeight(300);
btn.setReturnListener(app.createMethodBinding("#{helloWorldBacking.returnedFromPage2}", new Class[] { ReturnEvent.class }));
       m_MainPanel.getChildren().add(btn);
   }


The relevant backing bean methods are:

   public String onOpenPage2()
   {
       return "dialog:openPage2";
   }

   public String getOnOpenPage2() // maybe this???
   {
       return onOpenPage2();
   }

   public void returnedFromPage2( ReturnEvent event)
   {
       if (event.getReturnValue() != null)
       {
           Object[] array = (Object[]) event.getReturnValue();
           System.out.println( "returned value " + array[0] );
           setSessionText(array[0].toString());
       }
   }

The jspx version works fine, but the java version throws the exception below, which seems to suggest that onOpenPage2 should have more than the zero arguments which it is defined with.

Mar 11, 2008 3:16:41 AM org.apache.myfaces.trinidadinternal.config.xmlHttp.XmlHttpConfigurator handleError
SEVERE: Server Exception during PPR, #1
javax.servlet.ServletException: Exception while invoking expression #{helloWorldBacking.onOpenPage2}
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:250) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:207) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:161) at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92) 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:175) 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:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) 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.EvaluationException: Exception while invoking expression #{helloWorldBacking.onOpenPage2} at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:168) at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1188) at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:147) at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:139)
at org.apache.myfaces.lifecycle.ApplyRequestValuesExecutor.execute(ApplyRequestValuesExecutor.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)
   ... 18 more
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
   ... 26 more


--
Shane

Reply via email to