1 Reply Latest reply on May 17, 2007 1:56 PM by stu2

    s:link problem

    statelessbean

      hi,
      i got problem with s:link i need to create in <h:dataTable elements with s:link and need to incject him param like:

      <s:link action='#{stsb.method("12")}'>
       <img src="#{defence.imageSrc}" style="border: none;" />
      </s:link>
      
      public String method(String elem) {}
      


      but i must to set my "12" numer from bean with EL, is this well formed? does this work?
      <s:link action='#{stsb.method("#{sfsb.myparam}")}'>
       <img src="#{defence.imageSrc}" style="border: none;" />
      </s:link>
      


      or maybe is better way to inject=rendered elem?


        • 1. Re: s:link problem
          stu2

           

          "Stateless Bean" wrote:
          hi,
          i got problem with s:link i need to create in <h:dataTable elements with s:link and need to incject him param like:
          <s:link action='#{stsb.method("12")}'>
           <img src="#{defence.imageSrc}" style="border: none;" />
          </s:link>
          
          public String method(String elem) {}
          


          but i must to set my "12" numer from bean with EL, is this well formed? does this work?
          <s:link action='#{stsb.method("#{sfsb.myparam}")}'>
           <img src="#{defence.imageSrc}" style="border: none;" />
          </s:link>
          


          or maybe is better way to inject=rendered elem?


          One very straightforward way that works reliably is to use f:param and @RequestParameter.

          I've found it to be simpler than trying to get the el parameter stuff to work (or the DataModelSelection for that matter) plus you can unit test it (El parameters don't work from SeamTest currently)

          Anyway, here's how it looks in the xhtml:

          <s:link value="del" action="#{catalogMapping.removeMapping}">
           <f:param name="columnNumberToUnmap" value="#{column.rawColumn.columnNumber}" />
          </s:link>
          


          Your image tag would be a peer of the f:param. And in your bean, just mark a variable with @RequestParameter with a name that matches your parameter name. Done.