You can use the html:link tag to pass parameters. The example shows how to
pass a single parameter, there is another method involving a Map that lets
you pass multiple key/value pairs as parameters.
<logic:iterate id="restaurant" name="restaurants">
<tr>
<td align="left">
<html:link paramId="restaurantId" paramName="restaurant"
paramProperty="restaurantId" page="/viewRestaurantDetail.do"><bean:write
name="restaurant" property="restaurantName"/></html:link>
</td>
</tr>
</logic:iterate>
> -----Original Message-----
> From: Stephen Schaub [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 19, 2001 9:40 AM
> To: [EMAIL PROTECTED]
> Subject: Writing complicated HTML with embedded bean data
>
>
> I'm rather new to Struts, and have done quite a bit of
> reading, but am just now getting down to some experimental
> development.
>
> One of the issues I'm trying to deal with is how to generate
> things like HTML links without resorting to embedding
> scriptlets.
>
> For example, let's say that I have a bean named 'product'
> with two properties: id and title. I would like to generate
> a link like this:
>
> <A HREF="/myapp/viewinfo.do?id=<<product.id>>">
> <bean:write name="product" property="title"/>
> </A>
>
> I don't want to resort to using a scriptlet to get the
> product id embedded in the link. So far the only solution
> I've seen is in the struts-example app, which uses a custom
> tag in a similar situation to avoid the scriptlet approach.
> That seems like overengineering to me (or maybe I'm just too
> lazy).
>
> It seems to me that the <bean:message> tag might be easily
> adapted to solve this problem. I would like to be able to do
> something like this:
>
> In ApplicationResources, define the following:
>
> product.link=<A HREF="/myapp/viewinfo.do?id={0}">{1}</A>
>
> Then, in the jsp file:
>
> <bean:message key="product.link" arg0="{product.id}"
> arg1="{product.title}"/>
>
> I'm using { } in the arg attributes to indicate that the
> text of the argument should be retrieved from the bean using
> the struts property evaluation system.
>
> What think ye?
>
> Stephen Schaub
>