aspose file tools*
The moose likes Struts and the fly likes Problem setting form property in action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem setting form property in action" Watch "Problem setting form property in action" New topic
Author

Problem setting form property in action

Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
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

Joined: Aug 29, 2008
Posts: 349
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

Joined: Nov 14, 2008
Posts: 43
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

Joined: Sep 29, 2008
Posts: 12617

You don't provide the action mapping; is it a redirect="true"? Is the form a session or request form?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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)..


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

And change your display name , As per JavaRanch Name Policy ..
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
With session.setAttribute it works but I don't like it very much.

Why it doesn't work with :



Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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 ??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem setting form property in action