You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "Asleson, Ryan" <as...@BIWORLDWIDE.com> on 2004/10/19 21:48:37 UTC

Mapped properties with JSTL

Hello,

I have the following JSTL code fragment that is failing:


<c:if test="${empty form.mappedProperty[13]}">
<c:set target="${form}" property="mappedProperty[13]" value="newValue"/>
</c:if>


The "form" object has a method called getMappedProperty that takes a String
as the key and returns the appropriate value.  There is also a
setMappedProperty method that takes two Strings as parameters, the key and
new value, and sets the value.

This code is failing to compile -- at least, if fails on the c:if line.  I'm
trying to get this to work the way the Struts tags do, where any values that
appear in parentheses are assumed to be parameters to the underlying bean
property method.

How can I modify the above code so it does as I desire?  I figure it has to
be close.  


Thank you!!!






This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Mapped properties with JSTL

Posted by Kris Schneider <kr...@dotech.com>.
The JSTL EL doesn't support the notion of a "mapped" property because the
JavaBeans Spec. doesn't support it. If your "form" class exposes a simple
property of type Map, then that's another story. You can use JSTL to read and
write map entries just fine.

You'll have to use JSP 2.0 before you can get close to being able to arbitrarily
invoke methods. This is done by creating EL functions. JSTL 1.1 comes with a
set of functions in addition to its taglibs.

Quoting "Asleson, Ryan" <as...@BIWORLDWIDE.com>:

> 
> Hello,
> 
> I have the following JSTL code fragment that is failing:
> 
> 
> <c:if test="${empty form.mappedProperty[13]}">
> <c:set target="${form}" property="mappedProperty[13]" value="newValue"/>
> </c:if>
> 
> 
> The "form" object has a method called getMappedProperty that takes a String
> as the key and returns the appropriate value.  There is also a
> setMappedProperty method that takes two Strings as parameters, the key and
> new value, and sets the value.
> 
> This code is failing to compile -- at least, if fails on the c:if line.  I'm
> trying to get this to work the way the Struts tags do, where any values that
> appear in parentheses are assumed to be parameters to the underlying bean
> property method.
> 
> How can I modify the above code so it does as I desire?  I figure it has to
> be close.  
> 
> 
> Thank you!!!

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org