aspose file tools*
The moose likes JSP and the fly likes Custom Tag Attribute problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom Tag Attribute problem" Watch "Custom Tag Attribute problem" New topic
Author

Custom Tag Attribute problem

Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

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 ]

Back to Java , again.
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
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

Joined: Mar 18, 2008
Posts: 574
    
    1

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

Joined: May 08, 2007
Posts: 621
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

Joined: Mar 18, 2008
Posts: 574
    
    1

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

Joined: Jan 10, 2002
Posts: 61180
    
  66

Do you really write your code with no indentation?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

I am afraid I did indentation ,sorry.

But I thought you would try to help me.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

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

Joined: Mar 18, 2008
Posts: 574
    
    1

Yes sir,I can understand.
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
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 ]
 
Don't get me started about those stupid light bulbs.
 
subject: Custom Tag Attribute problem