[jboss-user] [JBoss Seam] - <a:support> with <s:selectItems> problem

jquery@interia.pl do-not-reply at jboss.com
Thu Sep 20 05:42:43 EDT 2007


Hi,

what I am trying to do is to change the set of values in one <s:selectItems> component after changing the value on a facelets page in another <s:selectItems>. In other words speaking lets assume that we have two <s:selectItems> components. In the first one there are branches and in the second one there are categories. And now if I change the branch the categories in the new selected branch should be loaded into the second <s:selectItems> . The code is following:



  | <h:form id="predefinedSkill" styleClass="edit">
  | 
  |    <h:outputLabel for="branch">
  |       #{messages.branch}
  |    </h:outputLabel>
  | 
  |    <s:decorate id="branchDecoration">
  |       <h:selectOneMenu value="#{branchHome.instance.name}">
  | 	<s:selectItems value="#{branchList.resultList}" var="branch" label="#{branch.name}" />
  | 	<s:convertEntity/>
  | 	<a:support event="onchange" reRender="categoryDecoration" ajaxSingle="true" action="#{categoryHome.loadAllCategories()}"/>
  |       </h:selectOneMenu>
  |    </s:decorate>
  | 
  | 					                      
  |    <h:outputLabel for="category">
  |       #{messages.category}
  |    </h:outputLabel>
  | 
  |    <s:decorate id="categoryDecoration">
  |       <h:selectOneMenu value="#{categoryHome.instance.name}" >
  |          <s:selectItems value="#{categoryHome.categoryList}" var="category" label="#{category.name}" />
  |          <s:convertEntity/>
  |        </h:selectOneMenu>
  |     </s:decorate>
  | 
  | </h:form>
  | 

But when I change the branch I get the error:

  | INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
  | sourceId=predefinedSkill:branchDecoration:j_id29[severity=(ERROR 2), summary=(/specialist/spec_skills.xhtml @76,85 value="#{branchHome.instance.name}": java.lang.IllegalArgumentException: argument type mismatch), detail=(/specialist/spec_skills.xhtml @76,85 value="#{branchHome.instance.name}": java.lang.IllegalArgumentException: argument type mismatch)]
  | 
  | 

If the Branch Entity has additionally constraints on length i.e.

  | @Column(name = "NAME", length = 100)
  | @Length(max = 100)
  | public String getName() {
  |    return this.name;
  | }
  | 

I get the following error:


  | INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
  | sourceId=predefinedSkill:branchDecoration:j_id28[severity=(ERROR 2), summary=(length must be between 0 and 100), detail=(length must be between 0 and 100)]
  | sourceId=predefinedSkill:predefinedSkillDecoration:j_id37[severity=(ERROR 2), summary=(length must be between 0 and 100), detail=(length must be between 0 and 100)]
  | 

In both cases the method categoryHome.loadAllCategories() [I don't use branchId as a parameter in this method for the simplicity reason] is not invoked! But if I invoke it from the simple <h:input> component:

  | <h:form id="predefinedSkill" styleClass="edit">
  | 
  |    <h:inputText value="TEST">
  |       <a:support event="onchange" reRender="categoryDecoration" ajaxSingle="true" action="#{categoryHome.loadAllCategories()}"/>
  |    </h:inputText>
  | 
  |    <h:outputLabel for="branch">
  |       #{messages.branch}
  |    </h:outputLabel>
  | 
  |    <s:decorate id="branchDecoration">
  |       <h:selectOneMenu value="#{branchHome.instance.name}">
  | 	<s:selectItems value="#{branchList.resultList}" var="branch" label="#{branch.name}" />
  | 	<s:convertEntity/>
  | 	<a:support event="onchange" reRender="categoryDecoration" ajaxSingle="true" action="#{categoryHome.loadAllCategories()}"/>
  |       </h:selectOneMenu>
  |    </s:decorate>
  | 
  | 					                      
  |    <h:outputLabel for="category">
  |       #{messages.category}
  |    </h:outputLabel>
  | 
  |    <s:decorate id="categoryDecoration">
  |       <h:selectOneMenu value="#{categoryHome.instance.name}" >
  |          <s:selectItems value="#{categoryHome.categoryList}" var="category" label="#{category.name}" />
  |          <s:convertEntity/>
  |        </h:selectOneMenu>
  |     </s:decorate>
  | 
  | </h:form>
  | 

everything works fine. Could anybody explain me why there is such a problem with <s:selectItems> and what are possible solutions for that.

Thanks for help in advance.
(I use Seam 2 CR1 + JBoss AS 4.2.0)

Best regards,
jquery

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086513#4086513

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086513



More information about the jboss-user mailing list