4 Replies Latest reply on Jun 27, 2007 9:22 AM by adrien.loyat

    sending a class threw page parameters

    adrien.loyat

      Hello, I have a pobleme with page parameters.

      I have generated a very simple CRUD application with seam-gen from a database containing 2 tables : col and typecol (which means the sort of col).
      The link between the two tables is : col.type = typecol.id
      typecol.id is an Integer


      The generation is ok. The col class contain a property Typecol typecol. A colList.xhtml was generated too.

      Now, I want to search for col of a certain type. So I've had a selectBox in colList.xtml :

      <s:decorate template="layout/display.xhtml">
       <ui:define name="label">Type de collectivité</ui:define>
       <h:selectOneMenu id="typecol" value="#{colList.col.typecol}" >
       <s:selectItems value="#{typecolList.resultList}" var="untypcol"
       label="#{untypcol.nom}" noSelectionLabel="Select..."
       hideNoSelectionLabel="false"/>
       <s:convertEntity />
       </h:selectOneMenu>
      </s:decorate>
      



      In ColList.page.xml, I've added the param :
      <param name="typecol" value="#{colList.col.typecol}" converter="EntityConverter" />


      In RESTRICTION property of ColList.java, I've added this :
      "col.typecol = #{colList.col.typecol}",


      When I tried the new selectBox, nothing happend.
      I put a conversation scope to colList class, then the search was ok. Was-it good to add conversation scope ?

      Nevertheless, all is not perfect, as I cannot use links (to order the list, or to navigate between the pages of results) because my param typecol is then not written in the url( http://localhost.../ColList.seam?firstResult=25&nom=&cid=4).

      Am I wrong from the beginning ? Am I wrong with the param in page.xml ?
      Thank you for having a look a fiew second at my issue.
      Adrien





        • 1. Re: sending a class threw page parameters
          pmuir

          You can't use the EntityConverter like that in pages.xml. Try something like

          <param name="typecolId" value="#{colList.col.typecol.id}" />


          Or write a custom converter that knows how to deal with a typecol object.

          • 2. Re: sending a class threw page parameters
            adrien.loyat

            Thanks for your help. I've made it work with a custom converter.

            I've tried many changes in the param without success. I'm a bit disappointed as, to my mind, this functionality should work easily in Seam without having to write a custom converter.

            Best regards.
            Adrien

            • 3. Re: sending a class threw page parameters
              pmuir

              It does, just not the way you are going about it. There is lots in the manual about this, and the examples use this.

              • 4. Re: sending a class threw page parameters
                adrien.loyat

                I had a look at the examples but I didn't find anything looking exactly like my issue. My purpose was to, very quickly, add a new search parameter.
                Maybe the way I do this is inappropriate but it seemed to me logical : I can search easily for colList.col.name (a string), so why is it difficult to search for colList.col.typecol (an entity) ? In fact, I was able to search for colList.col.typecol, but I was not able to click on the link so as to order the result because the typecol was then lost.

                Sorry for my english, I try to make it comprehensible with difficulty.