3 Replies Latest reply on Jan 31, 2008 7:35 AM by nepveul

    Seam newbie question

    nepveul

      Hi!

      I'm relatively new to Seam and the related technologies (JSF, hibernate, etc.)

      I'm trying to build a very simple webpage. One of my entity is a User.

      I have some sort of UserList.xhtml page that displays all the user info + a link for each row. I want this link to call an action listener, something like that:

       <h:column>
       <f:facet name="header">action</f:facet>
       <s:link view="/#{empty from ? 'User' : from}.xhtml"
       action="#{bean.action}"
       value="Select"
       id="user">
       <f:param name="userId"
       value="#{user.id}"/>
       </s:link>
       </h:column>
      


      But I want my #{bean.action} to be parametrized.

      So I create a param to this page:
      <param name="action_"/>


      Then I change, the previous code to :

       <h:column>
       <f:facet name="header">action</f:facet>
       <s:link view="/#{empty from ? 'User' : from}.xhtml"
       action="#{action_}"
       value="Select"
       id="user">
       <f:param name="userId"
       value="#{user.id}"/>
       </s:link>
       </h:column>
      


      But that doesn't work, right, because it will resolve #{action_} as some piece of text like "tournamentHome.addUser", but not as a method reference like #{tournament.addUser}.

      I'm sure this is trivial...but can't seem to figure out out to parametrize correctly my action to put under my link.

      Thanks for your help!

      Laurent



        • 1. Re: Seam newbie question
          nickarls

          If I understand you correctly you are looking for some sort of dynamic actions. I'm not sure it can be done with that sort of "double-EL-resolve".

          You can always use multiple links with rendered-conditions like

          <s:link action="{actions.add}" rendered="#{action='add'}">Add</s:link>
          <s:link action="{actions.nuke}" rendered="#{action='nuke'}">Nuke</s:link>
          


          • 2. Re: Seam newbie question
            pmuir

            As nickarls says or

            <ui:param name="bean" value="#{foo}" />
            <ui:param name="action" value="bar" />
            
            <s:link action="#{bean[action]}" />


            would call #{foo.bar} - this is a long standing issue with facelets.

            • 3. Re: Seam newbie question
              nepveul

              thanks guys!