You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Paul Speed <ps...@progeeks.com> on 2002/11/24 05:32:34 UTC

Re: Why can I not use attributes "lang" and "maxRows" in a customtag


"Craig R. McClanahan" wrote:
> 
> On Sat, 23 Nov 2002, Paul Speed wrote:
> 
> > Date: Sat, 23 Nov 2002 18:50:34 -0500
> > From: Paul Speed <ps...@progeeks.com>
> > Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> > To: Tomcat Developers List <to...@jakarta.apache.org>
> > Subject: Re: Why can I not use attributes "lang" and "maxRows" in a
> >     custom tag
> >
> > The Java beans API requires getters.  It does not require setters.
> > No setter means the property is read-only.  There's no such thing as
> > write-only in the Java beans API.
> >
> 
> That turns out not to be the case.
> 
> Section 8.3.1 of the JavaBeans Specification makes it clear that you can
> have either a read-only or a write-only property, in addition to a
> read-write property.

Ok, I'll admit this is true... however, (and it may be a personal
problem) the only way I ever got write-only properties to work was
to setup bean info.  I've had problems getting the introspector to 
find these automatically... especially if you have more than one 
setter.  Whereas, if you add a properly typed getter, everything 
magically works without the extra trouble.

I knew as soon as I made an absolute statement right after waking up 
from a nap, I'd regret it. ;)  Now if beans would just get 
multi-valued properties right... but that's another story. :)
-Paul

> 
> JSP custom tags are a pretty good use case for write-only properties --
> the JSP contracts only require an ability to *set* the property values;
> there is no requirement that the attribute values be made publicly
> available to any other class.  After all, the tag implementation class
> will have internal access to the set value, by referencing whatever
> instance variable the setter stored it in.
> 
> > A getter is the only way to determine what the type of the property
> > is since there can be only one getter with a particular name.  The
> > Java beans API is all about deducing all of this information at
> > runtime... so it must be able to figure this out. (For
> > PropertyDescriptors and such.)
> >
> 
> The user's original problem wasn't that they had a write-only property.
> The problem was that the data type of the getter and setter did not match,
> which violates the design patterns of Section 8.3.  Therefore, te
> JavaBeans introspector does not consider this to be an actual JavaBeans
> property.
> 
> > Not 100% useful as a way to do simple reflection though.
> > -Paul
> >
> 
> Craig
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>