• 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

retrieving value from Oracle table number column, converting to value in string column of same row

 
Rancher
Posts: 383
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
"
This is probably simple to do, but for some reason the concept is escaping my brain!! We have a table ("TABLE1") containing, among other things, a column ("COUNTRY_ID") of values in a number format that are inserted into the column from values in a lookup table (list of countries, say "COUNTRIES") of the same Oracle database. Any values being persisted to the database have to correspond to the ID associated with the country selected. However, in a primefaces form we have a field that contains a drop down list of countries that users can choose. Those countries have to appear in their text format on the form (the aforementioned "COUNTRIES" lookup table has a column containing the country names in text "COUNTRY_CODE_DESC", corresponding, of course, to an ID value for each country "COUNTRY_ID"). I am struggling to first of all set any fields in the form that display the country name to a default name (rather than it's associated ID), and at the same time having difficulty getting the same selected country name in it's text format "converted" to it's associated ID so I can persist that ID to the "COUNTRY_ID" column of the table "TABLE1". In essence, text value in form and corresponding ID value in database. I should know this, but as noted, I am struggling with how it should work. I am developing this in java 1.7, using JPA 2.1 and on a JBoss EAP 6.21 server, accessing an Oracle 11 database.

Thank you!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not that familiar with JSF, but the rendered HTML would probably be a simple <select> element with one nested <option> element per country with the ID as value and description as text. For example:
Now all you need to do is translate that to a JSF component. HtmlSelectOneMenu comes to mind.
 
Randy Maddocks
Rancher
Posts: 383
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,

Of course, I hadn't considered the JSF element itself containing the ID and description as text, so simple! Thank you, I will try this!
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
reply
    Bookmark Topic Watch Topic
  • New Topic