Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Bean question  RSS feed

 
Erik Pragt
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I have a very simple question, but I can't figure it out:
How do get this to work (partially pseudo code):


The problem is that I want to use the getProperty to display to display the price of the item, but I get the error :

Thanks for your help!

Erik
[ January 27, 2003: Message edited by: Erik Pragt ]
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just check whether u have stored it properly in session scope.
 
Erik Pragt
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, actually, the Vector is in the session. When I use

instead of

it does work..
 
isuraeru
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Erik Pragt:
well, actually, the Vector is in the session. When I use

instead of

it does work..

You can use:
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Erik
Yup, first declare the bean using <jsp:useBean> before using the <jsp:getProperty> and <jsp:setProperty> functions.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Erik
consider these two points,
1. in the first post you provided, you have object "items" in the session which is Vector and not a bean.
2. when you do getProperty then it looks for a bean in page, request, session, application scopes (well this sequence of lookup would be altogether another discussion i would say) and tries to do getAttribute("beanname") from them. if it does find it then tries to get the property you specified.

given these two points, we can easily see that when you tried to do getProperty on the "item" bean it looked for that in page,request,sesssion,application scopes where it didn't find it as you have a Vector of "items" in the session (not the bean), right?
doesn't matter that you did use the for loop. it doesn't change the fact that we don't have the appropriate bean object in the session.
so that approach obviously doesnt work.
as you have Vector of Beans in the session and you want to use each of those bean object separately to getProperty, it won't help you to use useBean tag either...how will it help??
the only way is to ignore use of getProperty tag and use


item.getPrice();


that you suggested in your second post....that is the only way you would get this working....
you can't put objects of beans with the same name in the session....
hope this helps.
regards
maulin.
 
Howard Ralston
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Erik,
Is it possible you spelled the word "property" wrong in your code as you did in your sample?
<jsp:getProperty name="item" propery="price" />
 
Erik Pragt
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, sorry about the typos, the most useful answer came from Maulin. I figured that it wouldn't be possible to do it the way I wanted to do it, but you clearly explained why I was wrong.
My thanks for that, you were a big help. Everyone else: thanks for your response, I also really appriciate that!
Greetings,
Erik
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!