Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tag attributes and the setter method

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't get to dynamic att's yet, Chandu.

Did you read Bryan Basham's tutorial?:

https://coderanch.com/t/170429/java-Web-Component-SCWCD/certification/Tutorial-Dynamic-Attributes
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic