5 Replies Latest reply on Sep 26, 2007 1:09 PM by limousyf

    Page parameter question

    limousyf

      Hello,

      I have trouble passing a simple parameter to a page.
      I read the example on page 159 of Michael Yuan's book :


      So when you load a URL such as person.seam?pid=3, Seam automatically invokes the ManagerAction.setPid(3) method (...)


      But my implementation seems nto to work.
      I re-created the exact same situation (I first tried with a boolean value without any success ...)

      Well here's a bunch of my code :

      @Name("activitesByCollaborateurCrossData")
      public class activitesByCollaborateurCrossDataBean implements
       activitesByCollaborateurCrossData {
      
      (bla)
      
       @Out(scope = ScopeType.CONVERSATION)
       private Long realise;
      
      (blabla)
      
       public void setRealise(Long realise) {
       this.realise = realise;
       }
      (blablabla)
      }
      


      Then I created my page parameter in .page.xml file

      <page>
       <param name="collaborateurFrom"/>
       <param name="collaborateurCollaborateurId" value="#{collaborateurHome.collaborateurCollaborateurId}"/>
       <param name="societeSocieteId" value="#{societeHome.societeSocieteId}"/>
       <param name="firstResult" value="#{collaborateurList.firstResult}"/>
       <param name="realise" value="#{activitesByCollaborateurCrossData.realise}" converterId="javax.faces.long"/>
      </page>
      


      And finally I call the page using a s:link

      <s:link view="/PageactivitesByCollaborateurCrossData.xhtml" id="SaisieActivites" >
      <f:param name="collaborateurCollaborateurId" value="1" />
      <f:param name="realise" value="1" />
      <h:graphicImage value="/img/application_form.png" />
      </s:link>
      


      But my "realise" attribute is aways null.
      I put a breakpoint on the set setRealise(Long realise) method but it's never toogled.

      The more unexpected stuff is that the other params, pointing on EntityHome objects are actually working fine !
      In fact, I never succeeded in passing a parameter on a field created by me :/

      What is wrong in my code ?

      (PS: I haven't forgot to put the setRealise signature in the interface)

      Thanks for your help on this

        • 1. Re: Page parameter question
          limousyf

          Hum ... ok.
          Looked like

          converterId="javax.faces.Long"


          is more appropriate (the converter wasn't created but the exception was long is the traffic)

          But now I have a weird error :

          javax.faces.el.EvaluationException: Cannot set value for expression '#{activitesByCollaborateurCrossData.realise}' to a new value of type java.lang.Long
          
          (...)
          
          Caused by: javax.ejb.EJBTransactionRolledbackException: java.lang.NullPointerException
          
          (...)
          
          Caused by: java.lang.NullPointerException
           at crossTable.action.activitesByCollaborateurCrossDataBean.init(activitesByCollaborateurCrossDataBean.java:110)
          


          The line 110 is a line in my @Create method, with absolutely nothing to do with the page parameter.
          It just crash here in fact ...

          • 2. Re: Page parameter question
            limousyf

            My page is still not working but it looks like when a page parameter goes bad (an exception during the setParam), all others parameters are not passed (which should be logical ...)

            BTW, how can I pass my parameter as a boolean instead of a long ?

            • 3. Re: Page parameter question
              dhinojosa

              What does:

              at crossTable.action.activitesByCollaborateurCrossDataBean.init(activitesByCollaborateurCrossDataBe
              an.java:110)
              


              Look like?

              • 4. Re: Page parameter question
                limousyf

                In fact, this line was using another page param, inserted in an EntityHome and which was working well.

                When the "realise" page parameter failed, all the others parameters seems to fail also. So the NPE was normal in fact.

                I still can't pass that parameter :/

                • 5. Re: Page parameter question
                  limousyf

                  To avoid converter problems, I changed my parameter to type String (and removed the "converterId" from my param).
                  But my problem remains: the parameter is not passed (I always have my dumb default value in it) whereas all the other params are actually passed (the one pointings in EntityHome).

                  Did I miss something ?
                  Do the EntityHome objects manage the parameters differently ?