You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Duffy <md...@yahoo.com> on 2003/07/20 23:43:25 UTC
paramId in html-el:link tag - Referenceing a Constant
The "struts-example\registration.jsp" contains the following code:
<html:link page="/editSubscription.do?action=Create" paramId="username"
paramName="registrationForm" paramProperty="username">
<bean:message key="registration.addSubscription"/>
</html:link>
Switching this to an html-el:link tag is easy.
<html-el:link page="/editSubscription.do?action=Create" paramId="username"
paramName="registrationForm" paramProperty="username">
<fmt:message key="registration.addSubscription"/>
</html-el:link>
The value "username" is a key, so it might be better to reference a constant value:
"Constants.USER_NAME_KEY". My question is, how do I do this (without using sriplets)?
If I don't use a quote after paramId=, I get an error when the page compiles. No matter what I
put inside the quotes, it comes into the html as literal.
Any suggestions?
Mike
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: paramId in html-el:link tag - Referenceing a Constant
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Mike" == Mike Duffy <md...@yahoo.com> writes:
Mike> The "struts-example\registration.jsp" contains the following code:
Mike> <html:link page="/editSubscription.do?action=Create" paramId="username"
Mike> paramName="registrationForm" paramProperty="username">
Mike> <bean:message key="registration.addSubscription"/>
Mike> </html:link>
Mike> Switching this to an html-el:link tag is easy.
Mike> <html-el:link page="/editSubscription.do?action=Create" paramId="username"
Mike> paramName="registrationForm" paramProperty="username">
Mike> <fmt:message key="registration.addSubscription"/>
Mike> </html-el:link>
Mike> The value "username" is a key, so it might be better to reference a constant value:
Mike> "Constants.USER_NAME_KEY". My question is, how do I do this (without using sriplets)?
Mike> If I don't use a quote after paramId=, I get an error when the page compiles. No matter what I
Mike> put inside the quotes, it comes into the html as literal.
Mike> Any suggestions?
The EL syntax in this version can reference javabean properties and
collection/map entries. That's it. You can do anything that uses those
features.
You could manually put constant values into a map, and reference the map
entries. If you have to do that a lot, you might consider a class that uses
reflection to "gather" constant values from one or more classes into a map,
keyed by the constant name (perhaps downcasing the keys).
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net ; SCJP; SCWCD
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org