aspose file tools*
The moose likes Struts and the fly likes Struts 2 Textfield showing comma delimited values? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 Textfield showing comma delimited values?" Watch "Struts 2 Textfield showing comma delimited values?" New topic
Author

Struts 2 Textfield showing comma delimited values?

Drew Kidder
Greenhorn

Joined: Jan 26, 2010
Posts: 2
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.



--
Drew Kidder
Java codeslinger and Struts 2 n00b
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No code == no real way to help. My guess is your logic is wrong.
Vamshi Jampala
Ranch Hand

Joined: Feb 23, 2008
Posts: 40
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 Textfield showing comma delimited values?