• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Split Values in a dropdown list

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic