On Tue, 16 Jul 2002, Leif Hanack wrote:

> with jstl i still can set a new value:
> 
> <c:set target="${user}" property="name" value="newname"/>
> 
> why?! is this a bug?!
> 
> it seems as if the EL does not care about which interface i defined.
> he always work on the real object type.
> 
> any help?!

Indeed, this is the specified behavior, and nothing else is really
possible in Java.  When you say "the EL does not care about which
interface I defined," this is only partially true; it's actually the Java
language that doesn't care about the interface you defined.  You've
created an object and then stored it in a collection of Objects; the type
of whatever reference you may have originally used is no longer relevant.

Whatever Object you added as a scoped variable is, in other words, an
Object in its own right, implementing certain interfaces, extending
certain superclasses, and instantiating a particular class.  There is no
way to recover information about how you retrieved this object.

If you don't want to let the user set information on an object with
<c:set>, it must not have setter methods.  You can always wrap the
underlying object in a wrapper that provides only one-way access, but an
interface does not provide this protection.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com
(coming in July 2002 from Manning Publications)


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to