You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ezra Jennings <ez...@yahoo.com> on 2007/07/04 23:27:24 UTC

Re: Best Practice pass data into an included jsp

I tried using s:include with nested s:param tags, but could not read the
parameters using the s:property tag at all.  The only way that I could read
the parameter was by using:

<%= "param1:" + request.getParameter("param1") %> 

as suggested in:
http://www.nabble.com/struts2-how-to-access-a-param-s%3Ainclude-tf2871075.html

I've had success with the following strategy (adapted to your example):

File: callPassRow.jsp

<tr id="sub-<s:property value="param1"/>">
  <td class="canFade indent2"><s:property value="name"/></td>
  <td class="canFade<s:property value="formattedDates"/> </td>
...
</tr>


File: Random jsp's
<s:set name="param1" value="%{'01234'}" scope="action"/>
<s:set name="name" value="%{'foo'}" scope="action"/>
<s:set name="formattedDates" value="%{'25Dec2006'}" scope="action"/>
<s:include value="/web/common/callpassRow.jsp" />


This feels like a Tiles-like strategy to me -- which is actually how I'm
using it:

pageToBeDisplayed.jsp:

<s:set name="analysisParameters" value="%{'includes/tile1.jsp'}"
scope="action" />
<s:include value="template.jsp" />

template.jsp:

<p>Some text</p>
<s:include value="%{#analysisParameters}" />


so that includes/tile1.jsp gets included in template.jsp which is used to
make pageToBeDisplayed.jsp
It may not be the speediest operation, but it does provide flexibility.

Hope this helps...
Ezra

-- 
View this message in context: http://www.nabble.com/S2----parameter-passing-%28newbie%29-question-tf3902253.html#a11437742
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Best Practice pass data into an included jsp

Posted by Chris Pratt <th...@gmail.com>.
You might look into the Tiles project (http://tiles.apache.org), that's
exactly what it's designed to do.
  (*Chris*)

On 7/4/07, Ezra Jennings <ez...@yahoo.com> wrote:
>
>
> I tried using s:include with nested s:param tags, but could not read the
> parameters using the s:property tag at all.  The only way that I could
> read
> the parameter was by using:
>
> <%= "param1:" + request.getParameter("param1") %>
>
> as suggested in:
>
> http://www.nabble.com/struts2-how-to-access-a-param-s%3Ainclude-tf2871075.html
>
> I've had success with the following strategy (adapted to your example):
>
> File: callPassRow.jsp
>
> <tr id="sub-<s:property value="param1"/>">
>   <td class="canFade indent2"><s:property value="name"/></td>
>   <td class="canFade<s:property value="formattedDates"/> </td>
> ...
> </tr>
>
>
> File: Random jsp's
> <s:set name="param1" value="%{'01234'}" scope="action"/>
> <s:set name="name" value="%{'foo'}" scope="action"/>
> <s:set name="formattedDates" value="%{'25Dec2006'}" scope="action"/>
> <s:include value="/web/common/callpassRow.jsp" />
>
>
> This feels like a Tiles-like strategy to me -- which is actually how I'm
> using it:
>
> pageToBeDisplayed.jsp:
>
> <s:set name="analysisParameters" value="%{'includes/tile1.jsp'}"
> scope="action" />
> <s:include value="template.jsp" />
>
> template.jsp:
>
> <p>Some text</p>
> <s:include value="%{#analysisParameters}" />
>
>
> so that includes/tile1.jsp gets included in template.jsp which is used to
> make pageToBeDisplayed.jsp
> It may not be the speediest operation, but it does provide flexibility.
>
> Hope this helps...
> Ezra
>
> --
> View this message in context:
> http://www.nabble.com/S2----parameter-passing-%28newbie%29-question-tf3902253.html#a11437742
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>