• 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

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: 41861
908
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.
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic