5 Replies Latest reply on Jul 14, 2009 4:06 PM by Tanya Ruttenberg

    Navigation difficulty one search page two result pages

    Tanya Ruttenberg Expert

      I think this is a simple question, but I'm still fairly new to Seam and I can't figure it out.


      I have a search page that has 2 classes of input, device input (hostname, osversion, all bound to Device bean) and office input (location, state, zip all bound to Office).  I have 2 result pages, one that is more device oriented and one that is more office oriented.


      When the user inputs a device parameter (for example a hostname), I want to redirect to DevResultPage, otherwise I want to redirect to OfficeResultPage.


      I have tried to do this using navigation rules in page.xml file, but with no success so now I am now trying to do it using an action method.


      But I'm now having the same fundamental problem.  In trying both navigation rules in pages.xml and now in the action bean, I have not successfully figured out how to test whether an input is set.


      How do I do this?  The form has, say, 10 input possibilities, but the user only inputs a hostname.  How do I test that this is the data put in by the user so I can redirect based on that info?


      I suspect in the action bean I should use @In, but I'm still a little unclear on the concept.


      TDR

        • 1. Re: Navigation difficulty one search page two result pages
          Arbi Sookazian Master

          Add appropriate logic (set a boolean variable, for example) in the setter method(s) for the inputText fields.  When the user submits the form, the setters, in the apply request values JSF phase, get called prior to the action method.  Then in the action method, check the boolean variable and return the appropriate String value so JSF knows which JSF page to redirect the request to.

          • 2. Re: Navigation difficulty one search page two result pages
            Tanya Ruttenberg Expert

            OK, this makes sense. But I'm still having the fundamental problem.  The boolean is set in the Devices object like this




            public void setDevName(String devName) {
                deviceResult = true;
                this.devName = devName;
            }
            




            How do I get to devices.deviceResult from searchListener?  Here is searchListener.  I have a vague feeling I need to use @In to get the Devices object injected into the searchlistener, but I can't figure out how to make it work:




            @Name("searchListener")
            public class SearchListener {
                 
                @In
                private Devices devices;
                 
                public String goSearch()  {
                    System.out.println("inhabiting the action listener...");
                    System.out.println("deviceResult is " + #{devices.deviceResult});
                    return "godevice";
                }
            }



            But then I get this error:



            Caused by: org.jboss.seam.RequiredException: @In attribute requires non-null value: searchListener.devices
            



            which I have also tried, unsuccessfully, to resolve.

            • 3. Re: Navigation difficulty one search page two result pages
              Arbi Sookazian Master

              You must use @In(create=true) or add @AutoCreate to your Devices class.


              This is a typical beginner's mistake with Seam and use of @In (it happened to me a lot in the beginning!)


              The core dev team should refactor this such that the create=true (essentially AutoCreate) is default, and if one already exists in the current context (as defined by the context/scope of the current Seam component), then use that one and don't create a new one.


              But perhaps I'm missing something...

              • 4. Re: Navigation difficulty one search page two result pages
                Tanya Ruttenberg Expert

                Thank you for your help so far, James.


                I set create to true (hadn't before), but am still getting the error.  AND I included a print statement to verify the Devices object was getting created before the listener was called.  Here's what happened when I tried to invoke the listener


                12:19:21,863 INFO  [STDOUT] TDR: Creating Devices object...
                12:19:21,863 INFO  [STDOUT] TDR: Creating Devices object...
                12:19:21,910 ERROR [STDERR] Jul 10, 2009 12:19:21 PM javax.faces.event.MethodExpressionActionListener processAction
                SEVERE: Received 'org.jboss.seam.RequiredException' when invoking action listener '#{searchListener.goSearch()}' for componen
                t 'searchd'
                12:19:21,910 ERROR [STDERR] Jul 10, 2009 12:19:21 PM javax.faces.event.MethodExpressionActionListener processAction
                SEVERE: org.jboss.seam.RequiredException: @In attribute requires non-null value: searchListener.devices
                        at org.jboss.seam.Component.getValueToInject(Component.java:2335)
                        at org.jboss.seam.Component.injectAttributes(Component.java:1736)
                        at org.jboss.seam.Component.inject(Component.java:1554)
                        at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                        at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
                        at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
                        at dne.nmt.ond.action.SearchListener_$$_javassist_seam_5.goSearch(SearchListener_$$_javassist_seam_5.java)
                        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.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                        at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
                        at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
                        at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
                        at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                        at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                        at org.jboss.seam.el.OptionalParameterMethodExpression.invoke(OptionalParameterMethodExpression.java:39)
                        at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:99)
                        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:771)
                        at javax.faces.component.UICommand.broadcast(UICommand.java:372)
                        at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                        at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                        at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                        at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                        at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                        at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                        at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
                        at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
                        at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                        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:235)
                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126
                )
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
                        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                        at java.lang.Thread.run(Thread.java:619)
                12:19:21,910 ERROR [AjaxViewRoot] Error processing faces event for the component officeViewSearch:searchd
                javax.faces.event.AbortProcessingException: /ONDSearchPage.xhtml @224,97 actionListener="#{searchListener.goSearch()}": org.j
                boss.seam.RequiredException: @In attribute requires non-null value: searchListener.devices
                        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:118)
                        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
                        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:771)
                        at javax.faces.component.UICommand.broadcast(UICommand.java:372)
                        at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                        at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                        at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                        at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                        at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                        at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                        at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
                        at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
                        at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                        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:235)
                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126
                )
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
                        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                        at java.lang.Thread.run(Thread.java:619)
                Caused by: org.jboss.seam.RequiredException: @In attribute requires non-null value: searchListener.devices
                        at org.jboss.seam.Component.getValueToInject(Component.java:2335)
                        at org.jboss.seam.Component.injectAttributes(Component.java:1736)
                        at org.jboss.seam.Component.inject(Component.java:1554)
                        at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                        at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
                        at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
                        at dne.nmt.ond.action.SearchListener_$$_javassist_seam_5.goSearch(SearchListener_$$_javassist_seam_5.java)
                        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.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                        at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
                        at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
                        at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
                        at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                        at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                        at org.jboss.seam.el.OptionalParameterMethodExpression.invoke(OptionalParameterMethodExpression.java:39)
                        at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:99)
                        ... 54 more
                



                Any ideas?  I'm going to keep digging and fiddling around.


                • 5. Re: Navigation difficulty one search page two result pages
                  Tanya Ruttenberg Expert

                  FYI to anyone who comes across this.   The source of this error:


                  @In attribute requires non-null value:


                  is that the object I was injecting was somehow not a seam component. ie it was not annotated with @Name.  I'm not sure how this happened as this class was generated by seam-gen and I had assumed that all generated classes were designated as seam components.  Apparently not.


                  When I added @Name above the class definition:


                  @Name("devices")
                  public class Devices implements java.io.Serializable {


                  the injection worked just fine.


                  Of course, that led to another problem with this solution, but I'm working on it...


                  Thanks!


                  TDR