This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes problem with creating new object in a list in struts tag and adding value to property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem with creating new object in a list in struts tag and adding value to property" Watch "problem with creating new object in a list in struts tag and adding value to property" New topic
Author

problem with creating new object in a list in struts tag and adding value to property

paddy Mahadeva Iyer
Ranch Hand

Joined: Feb 10, 2007
Posts: 63
Hi,

I am facing some problem with creating an object within a list using struts tag.

I have a list list1<TypeClass> in my action class with proper setter and getter. In my class TypeClass i have two properties with prop1 and prop2 of type string with proper setters and getters.

In my jsp. i have a code



My list is empty when the jsp is rendered and i am creating this text field dynamucally. As per what i have read if i have the above code a new object will be created in the list and corresponding property field will be populated. But this is not happening.

I replaced the code with



Consider that i am properly updating that index.

Here I found that the new object is created but the property is not being set to the value entered in the textfield.

Can somebody help please?

Thanks in advance
paddy
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Are you sure your getters and setters are correct? Do you have indexed getters and setters. I had a similar problem when I first switched to Struts2 and the problem turned out to be that I wasn't using the generics correctly. Posting your getter and setter code might help.
paddy Mahadeva Iyer
Ranch Hand

Joined: Feb 10, 2007
Posts: 63
Thanks. Same problem here! Generics

I don't know how this works but this is what happened with me. One of my variables is of Type T where T extends Object. So what happened. I had set the generic where i declared the object that T would be string. Once i removed the generic it started working. But that gave me a new problem. For each textfield it was setting in a string array of size 1 with the value in the text field at position 0. I have no idea how struts tried to set a string value as string array into the variable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with creating new object in a list in struts tag and adding value to property
 
Similar Threads
passing parameters
struts 2 s:radio tag
problem calling static method using OGNL
Setting an object with c:set from sessionScope
Help with using a List of Collections which has another List of Collections