The body of <jsp:useBean> is only processed the first time the bean is created.

Outside loop:

<jsp:useBean id="paramMap" class="java.util.HashMap"/>

Inside loop:

<c:set target="${paramMap}"
       property="pageName" value="${topMenuItem.menuItemName}"/>
<c:set target="${paramMap}"
       property="menuBlock" value="${topMenuItem.link}"/>

Quoting Joanne L Corless <[EMAIL PROTECTED]>:

> Hi,
> 
> I am building an application based around struts that needs a number of
> html:link's building in the JSP. I have successfully built the
> functionality using a single parameter, however I need to use multiple
> parameters passed into the struts action.
> 
> It is sort of working using a jsp:useBean and setting the parameters,
> however this works only for the first object in the list. All the other
> item's in the list display the correct name but the parameters are the same
> as the first object.
> 
> Is this because the bean has been set into the page scope and if it is how
> can I fix this ?
> 
> The code in the page is below:
> 
> <c:forEach var="topMenuItem" items="${topMenu}">
> 
>   <c:choose>
>     <c:when test="${topMenuItem.menuItemName eq currentPageName}">
>       <td valign="bottom" align="right" class="tabselected">
>       <img src="<c:out value="
> ${commonImagePath}/page_name_left_selected.gif"/>" border="0">
>       </td>
>       <td valign="bottom" background="<c:out value="
> ${commonImagePath}/page_name_mid_selected.gif" />" align="center" class
> ="tabselected" nowrap style="background-repeat: repeat-x;">
>            <span class="tabselected"><c:out value="
> ${topMenuItem.menuItemName}"/></span>
>       </td>
>       <td valign="bottom" align="left" class="tabselected">
>       <img src="<c:out value="
> ${commonImagePath}/page_name_right_selected.gif"/>" border="0">
>       </td>
>     </c:when>
>     <c:otherwise>
>      <jsp:useBean id="paramMap" class="java.util.HashMap" scope="page">
>       <c:set target="${paramMap}" property="pageName" value="
> ${topMenuItem.menuItemName}"/>
>       <c:set target="${paramMap}" property="menuBlock" value="
> ${topMenuItem.link}"/>
>     </jsp:useBean>
> 
>         <td valign="bottom" align="right" class="tabunselected">
>         <html:link action="/changePage"
>                name="paramMap">
>         <img src="<c:out value="
> ${commonImagePath}/page_name_left_unselected.gif"/>" border="0">
>       </html:link>
>       </td>
>       <td valign="bottom" background="<c:out value="
> ${commonImagePath}/page_name_mid_unselected.gif" />" align="center" class
> ="tabselected" nowrap style="background-repeat: repeat-x;">
>        <html:link action="/changePage"
>                name="paramMap">
>          <span class="tabselected"><c:out value="
> ${topMenuItem.menuItemName}"/></span>
>       </html:link>
>       </td>
>       <td valign="bottom" align="left" class="tabunselected">
>        <html:link action="/changePage"
>                name="paramMap">
>         <img src="<c:out value="
> ${commonImagePath}/page_name_right_unselected.gif"/>" border="0">
>       </html:link>
>       </td>
>     </c:otherwise>
>   </c:choose>
> </c:forEach>
> 
> I would really appreciate some help with this
> 
> Regards
> 
> Joanne Corless
> 
> CSC Computer Sciences Limited
> (   Office +44 (0)1772 318025
> ( Mobile +44 (0)7767 656588
> * email [EMAIL PROTECTED]
> 
> 
> Based at: CSC, Alliance House, Library Road, Chorley, Lancs, PR6 7EN
> CSC Computer Sciences Limited: Registered in England, No. 963578.
> Registered office: Royal Pavilion, Wellesley Road, Aldershot, Hampshire,
> GU11 1PZ.

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to