• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL problem with order of gets/sets in class  RSS feed

 
Greg Reinl
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm seeing some strange behavior using the Apache JSTL. When using the "value" attribute in the "formatDate" tag to get a value from an object, I get a JspException:



even though there is a proper "getBirthDate" method that returns a Date object in the MemberImpl class. The strange thing is that there is also a setBirthDate method and when I change the order of the two methods in the class it works fine. If that's not bad enough, the order in which the methods need to be is different between JVMs. (In Websphere it works when the get method is after the set method. In Tomcat it only works the other way around).



Has anyone else run accross this problem? Any ideas how to get around it?

Thanks.

[ June 09, 2004: Message edited by: Greg Reinl ]
[ June 09, 2004: Message edited by: Greg Reinl ]
 
Greg Reinl
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it appears that this behavior occurs when the set method for a property takes one type as the parameter and the get method for that property returns a different type. For example:


So I was able to work around the problem by renaming one of the methods (in this case calling the set method setBirthDateString). But I still don't understand what the root cause of the problem is and that leaves me feeling uneasy.

Once again, does anyone have any thoughts on why this is happening? Is there a more appropriate forum to post this question?

Thanks,
Greg
[ June 11, 2004: Message edited by: Greg Reinl ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most JSTL implementation use the bean API to deal with the various bean objects. This API requires that classes serving as beans follow the bean pattern rather strictly. Deviate from that pattern and odd things will occur.
 
Greg Reinl
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Bear. Good "safety tip"...

Regarding your comment:
This API requires that classes serving as beans follow the bean pattern rather strictly


I haven't done much with java bean components. Pretty much everything I know about the strict requirements for a bean are on this page JavaBeans Component Design Conventions Is there more to it? If so, where can I find additional information?

Thanks again,
Greg
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!