Solved

How to use checkbox in java server faces (jsf) when the database is oracle

Posted on 2009-05-07
8
927 Views
Last Modified: 2013-11-24
Hello,

we got a problem with a form that is programmed with jsf.
We got no idea how to programm checkboxes when the database behind is oracle.
A checkbox is usually of type boolean, but oracle cannot handle this type.
 
Do we have to write some kind of wrapper around each checkbox to convert [x] to number "1" and send this to the database?

Any good code example would be appreciated.

0
Comment
Question by:Tolomir
  • 4
  • 4
8 Comments
 
LVL 47

Expert Comment

by:schwertner
ID: 24324076
Checkbox is Boolean (Boolean doesn't exist in the DB), but behind the checkbox sits code.
And PL/SQL and java both support BOOLEAN type.
E.g. the Boolean could be used to conditionally create on the fly SQL statement.
0
 
LVL 27

Author Comment

by:Tolomir
ID: 24324379
ok, will discuss this with the programmer.

I also need some more details why he is not using the oracle jsf api

http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/tagdoc/core/imageIndex.html
0
 
LVL 47

Expert Comment

by:schwertner
ID: 24325107
Checkboxes in most cases are used for two things:

1. To check what to show and what to hide in the Forms (no matter which - Oracle forms, HTML, etc.)
2. As hint how to modify SELECT and DMA statements before executing in order to achieve special
    functionalities and to restrict the data set (in the WHERE clause)
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 27

Author Comment

by:Tolomir
ID: 24326825
Well in this case we want to allow users to specify entries in a form like:

New record:

User 4711 what do you agree more:

I like the weather [ ]
the weather is awful []

What is your favorite color:

green ( )
blue ( )
yellow ( )

This should results in a dataset in an oracle table:

user_number: 4711
likes_weather_yes: true
likes_weather_not:false
preferred_color: green
 
something like that.

the programmer did use postgreSQL before with jsf - it provides the type boolean so binding is no problem at all.
Oracle is different, the programmer cannot bind the datafield "likes_weather_yes" to the checkbox "I like the weather [ ]"

This is, what the entire problem is all about.


Tolomir
0
 
LVL 47

Accepted Solution

by:
schwertner earned 500 total points
ID: 24328185
The checkbox has trigger ot at least the value could be checked:

IF cb_weather = 'checked' THEN v_weatner := 'good' (or TRUE, or YES)
                                           ELSE v_weather := 'bad'   (or FALSE, or NO);
END;

INSERT INTO our_table (weather,....) VALUES (v_weather, ....);
0
 
LVL 27

Author Comment

by:Tolomir
ID: 24328767
interesting approach.  Will discuss it with the programmer tomorrow. Thank you.
0
 
LVL 47

Expert Comment

by:schwertner
ID: 24333778
Glad to help.
0
 
LVL 27

Author Closing Comment

by:Tolomir
ID: 31578887
Programmer insisted that a direct database connection without " if / then / else" should be used due to performance issues. Still for me it's a good approach.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
print map entry 34 69
SQL Query 34 101
servlet filter example 37 63
oracle database - pl sql code - for connecting to multiple databases from 1 database using database links 30 63
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question