• Post Reply Bookmark Topic Watch Topic
  • New Topic

[ taglib ] Can the parameters be other types than String ?  RSS feed

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
e.g. <myns oSomething a="1" b="<%=request.getAttribute("foo")%>" />
The attribute a is a string value, so that
should not cause any problems. Is b legal JSP
since I am passing in an Object, not a string ?
Thanks
Pho
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's legal and attributes need not only be String values. For this to work, there are a couple of things that you need to do with your tag handler:
(1) Define the setter method for the b attribute as follows...
(2) Make the value of the <rtexprvalue> element for the b attribute true in your TLD file.
Hope that helps
Simon
[ April 04, 2002: Message edited by: Simon Brown ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simon,
A question about your answer:
Your example uses an Object as the parameter in the signature of your setter for the tag attribute. If one knew that the parameter was going to be a specific class, java.util.Date for example, would there be a down-side to using the specific class rather than Object?
thanks,
bear
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, a specific class is fine too. I was just using Object in the example because request.getAttribute() (from Pho's question) returns just an Object.
Simon
[ April 05, 2002: Message edited by: Simon Brown ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!