8 Replies Latest reply on Feb 14, 2007 4:35 PM by Gavin King

    f:param in h:commandLink in h:column

    jk;l jkl; Expert

      Within a h:dataTable's h:column I have a h:commandLink that I want to show a specific URL parameter. Within the commandLink I therefore add an f:param, but it doesn't seem to do anything in the generated URL.

      Even if I have a static value like below, nothing happens (shouldn't every generated URL have an ?paramName=1 appended to it?):

      <h:commandLink action="${bean.method}" value="Do Method">
       <f:param name="paramName" value="1" />

      Why might this be happening?

      Also, when the param value is set to an EL expression, nothing appears. But if I place the expression as just text within the h:column but outside the commandLink it appears as it should (based on each row's value...)

        • 1. Re: f:param in h:commandLink in h:column
          jk;l jkl; Expert

          Could somebody please describe whether the behavior I'm expecting is the behavior that should be happening (because maybe I'm totally wrong about this to begin with)?

          Also, is there anything you can think of related to the use of Seam that might be causing this...or do you think it's totally a JSF issue?

          Any direction would be highly appreciated.

          • 3. Re: f:param in h:commandLink in h:column
            jk;l jkl; Expert

            Apparently I should be using outputLink instead of commandLink to get the parameters to show up...

            So here's the issue I foresee now...each row in the dataTable has a link to a remove method which contains that row's entity id as a request parameter.

            How would I use pages.xml to get the parameter to the method? If I put the pages.xml param element on the page that contains the dataTable, then many links on that page contain a "paramName=0" the first time the page is loaded

            I could use @RequestParameter, but I'd like to use the pages.xml way of doing it

            • 4. Re: f:param in h:commandLink in h:column
              Ben Catherall Newbie

              Why not use the Seam EL extensions, and a @DataModel. Then you can do:

              <h:dataTable var="entity" values="#{myDataModel}">
              <h:commandLink action="#{myComponent.delete(entity)}" value="..." />

              That should be easier!

              • 5. Re: f:param in h:commandLink in h:column
                jk;l jkl; Expert

                I can't get the request parameter to work from pages.xml. My dataTable is as follows. What should be in my myBean.myAction method - anything? Right now it's empty, like it was when I was using DataModel/DataModelSelection...

                <h:dataTable id="table" value="#{myList}" var="a">
                 <s:link value="#{a.text}" action="#{myBean.myAction}" >
                 <f:param name="theId" value="#{a.id}" />

                My pages.xml looks like the following. Should the param element be in the navigation element of the initiating page, the page element of the resulting page, or either? What's the difference? (Right now I've got it commented out in the latter.) The resultPage.xhtml displays information relating to contextualBean...

                <page view-id="/listpage.xhtml">
                 <navigation from-action="#{myBean.myAction}">
                 <begin-conversation />
                 <redirect view-id="/resultPage.xhtml">
                 <param name="theId" value="#{contextualBean.id}" />
                 <page view-id="/resultPage.xhtml">
                 <param name="theId" value="#{contextualBean.id}" />

                • 6. Re: f:param in h:commandLink in h:column
                  Gavin King Master

                  The page parameter goes *directly* beneath the element for the view id you want to link or redirect to (ie. the page that needs the parameter as an input).

                  • 7. Re: f:param in h:commandLink in h:column
                    jk;l jkl; Expert

                    In that case the parameter doesn't show up in the address bar at all. To test whether it's working, I entered a parameter with a value of an entity id that I know exists, but still the appropriate data doesn't show up.

                    When I set "contextualBean.id" from the param element, does the entire contextualBean get refreshed from the database? Or does it just create an empty component and insert the id value?

                    I feel like I am missing some code (either in my "myBean.myAction" method or elsewhere to get that data). Is that the case?

                    • 8. Re: f:param in h:commandLink in h:column
                      Gavin King Master

                      Look at the examples. contactlist is a good one to start with. Also seam-gen uses this stuff.