You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by An...@enron.net on 2001/04/23 23:40:34 UTC
revision to the html:link tag
currently there are two ways to add parameters when using the link tag. you can
either:
(1) specify 1 parameter using the paramId/paramName/paramProperty/paramScope
attributes of the tag, or
(2) specify a Map of name/value pairs that the name and property attributes
method 1 is obviously limiting.
method 2 is kind of a pain in the butt if you want to include parameters with
values from multiple bean, etc. i get really annoyed at the idea of having to
created an extra Map just to store some values to be used in a URL.
here's my proposal. you can keep the previously mentioned methods of adding
parameters and add another that looks like the following example:
<html:link page="action.do">
<html:urlParam key="param1" name="bean1" property="value1"/>
<html:urlParam key="param2" name="bean2" property="value2"/>
<html:urlParam key="param3" name="bean3" property="value3"/>
click here
</html:link>
this would result in a link that look like this:
<a
href="<base-url>/action.do?param1=bean1.value1¶m2=bean2.value2¶m3=bean3.value3">
click here
</a>
i have written this tag combination for my use, and would be happy to pass it
along if you think it would useful in the struts taglib. basically i used the
same link tag with 2 changes:
1) set the <bodycontent> in the tld to be "JSP"
2) moved construction of the url to the doEndTag method
the urlParam tag just sets creates a Map to store its name-value pairs, stores
it in the PageContext, and sets the parent link tag's name attribute to the new
Map. (as a result, you need to remove this value from the PageContext in the
link tag's release method.)
this tag combination adds some handy new functionality, and is
backwards-compatible as well.
ab