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?
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.
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?