• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Randy Maddocks
Ranch Hand
Posts: 148
3
  • Mark post as helpful
  • send pies
  • 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!
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 148
3
  • Mark post as helpful
  • send pies
  • 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: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!