Solved

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

Posted on 2009-05-07
8
937 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
date show only hh:mm 2 50
oracle query 3 35
populate value based on what is selected in lov 2 67
how to use l_instance in the host command 7 36
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example, show how to take different types of Oracle backups using RMAN.
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.

752 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