Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-05-07
8
Medium Priority
?
950 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 1500 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Suggested Courses

886 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