• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

new to struts

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.....
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at this example.
 
Jomy George
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks joe you solved my issue.

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