6 Replies Latest reply on Jun 21, 2007 7:04 AM by idylle

    value of selectItems not posted in the form?

    idylle

      Hi,

      I've got a problem with the h:selectOneMenu and s:selectItems elements.

      If I use h:selectOneMenu with f:selectItem ("id="colaff" " in the code below) , the value chosen in the select box is part of the values submitted with the form, no problem.
      But if I use h:selectOneMenu with s:selectItems ("id="tpcidt" " in the code below), the value selected in the box is ignored when I submit the form.


      <h:form id="collectivitesSearch" styleClass="edit" accept-charset="UTF-8" >
       <s:decorate template="layout/display.xhtml">
       <ui:define name="label">Ville</ui:define>
       <h:inputText id="colvil" value="#{collectivitesList.collectivites.colvil}"/>
       </s:decorate>
      
       <s:decorate template="layout/display.xhtml">
       <ui:define name="label">Type de collectivité</ui:define>
      
       <h:selectOneMenu id="tpcidt" value="#{collectivitesList.collectivites.typcol}">
       <s:selectItems value="#{typcolList.resultList}" var="untypcol" label="#{untypcol.tpclib}" noSelectionLabel="Select..." hideNoSelectionLabel="false"/>
       <s:convertEntity />
       </h:selectOneMenu>
       </s:decorate>
      
       <s:decorate template="layout/display.xhtml">
       <ui:define name="label">Affiliation</ui:define>
       <h:selectOneMenu id="colaff" value="#{collectivitesList.collectivites.colaff}">
       <f:selectItem itemValue="" itemLabel=" " />
       <f:selectItem itemValue="O" itemLabel="Oui" />
       <f:selectItem itemValue="N" itemLabel="Non" />
       </h:selectOneMenu>
       </s:decorate>
      
       <div class="actionButtons">
       <h:commandButton id="search" value="Chercher" action="/CollectivitesList.xhtml?firstResult=0">
       </h:commandButton>
       </div>
      </h:form>


      Should I add something in my pages.xml? (I tried to add the param "tpcidt" but with no effect)

        • 1. Re: value of selectItems not posted in the form?
          pmuir

          Post your backing beans

          • 2. Re: value of selectItems not posted in the form?
            idylle

            Here are my beans :

            The entity bean (just the attributes) :

            @Entity
            @Table(name = "collectivites", schema = "public")
            public class Collectivites implements java.io.Serializable {
            
             private int colidt;
             private Typcol typcol;
             private Departements departements;
             private String colnom;
             private String coltel;
             private String colfax;
             private String coladr;
             private String colcp;
             private String colnmc;
             private String coltlc;
             private Integer colpop;
             private String colaff;
             private String colvil;
            
             public Collectivites() {
             }
            
             + getter and setter
             ...
            


            The query bean :
            @Name("collectivitesList")
            public class CollectivitesList extends EntityQuery {
            
            
             private static final String[] RESTRICTIONS = {
             "lower(collectivites.colnom) like concat('%',lower(#{collectivitesList.collectivites.colnom}),'%')",
             "lower(collectivites.coltel) like concat(lower(#{collectivitesList.collectivites.coltel}),'%')",
             "lower(collectivites.colfax) like concat(lower(#{collectivitesList.collectivites.colfax}),'%')",
             "lower(collectivites.coladr) like concat(lower(#{collectivitesList.collectivites.coladr}),'%')",
             "lower(collectivites.colcp) like concat(lower(#{collectivitesList.collectivites.colcp}),'%')",
             "lower(collectivites.colnmc) like concat(lower(#{collectivitesList.collectivites.colnmc}),'%')",
             "lower(collectivites.coltlc) like concat(lower(#{collectivitesList.collectivites.coltlc}),'%')",
             "lower(collectivites.colvil) like concat('%',lower(#{collectivitesList.collectivites.colvil}),'%')",
             "collectivites.colaff like concat(#{collectivitesList.collectivites.colaff},'%')",
             "collectivites.typcol like concat(#{collectivitesList.collectivites.typcol},'%')",};
            
             private Collectivites collectivites = new Collectivites();
            
             @Override
             public String getEjbql() {
             return "select collectivites from Collectivites collectivites";
             }
            
             @Override
             public Integer getMaxResults() {
             return 25;
             }
            
             public Collectivites getCollectivites() {
             return collectivites;
             }
            
             @Override
             public List<String> getRestrictions() {
             return Arrays.asList(RESTRICTIONS);
             }
            
            }


            • 3. Re: value of selectItems not posted in the form?
              pmuir

              And you get no messages displayed in your h:message/h:messages?

              • 4. Re: value of selectItems not posted in the form?
                idylle

                no, the page is just redisplayed with the whole list of results, ignoring the "tpcidt" and the select box is back to "Select..." instead of having my choice selected.

                If I put this :

                <h:commandButton id="search" value="Chercher" />
                
                in my command button, it works but :
                1- I need the firstresult=0 param
                2- It won't work after if I try to use the next page link to navigate through results pages
                


                • 5. Re: value of selectItems not posted in the form?
                  pmuir

                  Surely you want to call an action on the backing bean. Normally you have action="#{backingBean.foo}". You certainly can't append query string parameters to an action like that.

                  • 6. Re: value of selectItems not posted in the form?
                    idylle

                    But I don't understand why the other elements in the form are Ok and just this one is a problem.