You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Bowman <br...@nordicwave.com> on 2001/01/18 20:41:09 UTC
Passing form property into custom tag
This has got to be very simple but I can't figure it out. All I want to do
is pass a form bean property as an attribute value to a custom tag. My
custom tag is called decode and it just converts a code(in this case
country) into a full name. The code comes from the form associated with this
page(in this case itemForm).
I have tried this:
<app:decode codeType="country" code="<bean:write name='itemForm'
property='countryCode'/>"/>
and this
<app:decode codeType="country" code='<bean:write name="itemForm"
property='"countryCode'">'/>
and they both give me the string <bean:write name="itemForm"
property='"countryCode'"> as the code attribute value in the custom tag.
I know "bean:write" probably isn't correct but I don't know what else to
try.
I have the tag defined as the following in my app.tld:
<tag>
<name>decode</name>
<tagclass>com.nordicwave.resourcing.web.taglib.DecodeTag</tagclass>
<bodycontent>empty</bodycontent>
<info>
Decode a code from the code table based on the
parameters provided:
codeType - type of code in the code table
code - code from code table</info>
<attribute>
<name>codeType</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>code</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
Any help would be greatly appreciated.
Thanks in advance,
Brian Bowman
Nordic Wave
Re: Passing form property into custom tag
Posted by Peter Alfors <pe...@irista.com>.
You cannot nest taglibs within each other. (A taglib cannot be an
attribute for another taglib).
However, you could retrieve the countrycode value as a script variable,
and then use that as the attribute of the <app:decode> taglib.
The <rtexprvalue> value for the code attribute of decode must be TRUE
for this to work...
<% String countryCode = theValue; %>
<app:decode codeType="country" code="<%=countryCode%>">
HTH,
Pete