• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to store and bind to the view containing multiple values for single field?

 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you please let me know how to save and bind the multiple values for a single field? For example, i have a form with field 'Interested in' and user can select more than one values, in this scenario how do i save the values and how to bind again to the view? what is the best design for this? I am using struts 2.

Similar scenario is like user will select multiple select boxes and i have to persist them and again i have to show the selected boxes in view..


Thanks
Nagaraj
 
Stephan van Hulst
Bartender
Posts: 6654
90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably want a JList. Read the documentation to find out how you can select and get multiple values.
 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I dont want use swings or awt components..

Stephan van Hulst wrote:You probably want a JList. Read the documentation to find out how you can select and get multiple values.
 
Nitin Surana
Ranch Hand
Posts: 129
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is all you need.

http://www.mkyong.com/struts2/how-to-set-default-value-for-multiple-checkboxes-in-struts-2/

If you don't get it, let me know. I'll write another example.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!