Hi Ted,
here follows a example of the tag usage with iterate.
We assume that there is a collection ('catalog') of Book bean available in
the page context. A book bean has 3 properties: a title, a publisher and a
reference at the publisher (I know it exists a unique book reference names
ISBN but this is just an example - ;-) )
A catalog list can be implemented as follow:
<ul>
<logic:iterate id="book" name="catalog" type="Book">
<li>
<hm:link href="http://myserver/order.do">
<hm:linkparam name="publisher" value="<%= book.getPublisher() %>" />
<hm:linkparam name="reference" value="<%= book.getReference() %>" />
<bean:write name="book" property="title" />
</hm:link>
</li>
</logic:iterate>
</ul>
This would generate a list of lines like:
<li><a
href="http://myserver/order.do?publisher=apublisher&reference=45553">The
title of the book</a>
</li>
Assuming the publisher property is 'apublisher' and reference property is
'45553'.
Of course there is a weak point in the example above: we used jsp scriplet
to initialize the parameter values.
I think that this could be improved by being able to refer directly to a
bean property as it is in most of the Struts tag.
However, in the meantime, I've made a little improvement to the linkparam
tag (new source attached) to be able to define the value in the body part of
the tag.
The example above would then become:
<ul>
<logic:iterate id="book" name="catalog" type="Book">
<li>
<hm:link href="http://myserver/order.do">
<hm:linkparam name="publisher">
<bean:write name="book" property="publisher" />
</hm:linkparam>
<hm:linkparam name="reference">
<bean:write name="book" property="reference" />
<:hm:linkparam>
<bean:write name="book" property="title" />
</hm:link>
</li>
</logic:iterate>
</ul>
Personnaly, I found the later example better because there is not jsp
scriplet embedded in the jsp tags (something I usually try to avoid be able
to process my JSP through an XSL processor when I will find it usefull in
the future - to provide several interface layout).
Eric
> -----Message d'origine-----
> De : Ted Husted [mailto:[EMAIL PROTECTED]]
> Envoye : vendredi 8 juin 2001 17:41
> A : [EMAIL PROTECTED]
> Objet : Re: Multiple request parameter for the html:link tag
>
>
> An alternative to maps for multiple dynamic parameters would be helpful.
>
> Could you provide some representative examples of using the tag with
> iterate, and the HTML rendered?
>
> I imagine the one provide would generate
>
> <a href="request.do?action=read&docref=55363">This is the link for the
> rquest.</a>
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/
>
> > Eric Fesler wrote:
> > In a recent project, we had to face quite often the fact that we
> > wanted to use a <html:link> tag with multiple request parameters. I
> > know that this tag allows the use of a Map with all the parameters.
> > However, we found its usage quite difficult specially when the
> > <html:link<> tag was embedded in a <logic:iterate> tag and when the
> > request parameters were dynamic.
>
> > <hm:link href="request.do">
> > <hm:paramlink name="action" value="read" />
> > <hm:paramlink name="docref" value="55363" />
> > This is the link for the request.
> > </hm:
>
>
LinkParamTag.java