Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1.2 array validation

 
Varsha Goswami
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had developed an application having a selection box <html:select multiple="true"> with multiple="true" in it as it contains multiple names. Whenever I am selecting a number of names from that selection box then in case of any error, those selection values cannot be retained. But if they are saved successfully then they can be retained.

Attached here are two screenshots:- one in case of selection and other in case of an error.

I need to fix this problem asap.

Please somebody help me....

addUser.png
[Thumbnail for addUser.png]
This is the case when I select the names for the first time
 
Varsha Goswami
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another attachment is here... this is the case when an error comes up when I leave all the other mandatory fields as blank and select only the names from selection box.
ErrorUser.png
[Thumbnail for ErrorUser.png]
Errorneous condition
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean when javascript validations errors occurred, then the select box doesn't show the box selected, well then I say, thats the default behavior of any browser.

If this is not the case, then please explain.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From second post, I'm confused little bit, if you don't fill the mandatory fields, then there ought to be an error.
 
Varsha Goswami
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your immediate response.

I know error will come for mandatory fields, but the selection list box has values selected in it which is not an error. After error am able to retain all the inserted values in the textboxes or dropdown, but only in case of selection box am not able to retain those values.

 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varsha Goswami wrote:After error am able to retain all the inserted values in the textboxes or dropdown, but only in case of selection box am not able to retain those values.

You have to implement some Javascript code to retain this value, I'm not sure about whether Struts Validations support your requirement.
BTW, which validations you're using, client side or server side ?
 
Varsha Goswami
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to apply Javascript validation on this..Currently, I am using server side validations..
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there is no attribute SELECTED for multiple select tag.
If there any, then you can apply some logic like this, when you show the JSP page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic