| Author |
Tag attributes and the setter method
|
Joseph Clark
Ranch Hand
Joined: Sep 10, 2005
Posts: 48
|
|
I am trying to get the "Simple tag with attribute" example on page 511 of HFSJ working. Here's the code . . . The tag handler class and the bean are in $CATALINA_HOME/webapps/simple_tag/WEB-INF/classes/foo. The .tld is in /WEB-INF. When I run it, in Tomcat 5.5.12, I get a NullPointer exception at the line where the iterator is declared in the tag handler. Any thoughts will be greatly appreciated. Thank you,
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
Two big things here. 1) I don't think movieCollection.add("${movie1}"); will work because I don't think EL works inside of scriptlets. 2) <myTags:movieTag movieList="${movieCollection}"> won't find your collection because your never added it to any scope. Try ending the scriptlet with a: request.setAttribute("movieCollection", movieCollection); Fixing this second part alone will solve the NullPointer.
|
A good workman is known by his tools.
|
 |
Chandra Sagi
Ranch Hand
Joined: May 05, 2005
Posts: 162
|
|
Two big things here. 1) I don't think movieCollection.add("${movie1}"); will work because I don't think EL works inside of scriptlets. 2) <myTags:movieTag movieList="${movieCollection}"> won't find your collection because your never added it to any scope. Try ending the scriptlet with a: request.setAttribute("movieCollection", movieCollection); Fixing this second part alone will solve the NullPointer.
I guess these should not be a problem. Micheal, I have given it a try but with no luck. I used SimpleTagSupport to implement DynamicAttributes and also tried to add <dynamic-attributes> in tld. It was mentioned in HFJS on pg562 Q7. Try using this, may be it would solve your problem. Please let me know if you solve it. Thanks Chandu
|
 |
Joseph Clark
Ranch Hand
Joined: Sep 10, 2005
Posts: 48
|
|
Well, this works . . . Thanks for the tip Marc. No telling when it would have occured to me to give the thing a scope. [ March 03, 2006: Message edited by: Michael Clark ]
|
 |
Chandra Sagi
Ranch Hand
Joined: May 05, 2005
Posts: 162
|
|
Marc, No offense. You are correct. Could any of you explain me about Question 7 in HFJS on pg562. Thanks in Advance. Chandu
|
 |
Joseph Clark
Ranch Hand
Joined: Sep 10, 2005
Posts: 48
|
|
I didn't get to dynamic att's yet, Chandu. Did you read Bryan Basham's tutorial?: http://www.coderanch.com/t/170429/java-Web-Component-SCWCD/certification/Tutorial-Dynamic-Attributes
|
 |
 |
|
|
subject: Tag attributes and the setter method
|
|
|