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 with creating new object in a list in struts tag and adding value to property

 
paddy Mahadeva Iyer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic