My naming convention to solve this has been:

setDateAsString
getDateAsString

as I think I hit this problem with Struts or something a couple of years
back. It seems to work quite nicely. :)

Hen


On Wed, 6 Nov 2002, David Hainlin wrote:

> Problem solved. Thanks Martin and Robert for your quick responses. Turns
> out, having an overloaded setter pushed the class out of bean spec
> enough. that Refelction and Introspection reported different attributes.
>  When I fixed my (prototype :-) code, poof, the properties were there in
> Bean utils.  So, the bug was in my
> sorta bean.
>
> Here is what I did to fix the problem...
>
> *  * public Date getReceivedDate()
>    {
>       return receivedDate;
>    }
>    public void setReceivedDate(Date val)
>    {
>       receivedDate = val;
>    }
>    public void setReceivedDate*String*(String val)
>    {
>         ...*
> *
> Many thanks
>
>
> David Hainlin wrote:
>
> > Martin, Thanks for your quick reply.
> >
> > Actaully, the getters both return Date but your comment did make me do
> > a double take and I did notice the setters in this case are overloaded
> > with String and Date.  I'll check this out and report back. I'll also
> > confirm with Introspection rather than Reflection as Robert has
> > recommended...
> > David
> >
> >
> > Martin Cooper wrote:
> >
> >> I believe the problem stems from the fact that you have two getters
> >> for each
> >> of the properties that are failing - one that returns a Date and one
> >> that
> >> returns a String. JavaBeans introspection does not allow that, and so
> >> BeanUtils is (correctly) determining that expiresDate and
> >> receivedDate are
> >> not valid properties.
> >>
> >> --
> >> Martin Cooper
> >>
> >>
> >>
> >>
> >>> -----Original Message-----
> >>> From: David Hainlin [mailto:dhainlin@;attbi.com]
> >>> Sent: Wednesday, November 06, 2002 9:52 AM
> >>> To: [EMAIL PROTECTED]
> >>> Subject: [beanutils] Problem with missing attributes
> >>>
> >>>
> >>> I'm having a strange problem which appears to be related to bean
> >>> utils or collections. The issue is Struts is reporting it can't find
> >>> some attributes from some beans being accessed via bean:write tag
> >>> libs.  In researching this, I've discovered that the information
> >>> about the bean being reported by PropertyUtils is in fact missing
> >>> some accessors/attributes.  I downloaded the latest beanutils and
> >>> collections today and still no go.
> >>>
> >>> Here is how I verified the problem: In one of our JSP pages,  we
> >>> kept getting a runtime exception about a bean (Certification)  not
> >>> having an attribute called receivedDate.  To workaround the problem,
> >>> I created another accessor called getReceived which simply calls
> >>> getReceivedDate and all is well...
> >>>
> >>> The problems does not appear to be consistent in that  some
> >>> attributes are picked up and some are not. It even has changed
> >>> across platforms (same code base running on different platforms has
> >>> different attributes missing)
> >>>
> >>> Here is a fragment of code I stuck into the JSP to confirm that
> >>> basic java introspection was working vs what beanutils was
> >>> reporting... Note I wrapped  java.lang.reflect output in parens ( )
> >>> and the PropertyUtils.describe output in brackets []. The row object
> >>> is obtained from an <iterate: tag on the jsp page...
> >>>
> >>> <logic:iterate id="row" name="result" property="certifications"
> >>> scope="request">
> >>> <%out.println("<pre>");
> >>>  java.lang.reflect.Method[] ms = row.getClass().getDeclaredMethods();
> >>>  for(int ind = 0;ind<ms.length;ind++){
> >>>     out.println("("+ms[ind]+")");}
> >>>  java.util.Map m =
> >>> org.apache.commons.beanutils.PropertyUtils.describe(row);
> >>>  for(java.util.Iterator i = m.keySet().iterator();i.hasNext();){
> >>>     out.println("["+i.next()+"] ");}
> >>> out.println("</pre>");
> >>> %>
> >>> ...
> >>>
> >>> Got the following results... note several methods are missing...
> >>>
> >>> (public java.lang.String com.seacor.custom.Certification.toString())
> >>> (public java.lang.String com.seacor.custom.Certification.getName())
> >>> (public void com.seacor.custom.Certification.setName(java.lang.String))
> >>> (public java.lang.String com.seacor.custom.Certification.getNumber())
> >>> (public void
> >>> com.seacor.custom.Certification.setReceivedDate(*java.util.Date*))
> >>> (public void
> >>> com.seacor.custom.Certification.setReceivedDate(*java.lang.String*))
> >>> (public void
> >>> com.seacor.custom.Certification.setExpiresDate(java.util.Date))
> >>> (public void
> >>> com.seacor.custom.Certification.setExpiresDate(java.lang.String))
> >>> (public void
> >>> com.seacor.custom.Certification.setSchool(java.lang.String))
> >>> (public void
> >>> com.seacor.custom.Certification.setNumber(java.lang.String))
> >>> (public java.util.Date
> >>> com.seacor.custom.Certification.getExpiresDate())
> >>> (public java.util.Date com.seacor.custom.Certification.getExpires())
> >>> *(public java.util.Date com.seacor.custom.Certification.getReceived())
> >>> (public java.util.Date
> >>> com.seacor.custom.Certification.getReceivedDate())*
> >>> (public java.lang.String com.seacor.custom.Certification.getSchool())
> >>> [expires]
> >>> [name]
> >>> [school]
> >>> [number]
> >>> [class]
> >>> [received]
> >>>
> >>> As you can see the elements in [] are retrieved from
> >>> PropertyUtils.describe and are missing expiresDate and receivedDate.
> >>> The bean in this case (Certification) is a simple value object with
> >>> public default constructor, simple accessors, and is serialized...
> >>> Any thoughts? I'm hoping it is a simple config problem or something
> >>> obvious I have overlooked.
> >>>
> >>> Thanks in advance
> >>> David
> >>>
> >>>
> >>> --
> >>> To unsubscribe, e-mail:
> >>> <mailto:commons-user-unsubscribe@;jakarta.apache.org>
> >>> For additional commands, e-mail:
> >>> <mailto:commons-user-help@;jakarta.apache.org>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:commons-user-unsubscribe@;jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:commons-user-help@;jakarta.apache.org>
> >
> >
>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-user-help@;jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-user-help@;jakarta.apache.org>

Reply via email to