Solved

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

Posted on 2009-05-07
8
919 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 27

Author Comment

by:Tolomir
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 47

Accepted Solution

by:
schwertner earned 500 total points
Comment Utility
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
Comment Utility
interesting approach.  Will discuss it with the programmer tomorrow. Thank you.
0
 
LVL 47

Expert Comment

by:schwertner
Comment Utility
Glad to help.
0
 
LVL 27

Author Closing Comment

by:Tolomir
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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 explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now