This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem setting form property in action

 
Fred Artes
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem setting form property in action.

ACTION


FORM


JSP


ERROR
javax.servlet.jsp.JspException: Failed to obtain specified collection
at org.apache.struts.taglib.html.OptionsCollectionTag.doStartTag(OptionsCollectionTag.java:176)

Why my form list property is null ?

[ November 14, 2008: Message edited by: Federico Artebani ]
[ November 14, 2008: Message edited by: Atlantide ]
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need an indexed getter and setter for your list property in addition to the unindex ones you have. That is, make methods with the same names that take in additional parameter, and int. Then use that int to either get the value from the list at the int position or set an individual record at the int position.
 
Fred Artes
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mmmm, I don't know.

After this instruction the list is correctly saved into form


After return mapping findforward, in the jsp, ALL properties of action form are null.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't provide the action mapping; is it a redirect="true"? Is the form a session or request form?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this, this helps..

Put the "list" in scope , either session or request , like



and use "name" attribute to access this , like



and make sure that , there are getter and setter for "id" & "descriz" in class MyRecord( the bean you are using)..
 
Fred Artes
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not a redirect = true and I have a session scope (attribute scope not defined in action mapping --> default scope=session)

I will try with session.setAttribute ...
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And change your display name , As per JavaRanch Name Policy ..
 
Fred Artes
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With session.setAttribute it works but I don't like it very much.

Why it doesn't work with :



 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your action mapping for above action from struts-config.xml, and one doubt, you post the code for MyForm form & you are retrieving in action class as




Is MyActionForm is derived from MyForm ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic