Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem from HFSJ book

 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is problem from book HFSJ (page 507,ch 10)





Above , I have no idea what is 'Movie' and how to set ${movieCollection}?
I am getting annoying Null pointer exception.

I am really curious know to how to pass el as a custom tag attribute?

I hope you understand my problem ,please solve it.

best regards
omi
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
movieCollection needs to be a List saved as an attribute of some scope... and that list needs to be full of Movie objects!

I'm not a huge fan of scriptlets, but they can be useful to test something quick and dirty:


Assuming you've got a Movie class out there, this scriptlet should make it work.
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But Marc I thought Movie is a bean and I did the following with no success.
Where I am wrong? (still get null pointer exception)
Updated code :

[ April 17, 2008: Message edited by: omi sharma ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Movie is a bean. Why do you imply that I'm challenging its bean-ness?

Setting movieCollection inside the tag class doesn't make sense. You are supposed to set it before the JSP reaches the simple5 tag so the EL will pass the movieCollection into the tag class using the setMovieList method.

movieList is null. Why are you assuming that it shouldn't be null based on your code?

Then inside the tag you need to set an attribute called movie so that the EL in the tag's body can display it. (Which you have correct near the bottom)
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marc Peabody:
Movie is a bean. Why do you imply that I'm challenging its bean-ness?

Setting movieCollection inside the tag class doesn't make sense. You are supposed to set it before the JSP reaches the simple5 tag so the EL will pass the movieCollection into the tag class using the setMovieList method.

Then inside the tag you need to set an attribute called movie so that the EL in the tag's body can display it. (Which you have correct near the bottom)


Marc , do you mean I have to set movieCollection inside JSP page
instead of Tag class?

I could not understand the last line(sorry for that),how do I
correct the movie bean? you said I have to correct it near the bottom
what's that mean?

What's Movie inside the Tag class ,I assumed it as a Bean,am I right?

According to the book ,the tag simple6 should iterate movie's values? Please clarify this.

However, your scriptlet solution hit the goal and I solved my problem.
Thanks for that by the way.

But one more question,is there any alternative, because like you I also
hate scriptlet LOL.

best regards,
omi

[ April 18, 2008: Message edited by: omi sharma ]
[ April 18, 2008: Message edited by: omi sharma ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic