6 Replies Latest reply on Oct 4, 2007 3:55 AM by turkishpirate

    url parameters

    turkishpirate

      Hi all. Can anybody help me with following task:
      I have a page, which renders a list of some commodities. When user clicks on commodity title, i must redirect him to commodity details page.
      But this page must be bookmarkable, so i need to put commodity ID in page url. How can i do this with seam?
      And then, how can i retrieve this parameter from url to use them in db-query?

        • 1. Re: url parameters
          nickarls

          try putting an f:param inside the commandlink

          you should be able to get it from the request parameter map through the faces context.

          • 2. Re: url parameters
            nickarls

            you might also want to search for "page parameter" and @RequestParameter in the docs.

            • 3. Re: url parameters
              turkishpirate

              Thanks a lot.

              "nickarls" wrote:

              you should be able to get it from the request parameter map through the faces context.
              Can you give me some links or small example code, how should i do this?

              • 4. Re: url parameters
                turkishpirate

                 

                "nickarls" wrote:
                you might also want to search for "page parameter" and @RequestParameter in the docs.

                Thanks again

                • 5. Re: url parameters

                  Use Seam Page Parameters and the s:link tag:

                  In pages.xml you define a param tag for your commodity page:

                  <page view-id="/commodity.xhtml">
                   <param name="commodityid" value="#{commodity.id}"
                  </page>
                  


                  Now in your Commodity you need to define a public method to set the commodity id

                  public void setCommodityId(String id){
                   this.id = id;
                  }
                  


                  According to Seam Documentation, any s:link transparently includes the request parameters so you might consider it. I didn't use the tag before so I cannot help you here. Or, you can use the standard outputLink tag of JSF:

                  <h:outputLink value="/commodity.seam">
                   <f:param name="commodityid" value="#{commodity.id}"/>
                  </h:commandLink>
                  


                  • 6. Re: url parameters
                    turkishpirate

                    Great thanks to enrokuta