aspose file tools*
The moose likes Struts and the fly likes new to struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "new to struts" Watch "new to struts" New topic
Author

new to struts

Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
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

Joined: Oct 29, 2001
Posts: 8907
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
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

Joined: Oct 29, 2001
Posts: 8907
    
    8

Have a look at this example.
Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
thanks joe you solved my issue.

just string array is enough!... nice
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new to struts