How to use s:iterator s:include s:param

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use s:iterator s:include s:param

albert kao-2
This display properly:
<s:if test="#session.response.items.itemList">
  <s:iterator value="#session.response.items.itemList">
    <s:property value="description"/>
  </s:iterator>
</s:if>

I refactor to the following two files, which display nothing.
I have other codes in items.jsp which confirms that items.jsp is being used
in showitems.jsp.
Please help.
Thanks.

items.jsp:
<s:set var="itemList" value="%{parameters.itemList}"/>

<s:if test="%{itemList}">
  <s:iterator value="%{parameters.itemList}">
    <s:property value="description"/>
  </s:iterator>
</s:if>



showitems.jsp:
<s:include value="items.jsp">
  <s:param name="itemList" value="#session.response.items.itemList"/>
</s:include>
Reply | Threaded
Open this post in threaded view
|

Re: How to use s:iterator s:include s:param

Yasser Zamani-2
Hi Albert,

I found following at [1].

"Note: Any additional params supplied to the included page are not
accessible within the rendered page through the <s:property…> tag since
no valuestack will be created. You can, however, access them in a
servlet via the HttpServletRequest object or from a JSP page via a
scriptlet.

How To access parameters

Parameters are passed as request parameters, so use the
${param.ParamName} notation to access them. Do not use the property tag
to access parameters in included files."

So it seems you can use ${param.itemList}.

Thanks for using Struts!

Regards.

[1] https://struts.apache.org/tag-developers/include-tag.html

On 2/16/2019 4:33 PM, albert kao wrote:

> This display properly:
> <s:if test="#session.response.items.itemList">
>   <s:iterator value="#session.response.items.itemList">
>     <s:property value="description"/>
>   </s:iterator>
> </s:if>
>
> I refactor to the following two files, which display nothing.
> I have other codes in items.jsp which confirms that items.jsp is being used
> in showitems.jsp.
> Please help.
> Thanks.
>
> items.jsp:
> <s:set var="itemList" value="%{parameters.itemList}"/>
>
> <s:if test="%{itemList}">
>   <s:iterator value="%{parameters.itemList}">
>     <s:property value="description"/>
>   </s:iterator>
> </s:if>
>
>
>
> showitems.jsp:
> <s:include value="items.jsp">
>   <s:param name="itemList" value="#session.response.items.itemList"/>
> </s:include>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]