1 2 Previous Next 19 Replies Latest reply on May 6, 2008 12:43 PM by corneliuenero

    Chained Comboboxes (selectOneMenu)

    franciscoperedo

      Hi!
      Anyone here knows about a A4J/Seam example with chained Comboboxes (selectOneMenu)?


      When I say chained I mean the typical this one filters the next as in:


      Country: Please Select Country
      State: Please Select State


      If you select a country, then only the states in that country will appear in the States selectOneMenu. (All thanks to the magic of Ajax4Jsf)


      I implemented it, but, when I try to save use the selected country or state in the action of a button, I get them null...


      Any hints? (or preferably an example)


      Regards,

        • 1. Re: Chained Comboboxes (selectOneMenu)
          gimpy21

          Put all of this in a bean:


          List<String> availableCountries - getter only - you can @In this for cleanliness
          List<String> availableStates - getter only
          selectedCountryChanged() - implement obviously
          String selectedCountry - getter/setter
          String selectedState - getter/setter


          Now make a selectOneMenu using availableCountries with an a4j:support on event=onchange to call selectedCountryChanged(). This method will refresh the availableStates list with valid states. After a state is selected (in another selectOneMenu that you create that uses availableStates), you will have selectedCountry and selectedState in your bean to use as you wish.

          • 2. Re: Chained Comboboxes (selectOneMenu)
            gimpy21

            Sorry about the nasty conglomerated text. I didn't realize it would  smash it all together.

            • 3. Re: Chained Comboboxes (selectOneMenu)
              franciscoperedo

              Hi!


              Thanks for answering!


              Sounds extremely to what I did.... except for the selectedCountryChanged method... will give it a try...


              Regards,

              • 4. Re: Chained Comboboxes (selectOneMenu)
                franciscoperedo

                Hi!


                Doesn't work, it plain fails the same way it always has:


                Validation Error: Value is not valid.


                Any hints on how to deal with that?


                Do I handle this? with a conversation? but, what if I have to different groups of combos? I feel that handling conversations is a little to heavyweight for this....


                Also the strange thing is that the first selectOneMenu does filter the second selectOneMenu, but if after that I want to get the selected object of the second selectOneMenu to use it, for example for a query, it turns out to be null.


                Is it really this complex to do this with JSF/A4J? Couldn't seam somewhat help me?


                Regards,

                • 5. Re: Chained Comboboxes (selectOneMenu)
                  andygibson.contact.andygibson.net

                  Here's a simple stateless mechanism which should work.


                  public interface ItemListLocal {
                  
                      public List<String> getMasterItems();
                      public List<String> getDetailItems();
                      
                      public String getMasterValue();
                      public void setMasterValue(String masterValue);
                      
                      public String getDetailValue();
                      public void setDetailValue(String detailValue);
                      
                  }
                  



                  The bean :


                  @Name("itemList")
                  @Stateless
                  public class ItemListBean implements ItemListLocal {
                  
                       private String masterValue;
                       private String detailValue;
                  
                       public List<String> getDetailItems() {
                            ArrayList<String> result = new ArrayList<String>();
                            if (masterValue != null) {
                                 result.add(masterValue + ".1");
                                 result.add(masterValue + ".2");
                                 result.add(masterValue + ".3");
                                 result.add(masterValue + ".4");
                                 result.add(masterValue + ".5");
                            }
                            return result;
                       }
                  
                       public String getDetailValue() {
                            return detailValue;
                       }
                  
                       public List<String> getMasterItems() {
                            ArrayList<String> result = new ArrayList<String>();
                            result.add("Item 1");
                            result.add("Item 2");
                            result.add("Item 3");
                            result.add("Item 4");
                            result.add("Item 5");
                  
                            return result;
                       }
                  
                       public String getMasterValue() {
                            return masterValue;
                       }
                  
                       public void setDetailValue(String detailValue) {
                            this.detailValue = detailValue;
                       }
                  
                       public void setMasterValue(String masterValue) {
                            this.masterValue = masterValue;
                       }
                  
                  }
                  



                  And finally, the page


                  <h:form>
                        <a:outputPanel id="myPanel">
                            <h:selectOneMenu value="#{itemList.masterValue}">
                                 <s:selectItems var="v_item" value="#{itemList.masterItems}" label="#{v_item}" />
                                 <a:support event="onchange" reRender="myPanel"></a:support>
                            </h:selectOneMenu>
                  
                            <h:selectOneMenu value="#{itemList.detailValue}">
                                 <s:selectItems var="v_item" value="#{itemList.detailItems}" label="#{v_item}" />
                            </h:selectOneMenu>
                            
                  
                       </a:outputPanel>
                  </h:form>
                  



                  You don't need a conversation, however, if you don't use a conversation, you will have to regenerate the list each time, or store it in something more permanent such as the session or application which may be an option given that these are fairly constant.


                  The problem is that when you generate the second list, you need to let the component returning the list know what the current value is. Here, I have put everything in the same component, but in practice, this list generation should be in a separate component for promoting re-use.


                  • 6. Re: Chained Comboboxes (selectOneMenu)
                    franciscoperedo

                    Hi!
                    I am doing exactly the same thing, but I also have a button that needs to use the detailValue, and when click it I am still getting the Validation Error: Value is not valid:


                    
                    10:06:04,609 INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
                    sourceId=bienInmuebleSearch:municipioNotariaDecoration:j_id120[severity=(ERROR 2), summary=(Validation Error: Value is not valid), detail=(Validation Error: Value is not valid)]
                    
                    



                    The only difference is I am not using strings, I am using entities... another difference is the button that looks like this:


                    <a:commandButton id="search" value="Search" reRender="bienInmueblePanel"/>
                    



                    Basically I select Estado (State) then Municipio (County) and then I use that to filter a rich:dataTable that is inside the bienInmueblePanel this filtering is done with a typical:


                    
                    @Name("bienesInmueblesList ")
                    public class BienesInmueblesList extends EntityQuery {
                    
                    



                    Regards,


                    (Should I be using @DataModel or something like that? because I am using <s:convertEntity /> to bind the selectOneMenu to my java.util.Lists of entities)


                    • 7. Re: Chained Comboboxes (selectOneMenu)
                      andygibson.contact.andygibson.net

                      The value is not valid error is generated when the submitted value from the listbox or combo box is not in the list of items that were supplied to that list box.


                      What does the button do that creates the error? What is the scope of the items you are using to provide the data? You may need to throw it into a conversation, or some other longer running scope since if the values don't exit when it tries to submit the value, you will get that error.







                      • 8. Re: Chained Comboboxes (selectOneMenu)
                        franciscoperedo

                        Hi!


                        Have you tried your technique with 3 chained (dependant) selectOneMenues? IMHO you will get the same error I am getting if you try it.... (Because the value of the 2nd selectOneMenu will get lost and it will not be possible to use it for the third)


                        Regards,


                        • 9. Re: Chained Comboboxes (selectOneMenu)
                          andygibson.contact.andygibson.net

                          Hey,


                          I just tried it with a third without any problems, even using ajax onchange handlers and a button to set of a form submit. However, all the data that I need is available whenever I post it because I'm using simple strings.


                          The s:convertEntity should take care of entity conversation from the view selection to the value being set on the bean, however it appears to run into problems with it on the basis of the data not being available.


                          How are you passing the value of the 2nd drop down to the data provider that is returning the third list of values? Are you outjecting the entity in order to inject it to the data provider?

                          • 10. Re: Chained Comboboxes (selectOneMenu)

                            I finally decided to try with strings, but and now I am getting a new exception:


                             [lifecycle] executePhase(PROCESS_VALIDATIONS 3,com.sun.faces.context.FacesContextImpl@1e3e4c5) threw exception
                            javax.faces.FacesException
                                 at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:108)
                                 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: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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                                 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:141)
                                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                 at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                                 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:230)
                                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                                 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:157)
                                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                                 at java.lang.Thread.run(Thread.java:595)
                            Caused by: java.util.NoSuchElementException
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:117)
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:144)
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:49)
                                 at javax.faces.component.UISelectOne.matchValue(UISelectOne.java:164)
                                 at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:137)
                                 at javax.faces.component.UIInput.validate(UIInput.java:867)
                                 at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
                                 at javax.faces.component.UIInput.processValidators(UIInput.java:666)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIForm.processValidators(UIForm.java:229)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)
                                 at org.ajax4jsf.component.AjaxViewRoot.access$201(AjaxViewRoot.java:57)
                                 at org.ajax4jsf.component.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:319)
                                 at org.ajax4jsf.context.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:56)
                                 at org.ajax4jsf.context.AjaxContextImpl.invokeOnRegionOrRoot(AjaxContextImpl.java:170)
                                 at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:333)
                                 at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
                                 ... 40 more
                            00:46:54,737 ERROR [ExceptionFilter] handling uncaught exception
                            javax.servlet.ServletException
                                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
                                 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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                                 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:141)
                                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                 at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                                 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:230)
                                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                                 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:157)
                                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                                 at java.lang.Thread.run(Thread.java:595)
                            Caused by: java.util.NoSuchElementException
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:117)
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:144)
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:49)
                                 at javax.faces.component.UISelectOne.matchValue(UISelectOne.java:164)
                                 at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:137)
                                 at javax.faces.component.UIInput.validate(UIInput.java:867)
                                 at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
                                 at javax.faces.component.UIInput.processValidators(UIInput.java:666)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIForm.processValidators(UIForm.java:229)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)
                                 at org.ajax4jsf.component.AjaxViewRoot.access$201(AjaxViewRoot.java:57)
                                 at org.ajax4jsf.component.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:319)
                                 at org.ajax4jsf.context.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:56)
                                 at org.ajax4jsf.context.AjaxContextImpl.invokeOnRegionOrRoot(AjaxContextImpl.java:170)
                                 at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:333)
                                 at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
                                 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)
                                 ... 37 more
                            00:46:54,740 ERROR [ExceptionFilter] exception root cause
                            java.util.NoSuchElementException
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:117)
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:144)
                                 at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:49)
                                 at javax.faces.component.UISelectOne.matchValue(UISelectOne.java:164)
                                 at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:137)
                                 at javax.faces.component.UIInput.validate(UIInput.java:867)
                                 at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
                                 at javax.faces.component.UIInput.processValidators(UIInput.java:666)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIForm.processValidators(UIForm.java:229)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                 at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)
                                 at org.ajax4jsf.component.AjaxViewRoot.access$201(AjaxViewRoot.java:57)
                                 at org.ajax4jsf.component.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:319)
                                 at org.ajax4jsf.context.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:56)
                                 at org.ajax4jsf.context.AjaxContextImpl.invokeOnRegionOrRoot(AjaxContextImpl.java:170)
                                 at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:333)
                                 at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
                                 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: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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                                 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:141)
                                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                 at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                                 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:230)
                                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                                 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:157)
                                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                                 at java.lang.Thread.run(Thread.java:595)
                            
                            

                            • 11. Re: Chained Comboboxes (selectOneMenu)

                              Here is my jsf code:


                              <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                                           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                                   xmlns:s="http://jboss.com/products/seam/taglib"
                                   xmlns:ui="http://java.sun.com/jsf/facelets"
                                   xmlns:f="http://java.sun.com/jsf/core"
                                   xmlns:h="http://java.sun.com/jsf/html"
                                   xmlns:rich="http://richfaces.org/rich"
                                   xmlns:a="http://richfaces.org/a4j" template="layout/template.xhtml">
                              
                                   <ui:define name="body">
                              
                                        <h:messages globalOnly="true" styleClass="message" />
                              
                                        <rich:panel>
                                             <f:facet name="header">itemList</f:facet>
                              
                                             <h:form id="ItemListForm">
                              
                                                  <a:outputPanel id="myPanel">
                                                       <h:selectOneMenu value="#{itemList.masterValue}">
                                                            <s:selectItems var="v_item" value="#{itemList.masterItems}"
                                                                 label="#{v_item}" />
                                                            <a:support event="onchange" reRender="myPanel"></a:support>
                                                       </h:selectOneMenu>
                              
                                                       <h:selectOneMenu value="#{itemList.detailValue}">
                                                            <s:selectItems var="v_item" value="#{itemList.detailItems}"
                                                                 label="#{v_item}" />
                                                       </h:selectOneMenu>
                              
                              
                                                  </a:outputPanel>
                              
                              
                                                  <h:commandButton id="itemList" value="itemList!"
                                                       action="#{itemList.itemList}" />
                              
                              
                              
                                             </h:form>
                              
                                        </rich:panel>
                              
                                   </ui:define>
                              
                              </ui:composition>
                              
                              
                              



                              and the java bean code:


                              package org.domain.seam2pilot.session;
                              
                              import java.util.ArrayList;
                              import java.util.List;
                              
                              import org.jboss.seam.annotations.Name;
                              import org.jboss.seam.annotations.In;
                              import org.jboss.seam.annotations.Logger;
                              import org.jboss.seam.log.Log;
                              import org.jboss.seam.faces.FacesMessages;
                              
                              @Name("itemList")
                              public class ItemList {
                                   
                                  @Logger private Log log;
                                   
                                  @In FacesMessages facesMessages;
                                  
                                  private String masterValue;
                                   private String detailValue;
                              
                                   public List<String> getDetailItems() {
                                        ArrayList<String> result = new ArrayList<String>();
                                        log.info("getting detail items for #0", masterValue);
                                        if (masterValue != null) {
                                             result.add(masterValue + ".1");
                                             result.add(masterValue + ".2");
                                             result.add(masterValue + ".3");
                                             result.add(masterValue + ".4");
                                             result.add(masterValue + ".5");
                                        }
                                        return result;
                                   }
                              
                                   public String getDetailValue() {
                                        return detailValue;
                                   }
                              
                                   public List<String> getMasterItems() {
                                        ArrayList<String> result = new ArrayList<String>();
                                        result.add("Item 1");
                                        result.add("Item 2");
                                        result.add("Item 3");
                                        result.add("Item 4");
                                        result.add("Item 5");
                              
                                        return result;
                                   }
                              
                                   public String getMasterValue() {
                                        return masterValue;
                                   }
                              
                                   public void setDetailValue(String detailValue) {
                                        this.detailValue = detailValue;
                                   }
                              
                                   public void setMasterValue(String masterValue) {
                                        this.masterValue = masterValue;
                                   }
                                   
                                   public void itemList(){
                                        log.info("Master: #0",this.masterValue);
                                        log.info("Detail: #0",this.detailValue);
                                   }
                              
                              
                                   
                                 //add additional action methods
                                   
                              }
                              
                              



                              What could I be doing wrong? (Did you test it throughly? Because here it works when I select an item in the master selectOneMenu, but only the first time, the second time I get the exception I posted in my previous post)


                              Could it be because everything is inside a ui:composition? or perhaps because of the rich:panel?


                              While this is a little different exception the underlying cause seems to be the same, if you take a look at the messages printed by the log.info:



                              00:46:41,528 INFO  [ItemList] getting detail items for null
                              00:46:41,533 INFO  [ItemList] getting detail items for null
                              00:46:44,930 INFO  [ItemList] getting detail items for Item 2
                              00:46:44,935 INFO  [ItemList] getting detail items for Item 2
                              00:46:54,726 INFO  [ItemList] getting detail items for null
                              



                              The first 2 messages are printed when the page loads, the 3rd and 4th message, when the Item 2 is selected in the master selectOneMenu, the 5th message is printed when I try to select the Item 3 in the master selectOneMenu


                              Any hints?


                              Regards,

                              • 12. Re: Chained Comboboxes (selectOneMenu)
                                paata.paatal.magtigsm.ge

                                hi Francisco,


                                i have the same task, seam is more flexible and simple, try to look here into my example


                                http://www.seamframework.org/Community/SeamA4JSelectonemenusAndValidationRichMessage


                                you can fill secectonemenus by entities, queries could defined into components.xml, it will be be good if you had parrent - child dependencies by entities (OneToMany rellations).


                                if you want i can send my example.



                                _________________


                                Regards


                                Paata Lominadze


                                Magticom LTD.

                                • 13. Re: Chained Comboboxes (selectOneMenu)

                                  Hi!
                                  Okey, this is getting strange, if I set the @Scope of my class to  ScopeType.PAGE:


                                  @Name("itemList")
                                  @Scope(ScopeType.PAGE)
                                  public class ItemList {
                                  



                                  It works.... why is that? I thought all my backing beans had a default @Scope of ScopeType.CONVERSATION and I also thought that ScopeType.CONVERSATION lasted longer than ScopeType.PAGE even if I haven't started a long running conversation... but I do this:


                                  @Name("itemList")
                                  @Scope(ScopeType.CONVERSATION)
                                  public class ItemList {
                                  



                                  It crashes.... why backing beans are not ScopeType.PAGE by default?... Can I promote my bean from ScopeType.PAGE to @Scope(ScopeType.CONVERSATION) when/if ever decide to use  @Begin ? Is it a good idea to scope all my backing bean with ScopeType.PAGE? or perhaps I should find a trick to apply ScopeType.PAGE only my to String masterValue (perhaps with some weird trick that uses @Out@In or @Factory


                                  Any hints?




                                  • 14. Re: Chained Comboboxes (selectOneMenu)

                                    Hi!


                                    Thanks for answering!


                                    Well you do have a very similar task, but I want to do it without using long running conversations (And you seem to be using long running conversations).


                                    See my last post I made it work (with some help from Andy Gibson) , but I don't quite understand why @Scope(ScopeType.PAGE) makes it work... can you explain that to me?


                                    Regards,

                                    1 2 Previous Next