• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new to struts

 
Jomy George
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,

i am doing my first struts application now. during its development i got stopped on using multiple select in a form.
how this can be handled in struts form class?
which data type is used to store the selected values in jsp page?
is it some type of collection class?

one more doubt.. how can i handle validation easily?
by using validate method in form class? or specifying it in xml?
which one is the most popular way amoung developers?

thanks in advance.....
 
Joe Ess
Bartender
Posts: 9313
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As it says at the top of our forum, please indicate which version of Struts you are using. Struts 1 and Struts 2 are very different.
By "multiple select" do you mean a list of values from which one may select more than one value, or a two lists of values, one of which is dependent on the selection of another?

As for validation, I'm a fan of "whatever works". In terms of Struts 2, for basic validation (does a field contain a value), I use XML and the built-in validators. For anything more complex (if field x contains a number greater than 100, field y should contain at least 9 letters), I usually use the action validate method. The more "correct" way to do it would probably be to implement a custom validator and use XML to hook it up.
You also have the option of using annotations instead of XML to configure validations. My personal preference is for XML.
 
Jomy George
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you joe for quick answer

i am using struts 1.3.
for multiple select i mean field which may have more than on evalue from a given list
like hobbies. in my page i have reading , music, dancing, ... select options
user can select any number of hobbies from these

what should i place in my form class to receive these selections?

Thanks once again for your help
 
Joe Ess
Bartender
Posts: 9313
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this example.
 
Jomy George
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks joe you solved my issue.

just string array is enough!... nice
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic