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

Frustration with useBean and setProperty  RSS feed

 
John Bateman
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
After countless hours, no joke, of playing with jsp's I am at my wits end.
All attempts to use <jsp:useBean> and a subsequent <jsp:setProperty> have driven me nuts as I cannot for the life of me get my 'setter' methods to be called.
My values are being pased by the form as I can pick them out of the request object. My HTML form names match the public setter method in my bean. And, if I try using a setProperty with the name, property and param tags I get 'cannot find information on "VALUE-FROM-PARAM-TAG" in Bean XYZ.
If I just do a useBean with an ID="ABC" I can set and get all my fields in the ABC bean.
Oh yeah, I have tried page, request and session scope.. changes nothing.
Thanks in advance.

------------------
SOURCE CODE should be SURROUNDED by "code" tags.
Click here for an example
 
Sharmila Abkari
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you tried with the other way of setting properties.
which is
<% stringBean.setMessage("some message"); %>
 
dharmeshc
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello John
Why are you setting all the properties in your code?...do one thins ..You said that the form names in the HTML page and the setter method names match ..so why dont you set all the values using
<jsp:useBean id="someid" class="package.someclass">
<jsp:setProperty name="someid" property="*" />
</jsp:useBean>
This means that all the bean properties with names that match request parameters sent to the page are automatically set
OR
if you still arent comfortable with the above solution try doing it in the following manner
<jsp:setProperty name="someid" property="thepropertyname" param="parameternameinHTML"/>
Here the property is set to the value of a request parameter names "parameternameinHRML"

i hope this helps you ... if not reply back
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you falling in the case-sensitivity trap? Remember, to get a "foo.setBar(String bar)" method to be called, you'd need to use <jsp:setProperty name="foo" property="bar" value="foobar"/> or it won't work.
- Peter

[This message has been edited by Peter den Haan (edited May 02, 2001).]
 
John Bateman
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter den Haan:
Are you falling in the case-sensitivity trap? Remember, to get a "foo.set[b]Bar(String bar)" method to be called, you'd need to use <jsp:setProperty name="foo" property="bar" value="foobar"/> or it won't work.
- Peter
[/B]

(Not being blasphemous when I say the following..)
Holy good God in heavan above... I can't beleive this was the problem. I actually found out that when I switched my case on all my 'input' fields the darn things worked like a charm. I tell you that this solution was NEVER NEVER mentioned anywhere I look at the jsp syntax stuff.
What a pain in the neck.
THank you all for your help... I alway know when I come here someone will be able to help me out.
HURRAH!!!


------------------
SOURCE CODE should be SURROUNDED by "code" tags.
Click here for an example
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!