Link to home
Start Free TrialLog in
Avatar of kls1
kls1

asked on

JSF DB Access

What is the recommended mechanism for DB access with JSF?

Can you provide a simple example that I could work from that gives me:

Any config file(s) information I need to add
Any property file information I need to add
A sample JSF file
A sample bean (I'm guessing this will be needed)
Any other code that I would need

I'm using postgres database (I"m guessing that isn't terribly relevant other than the fact that I might be using my JDBC postgres driver) and Tomcat app server

Thanks for any quick responses I need to get going quickly on this.
Avatar of jaggernat
jaggernat

Avatar of kls1

ASKER

I don't see any info on interaction with databases, am I overlooking it?
Avatar of kls1

ASKER

I had found the first one also -- it seems to be geared to MS Access and Windows applications. Mine will be Linux/Unix based.

Does the second one have the needed pieces? I don't see any sample code -- am I missing it?

Thanks...
sample code for what ?
Use SDO: while this isn't very popular in general, it actually works really well with JSF. It's what IBM's Rational tools use to access data. Of course, if you want to really do The Right Thing, you could provide access to the data in an SOA manner, exposing access to the data as a service.
Avatar of kls1

ASKER

Jaggernat -- I hope I'm not being simplistic, but I've been looking for sample code that will do DB access from JSF "the right way". I have just started JSP and JSF, so I am _very_ clueless about what I'm doing (yes, I know Java), therefore am looking for a simple example that gives me all the basic pieces -- as JSF code, bean code, and property config files. Usually I can find this stuff very easily on the net but have not been able to find something that will help me get a quick start (I have people breathing down my throat to get this done quickly and "the right way".
Avatar of kls1

ASKER

Bpmurray -- do you thin either one of these methods would be easy to get a quick start for a newbie in this stuff like me? (Someone who knows Java but is absolutely clueless with JSF and JSP?)

I want to do this the right way but I also need to get it done quickly. (And I want to do it cleanly, I've seen too many messes that have stuck around from people trying to write code quickly...) I guess I want my cake and eat it too.... Is it possible? Or is there a way I'm best off going with in order to satisfy my managers by getting it done fast?
Perhaps a good way to start would be to use the beta of Rational's new version of tools: http://www-306.ibm.com/software/rational/beta/v7/ - sign up for the architect product. This will make it realy easy to create your apps.

Alternatively, since you're happy enough with DB access, encapsulate the DB access in a bean. Then you simply access it using the EL (expression language). So you get something like:
   <x:output value="#{bean.property}">

This gets translated in JSF to a call to bean.getProperty. You can tag the bean as being a "managed bean" in which case it's already know to JSF so you don't have to declare it anywhere. I'll try to throw together a basic example later and post it in the files section.
ASKER CERTIFIED SOLUTION
Avatar of bpmurray
bpmurray
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just one more comment: I got a mail from Sun today about using JSF with the new Java Persistence APIs, which might help you. Have a look at this sample: http://communications1.sun.com/r/c/r?1.1.3J1.2Vc.12RRpW.C00W*O..H.D4F6.1aec.3KCXAZ
Avatar of kls1

ASKER

Thanks for the help and suggestions, I really appreciate it.