Solved

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

Posted on 2009-05-07
8
929 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 48

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 48

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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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 48

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 48

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

828 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