6 Replies Latest reply on Aug 26, 2006 9:43 AM by Jens

    Can I forace a method to be invoked everytime a page is load

    Eric Ray Novice

      Is there a way that I can force a method to be invoked when a particular page is loaded and with no user interaction. The @Create and @Factory annotations only work on the initial creation of the seam component. I can't find any annotations that force this.

      My hunch is that I need to insert an interceptor into the lifecycle, but I was hoping to avoid this.

      Any suggestions?

      Thanks.
      Eric Ray

        • 1. Re: Can I forace a method to be invoked everytime a page is
          Thomas Heute Master

          Did you look at pages.xml ?

          Look at the blog example.

          • 2. Re: Can I forace a method to be invoked everytime a page is
            Eric Ray Novice

            will check it out. thanks.

            • 3. Re: Can I forace a method to be invoked everytime a page is
              Eric Ray Novice

              Page Event appears to be what I need. However, I get the following exception.

              javax.faces.el.EvaluationException: Exception while invoking expression #{elements.init}
               at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:165)
               at org.jboss.seam.core.Pages.callAction(Pages.java:161)
               at org.jboss.seam.core.Pages.callAction(Pages.java:143)
               at org.jboss.seam.jsf.AbstractSeamPhaseListener.callPageActions(AbstractSeamPhaseListener.java:128)
               at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:98)
               at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:50)
               at org.apache.myfaces.lifecycle.LifecycleImpl.informPhaseListenersBefore(LifecycleImpl.java:520)
               at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:342)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
               at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
               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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
               at java.lang.Thread.run(Thread.java:595)
              Caused by: javax.faces.el.PropertyNotFoundException: Base is null: elements
               at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:455)
               at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:180)
               at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:114)
               ... 27 more
              


              here's the pages.xml
              <pages>
               <page view-id="/extract/remittance.xhtml" action="#{elements.init}"/>
              </pages>
              


              The seam ojbect in question hasn't been created yet and it looks like that's the problem. Is there something else I should do?

              Thanks.


              • 4. Re: Can I forace a method to be invoked everytime a page is
                Gavin King Master

                Sure. Make a component called "elements" so that it will be automagically instantiated. Or create a @Factory method for "elements".

                • 5. Re: Can I forace a method to be invoked everytime a page is
                  Jens Newbie

                  Hi there,
                  how does this "automagical" creation work? I have declared a component and try to call it from the declaration in pages.xml and get the same error.

                  It works when I outject a component to a context. But at the end I want to have a stateless bean created whenever requested.

                  I lack a bit of understanding here. The error occurs on "org.apache.myfaces.el.MethodBindingImpl.invoke" when the myfaces variable resolver searches the FacesContext.
                  How ist the myfaces variable resolver supposed to find components that are not part of a context ?
                  I can't see anywhere that they are added to the FacesContext by the SeamPhaseListener.

                  Thanks for some clarification,
                  Jens

                  • 6. Re: Can I forace a method to be invoked everytime a page is
                    Jens Newbie

                    problem solved. I used my own seam jboss-seam.jar debug version. It didn't include the faces-config.xml which I was surprised to find in the original jar archive ...

                    Jens