This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tags -Passing Objects as parameter  RSS feed

 
Lakshmi Anantharaman
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can we pass Objects as Paratmer into Custom Tags
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can. The easiest way to do this is to declare your attribute as taking a request-time expression by setting the value of <rtexprvalue> (in the tag library descriptor) for your attribute to be true.
<rtexprvalue>true</rtexprvalue>
Then, declare the attribute setter as taking an object (for example a java.util.Date) in the normal way.
public void setMyAttribute(Date d)
Finally, when you use your tag, you can use a JSP expression as the value of the attribute.
<myTag myAttribute="<%= new java.util.Date() %>"/>
This then passes the object to your tag.
Hope that helps...
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!