Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Tag Attribute problem

 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code directly quoted from HFSJ 1.4 (page 507,ch 10)




I don't understand where the 'Movie' came from ,what I need to create for attribute?,Should I need to create beans ? or Should I
need to create Map?

The real question is what is movie? and What is ${movieCollection}?

I created Movie bean with two property namely name,genre and their getter
and setter method and also created movieCollection as a list under SimpleTagTest5 class but when I run the program I get : java.lang.NullPointerException

I am really confused please help.

note:The tld file is fine and directive are declared correctly.

[ April 17, 2008: Message edited by: omi sharma ]
[ April 17, 2008: Message edited by: omi sharma ]
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

i am not that thorough and sure with all concepts but still will try to explain on the concept as below.

1)we are actualy creating dynamic attribute "movie"
for a custom tag(i.e a user defined tag)......

2)so for creating attribute we have to create class that extends
SimpleTagSupport.

3)Now "movie" attribute is of type List
i.e it consist of list of elements,through which we iterate using
iterator.

4)And later part of DD ie web.xml
consist of element <mytag:simple5>,->it is custom tag
which has attribute present in EL(expression language).

5)As movie attribute is of type list we refer it as moviecollection
and furthur the elements in list are accessed as.
movie.name
movie.genre

I hope if it helps you to some extent.


SCJP(1.5),SCWCD(On the way....)
Dhwani:>Winning is not important but it is the only thing.
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL, I know those concepts but still get the problem, null pointer exception ,don't know why.
I am going to put the rest of the files and their codes.

my Movie Bean


you said movie should be list then how on earth we can do map and bean
like activity via a list i.e. ${movie.name}?

movie-->> only map or bean.
name-->> map key or bean property.

so Movie can not be list and must be bean or map.

I wanted to ask why I am getting Null pointer exception?
What I need to fix and where?

[ April 17, 2008: Message edited by: omi sharma ]
[ April 17, 2008: Message edited by: omi sharma ]
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi omi

I am realy sorry for the above
anyways ....

what goes is in the class SimpleTagTest5

List is of type -> movie...as shown below.



and i guess

movie ->>is a Bean
name ->>is a bean property

and on NullpointerException what i just figured
out was as below





i hope if it helps you to some extent..............

SCJP(1.5),SCWCD(On the way)
Dhwani:>Winning iis not important but it is the only thing.
 
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 dhwani mathur:
[QB]Hi omi

I am realy sorry for the above
anyways ....

what goes is in the class SimpleTagTest5

List is of type -> movie...as shown below.



and i guess

movie ->>is a Bean
name ->>is a bean property

LOL,I know that what above you tried to tell me because the Bean
class is created by me.Absolutely you missed the point my dear friend,
the problem is not getJspBody.invoke(null) but the problems are these three
things

${movieCollection} (must be this one)
${movie.name}
${movie.genre}

if you have the book named Head first Servlet and Jsp then you can find that on page 507 and ch 10.

The example on the book is missing several things but I added some
classes to complete the example and the result is the null pointer exception.

The problem is still persists ,still get null pointer exception.


best regards,
omi
[ April 17, 2008: Message edited by: omi sharma ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really write your code with no indentation?
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid I did indentation ,sorry.

But I thought you would try to help me.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by omi sharma:
But I thought you would try to help me.

The guidelines aren't there to harass you, they're there to help you. The use of code tags is urged because it preserves the indentation of the code. Unindented code is very hard to read. The harder the code is to read, the fewer people will take the time to read it and help you.

I'd recommend going back and fixing your posted code (don't re-post it, that will just be confusing) with indentation. That way, more people will take the time to read it.
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sir,I can understand.
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi omi

i have the book head first Servlets and JSP
i am too learning from the same ,i
will have a look into it and later as i get
some solution will fetch back.

SCJP(1.5),SCWCD(On the way)
Dhwani:>Winning is not important but it is the only thing.
[ April 17, 2008: Message edited by: dhwani mathur ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic