5 Replies Latest reply on Nov 28, 2007 7:45 AM by Damian Harvey

    clickable dataTable: DataModelSelection or method parameter?

    Marcus Schmidke Newbie

      Hello all,

      as far as I have understood, I have at least two possibilities to make a clickable list with h:dataTable.

      The first option is to have the selected row injected per @DataModelSelection.

      The second option is to have an action method with parameter, for example:

      <h:dataTable var="task" value="#{aufgabenFreigeber}">
       <h:column>
       <s:link action="#{aufgabenliste.onVersionBearbeiten(task)}">
       <h:outputText value="#{task.version.versionsnummer}" />
       </s:link>
       </h:column>
      </h:dataTable>
      


      Either seems to work perfect, but are there differences? In my eyes, the method parameter way has several advantages:

      - reduces the number of necessary injections (important since every injection must be done on every method call)
      - multiple dataTables on one page may use the same action methods, no different DataModelSelection variables to evaluate

      Does the DataModelSelection way also have advantages? If not, what is it for?

      Marcus.

        • 1. Re: clickable dataTable: DataModelSelection or method parame
          Pete Muir Master

          I prefer page parameters over both.

          @DataModelSelection is a concept from very early Seam (pre 1.0), whilst page parameters came later, and later still parameterized EL.

          • 2. Re: clickable dataTable: DataModelSelection or method parame
            Marcus Schmidke Newbie

            DataModelSelection - understood, thank you.

            "pete.muir@jboss.org" wrote:
            I prefer page parameters over both.


            Page parameters is something I did not work with until now. I've read the documentation and try to understand. I am not sure if I understand the concepts behind it (and behind pages.xml at all).

            I like Seam for it's effort to reduce xml (and it does a great job in this), so until now I did not understand why there comes a new file pages.xml into play.

            I've used it one single time so far, because I needed a page action. That time, I did not understand why I should put something there (I even could have imagined a special page tag which does nothing but calling that action before rendering - with pages.xml, this is one more case of strange behind-the-scenes-magic which no follow up developer will understand on first look at sources).

            With page parameters, there seem again to come a new kind of magic, parameters which jump into URLs where you cannot see at first sight where they come from.

            Why would you prefer page parameters over EL parameters?

            I still have the problem that I have two different, but similar tables on one page with similar action links. With EL parameters, I have one action method for both. Can I even do this with page parameters in an elegant way like this?


            Marcus.

            • 3. Re: clickable dataTable: DataModelSelection or method parame
              Pete Muir Master

              I prefer pages.xml as I find it cleaner and it produces bookmarkable links. We are considering making it possible to define in the facelets themselves.

              Yes, take a look at the way seam-gen, seamdiscs or seampay works for using page parameters.

              • 4. Re: clickable dataTable: DataModelSelection or method parame
                Marcus Schmidke Newbie

                 

                "pete.muir@jboss.org" wrote:
                Yes, take a look at the way seam-gen, seamdiscs or seampay works for using page parameters.


                In the examples, I can see lots of
                <s:link action="disc">
                 <f:param name="discId" value="#{disc.id}" />
                </s:link>
                


                Am I right that, using the page parameter way, there is no automatic conversion? One more thing I liked about EL parameters was that Seam does some work for me (in it's DataModel implementation or so), so that my action code is fully object oriented (speaking in this example's words, my action would be able to work on disc objects, not on disc object's id).

                Obviously, this way is not bookmarkable. But bookmarkability isn't necessary in every case.


                Marcus.


                • 5. Re: clickable dataTable: DataModelSelection or method parame
                  Damian Harvey Master

                  Two points that have got me recently around using the Extended EL for tables with navigation links:

                  1. Your list still needs to be annotated with @DataModel for the extended EL to pass the object. Otherwise it will be null.

                  2. In your pages.xml your navigation rule must have the from-action the same as it is specified in your page link eg.

                  <navigation from-action="#{hotelBooking.selectHotel(hot)}">


                  Cheers,

                  Damian.