4 Replies Latest reply on Sep 7, 2007 5:37 AM by pmuir

    begginer question - request parameters

    przadka

      Hello,

      I have a very simple question regarding <s:link> parameters. After playing with seam-gen I ve realised that it generates one page for both creating and editing entities. Seam knows that if I pass an id as a request parameter that means it should look for corresponding entity to edit.

      Now, the question: how does Seam know how to map the request parameter into the searching criteria? I dont see any explicit code saying something like

      if (id is set in request) display entity where id=request(id)

      on the corresponding view page (or any other file). I looked through configuration files and did not come across anything relevant. Am I missing something? Is it some default behaviour?

      Thanks for any info.
      Michal Przadka

        • 1. Re: begginer question - request parameters
          delphi'sghost

          I'm no expert on Seam-Gen generated edit pages, but I think it goes like this :

          The edit pages edits a Widget called "widget", it doesn't matter if it is a new one, or an existing one.

          You create a factory method for "widget" which in the same bean, injects the parameter widgetId. The factory method says "If I have an ID, load the widget, otherwise create a new one". Either way, it outjects a Widget called "widget", new or loaded.

          So, you load the edit page, which requests a bean called "widget" so seam calls the factory method on the bean, injecting the parameters beforehand. Your factory method checks the parameter, loads or creates a new widget, and returns it to Seam, which passes it to the page for editing.





          • 2. Re: begginer question - request parameters
            przadka

            thanks for the answer. i did some experiments which seem to confirm it.

            the source of my question is in the paging example in the documentation:

            http://docs.jboss.com/seam/1.2.1.GA/reference/en/html/framework.html#d0e5897


            in the example, the paging parameter (firstResult) is passed as a request parameter which is used by the entityquery component to display proper result set.

            i tried to follow the documentation but i ended up displaying the same result no matter what i pass as the request parameter. im not sure what i did wrong because the request parameter is never assigned explicitly (at least in the documentation example).

            and my question: is there a bug in the documentation (i dont think so) or the firstResult request parameter does not have to be assigned explicitly to the EntityQuery component? if it does not, how to tell seam it should pass it to the entity query from the request parameter?

            best regards,
            michal

            • 3. Re: begginer question - request parameters
              przadka

              solved.

              what i was looking for was the @RequestParameter annotation.

              best regards
              michal

              • 4. Re: begginer question - request parameters
                pmuir

                 

                "przadka" wrote:
                and my question: is there a bug in the documentation (i dont think so) or the firstResult request parameter does not have to be assigned explicitly to the EntityQuery component? if it does not, how to tell seam it should pass it to the entity query from the request parameter?


                This is what the page parameter is for.