Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 Textfield showing comma delimited values?

 
Drew Kidder
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all...

Being new to Struts 2, I'm hoping someone can help me out here. My form has various textfields and such, among them is a "total" field that adds up three other text fields, something like this:

field a - input
field b - input
field c - input
total - val(a) + val(b) + val(c)

So, an example of what this looks like is this:

field a: 1
field b: 0
field c: 2
total: 3

However, if I submit the form and a validation error occurs, I find this on my form after it refreshes:

field a: 1
field b: 0
field c: 2
total: 3, 3

If another error happens and the submit fails, I get this:

field a: 1
field b: 0
field c: 2
total: 3, 3, 3, 3

What's happening here? Has anyone seen this before? Can anyone help me out on what's going on and potentially how to fix it? I am using the ModelDriven interface and my model is represented by a hash table, so I've been calling {map name}.setProperty("total", "0") to initialize the total property and then setting the desired value with another setProperty call, but no dice. I thought maybe calling setProperty on a value that already exists might be causing it to store multiple copies in buckets, but I'm not sure.



Any ideas on what I should do here or how I can prevent this? Any and all useful suggestions will be appreciated!

Thank you.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No code == no real way to help. My guess is your logic is wrong.
 
Vamshi Jampala
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on my experience
Usually commas appear if you are using the same "name" attribute for multiple fields, cross check that
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how that would make sense--in order to get a CSV value from the action you'd need to have a collection action property.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic