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.
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
Joined: Feb 10, 2007
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.