• Post Reply Bookmark Topic Watch Topic
  • New Topic

Split Values in a dropdown list  RSS feed

 
vikram karne
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends

i am stuck with a problem for which i need your help.i will list it out as below.

i am having a dropdown in my jsp page a ComboBox. The values in the dropdown are in the form
After 10 minutes
After 20 minutes
After 30 minutes
Before 5 minutes

Now when the user selects a value in the dropdown list ex. After 10 minutes. This value needs to be fetched and i have to retrive 10 & minutes seperately from the string "After 10 minutes" and the values should go into two different colums of 2 tables in the database.

I cannot use a DTO to set these values since the values will be combination pair of value & timetype.
What should be my approach here.
should i use a Hashmap or a Hashtable or some list so that i can send these values from the Action class to the Session Bean method.

please let me know what needs to be done in this case.waiting for a positive reply from your side.

Thanks & Regards
Vikram K
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vikram,
Why can't you just call value.split(" ") and get the two fields from the array for insertion into the database?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Is it always "Minutes"? If so, can't you just assume that and have the amount as the value in the option? <option value="10">After 10 Minutes</option>

2. Do you any control over the database? If so, I'd drop the "Minutes" all together. Just hold a value in the database and always assume seconds, minutes, whatever.

Otherwise, do what Jeanne suggested.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!