9 Replies Latest reply on Apr 18, 2008 11:03 AM by mars1412

    page parameter in 2.0.1.GA

    mars1412 Apprentice

      I have a link that opens page a and passes webUserId as request parameter.
      so, now in the browser I see an URL like this.


      ...viewProfile.seam?webUserId=2



      this page's page.xml file defines the corresponding page parameter:


      <param name="webUserId" value="#{webUserHome.webUserId}" required="true" />



      on this very same page, I have a s:link element like this:


      <s:link value="#{messages['galleries']}" view="..user_galleries.xhtml" />
      



      which is rendered as this HTML:


      <a id="j_id60" href="..user_galleries.seam?cid=169">galleries</a>




      • shouldn't the page parameter webUserId be included as a request parameter??



      the reference says:



      Any <s:link> or <s:button> transparently propagates the request parameter 
      if that parameter is listed as a page parameter for the view.

        • 1. Re: page parameter in 2.0.1.GA
          Dragos D Newbie

          s:link takes into account when rendering the target page (usergalleries.xhtml in your case) so the solution is to add the param tag in usergalleries.page.xhtml

          • 2. Re: page parameter in 2.0.1.GA
            Dragos D Newbie

            sorry about previous post but this editor is quite unusual...


            s:link takes into account the target page (usergalleries.xhtml in your case) so the solution is to add the param tag in usergalleries.page.xhtml

            • 3. Re: page parameter in 2.0.1.GA
              mars1412 Apprentice

              oh - I forgot to mention that I also have this page parameter on the target page:


              ..user_galleries.xhtml:
              
              <param name="webUserId" value="#{webUserGalleriesHome.webUserId}" required="true" />
              



              this also does not propagate the page parameter


              the only thing that works is this:


              <f:param name="webUserId" value="#{webUserHome.webUserId}"/>



              which I would not call transparent..


              What am I doing wrong?

              • 4. Re: page parameter in 2.0.1.GA
                mars1412 Apprentice

                The more testing/debugging i do, the more confused I get...


                here is my simple testcase:



                • I have 2 conversation scoped POJO seam components that have a string value.

                • I have 2 testpages



                t1.page.xml


                <param name="pageParam1" value="#{testBean1.value}" />



                t1.xhtml


                     pageParam1:      "#{pageParam1}"<br />
                     testBean1.value: "#{testBean1.value}"<br />
                     
                     <s:link view="/testpages/t2.xhtml" value="goto page 2">



                t2.page.xml


                <param name="pageParam1" value="#{testBean2.value}" required="true"/>




                • I call page 1 by directly entering this URL



                http://.../testpages/t1.seam?pageParam1=XXX



                t2.xhtml


                     pageParam1:      "#{pageParam1}"<br />
                     testBean1.value: "#{testBean1.value}"<br />
                     testBean2.value: "#{testBean2.value}"<br />



                the page renders as expected:


                
                     pageParam1:      "XXX"
                
                     testBean1.value: "XXX"
                goto page 2
                


                my debugoutput shows that these functions are called for this GET request:


                14:57:04,027 INFO  [STDOUT] testBean1.setValue(): XXX
                14:57:04,043 INFO  [STDOUT] testBean1.getValue(): XXX
                14:57:04,043 INFO  [STDOUT] testBean2.getValue(): null



                as you can see testBean2.getValue() is called.


                WHY?


                it seems like t2.page.xml is processed when s:link is rendered?


                is this how it's supposed to be?


                • 5. Re: page parameter in 2.0.1.GA
                  Erdem Agaoglu Newbie

                  I got the same problem (i am not even sure if it is a problem or intended behaviour i dont know about) and in my case it causes a lot more complication.


                  I use nested conversations and when i use a conversation nesting s:link to reach a page with parameters configured in pages.xml, component related to page parameter gets initialized when rendering the s:link containing page. Since i did not follow those links to create a nested conversation, initialized component is placed on the current conversation where it should be parent and not aware of the component.


                  As you may guess, actual problem occurs when i try to nest multiple conversations on same parent. Because component is on the parent, nested ones use the same one which causes unexpected results.


                  I know there is a @PerNestedConversation but i think this is not its place because i think the component should not be initialized at the first place.


                  am i wrong? or whats the reason for s:link to process page parameters?

                  • 6. Re: page parameter in 2.0.1.GA
                    Erdem Agaoglu Newbie

                    Studying a little more and i discovered why.


                    Components initialized only when i omit f:param in s:link and this makes perfect sense as links should include any relevant parameter in the context if i dont override with f:param. So they should read from the components in the context in order to set it. And if i dont have the component in the context it will of course be initialized.


                    Documentation points this out pretty much clear for a careful reader(not me in this case)




                    Any s:link or s:button transparently includes the request parameter. The value of the parameter is determined by evaluating the value binding during the render phase (when the s:link is rendered).

                    • 7. Re: page parameter in 2.0.1.GA
                      mars1412 Apprentice


                      Any s:link or s:button transparently includes the request parameter.

                      should it read?: "includes the page parameter as a request parameter in the URL of the link"


                      if so, it's wrong, because it doesn't:


                      testBean1.java:
                      
                      @Name("testBean1")
                      @Scope(ScopeType.CONVERSATION)
                      public class TestBean1 implements Serializable {
                          private String value;
                      
                           public String getValue() {
                                System.out.println("testBean1.getValue(): "+value);
                               return value;
                          }
                      
                           public void setValue(String value) {
                                System.out.println("testBean1.setValue(): "+value);
                               this.value = value;
                          }
                      
                      }
                      
                      t1.page.xml
                      <param name="pageParam1" value="#{testBean1.value}" />
                      
                      t1.xhtml
                      
                           pageParam1:      "#{pageParam1}"<br />
                           testBean1.value: "#{testBean1.value}"<br />
                           
                           <s:link view="/testpages/t2.xhtml" value="goto page 2">
                      
                      get request for:
                      t1.seam?pageParam1=xxx
                      
                      renderes this html:
                      
                      pageParam1:      "xxx"<br />
                      testBean1.value: "xxx"<br />
                      <a href="/twentyfouract/testpages/t2.seam?cid=332" id="j_id2">goto page 2</a>
                      
                      



                      so nothing is included transparently!


                      if so, the output should be like this:


                      pageParam1:      "xxx"<br />
                      testBean1.value: "xxx"<br />
                      <a href="/twentyfouract/testpages/t2.seam?cid=332&pageParam1=xxx" id="j_id2">goto page 2</a>
                      



                      any ideas?

                      • 8. Re: page parameter in 2.0.1.GA
                        Erdem Agaoglu Newbie

                        yes it actually



                        "includes the page parameter as a request parameter in the URL of the link"

                        but in your test, t2.xhtml does not have a page parameter so links to this page do not have any. i think you should add sth like


                        t2.page.xml
                        <param name="pageParam1" value="#{testBean1.value}" />
                        



                        or i got it completely wrong. worth a try anyway.

                        • 9. Re: page parameter in 2.0.1.GA
                          mars1412 Apprentice

                          yes, that's works, as I have already described in my comment above


                          but in this case the docs should say:


                          includes the page parameter of the links target page as a request parameter in the URL of the link