Recommended structure of database-backed JSF app.

I'm learning how to put together a web application using JSF 2.0, Spring and hibernate. I've done a lot of reading on various sites on the 'right' way to do it, and I think I've got the right idea, but I just want to check that I've understood it correctly. (Of course this is more about the structure rather than any specific implementation.)
Here's what seems to be the case:
Hibernate is configured via spring.
POJOs for any persistent entities are mapped to hibernate via annotations (or xml), containing only trivial getters & setters. These methods are never accesses directly by JSF (i.e. these are not managed beans)
Each of these entities has a DAO that does create, read, update, delete (or whatever). These take only object ids (or other identifiers) for reads or entity objects for the other ones, i.e. they don't access all the setters of the POJOs. (As such, can be made generic to reduce code duplication.)
Optionally, each DAO can have a service object that presents the various database operations to the next layer, possibly performing checks and grouping operations together.
Via spring, the service objects are accessible to the JSF beans (or pages).
Now, suppose a simple use case where a user is entering a new record to the database via a web form. The JSF managed bean will be a POJO mirroring all the fields of the relevant entity bean (but not actually be an instance of one). These fields will be bound to the input fields of the form, and if they pass validation, the action (a method of the JSF managed bean) will create a new instance of the entity bean, copy all of its own field into this using its setters, then persist the newly created object with the service object (made available by spring).
Displaying a previously persisted bean would be a similar process in reverse; the JSF managed bean would read an entity bean from the service object, load all its own fields using the getters from the loaded entity bean, then populate the page with these values.
(Obviously this is a very simple case, I imagine there would be cases where the two beans would differ a bit, or perhaps more than simple get/set methods would be used, but I'm just starting out here)
Is this about right? It seems odd to me that one would duplicate all the fields. It should be possible to make the beans do a dual duty, acting as both the entity bean and the JSF managed bean. Hibernate would simply ignore any action methods, and presumably such cases are what the @transient annotation is for.
You'd end up with a single class that has both hibernate and JSF annotations on it.
Is that right?

There is a design forum.
I think you have a few too many keywords in there. Hopefully someone with experience end to end might clear that up.
You'd end up with a single class that has both hibernate and JSF annotations on it.Even if possible I suspect that no one is going to recommend that.

Similar Messages

  • How to connect with Oracle database in JSF ?

    Hi ,
    am very new to JSF,i want to perform a database connection with an Oracle database through JSf.Is there any special tag as such in struts for DB connectivity in JSF?Can any one help me?

    No.
    A database shouldn't even be reached from inside the view layer. Do it in the controller/business layer, e.g. the backing bean. Read on about JDBC, DAO, DTO. If you're already familiar with that, consider an ORM, like Hibernate.

  • XML as DataSource for JSF app

    I am using xml files as the data for a JSF app. I know how to use dataproviders attached to databases in order to display and update data to and from the jsf page. Is there a simple way to do this with XML as the data source?

    Let me just add I would like to be able to do CRUD on the xml

  • Backing up apps

    When I plug in my ipad 2 to my laptop I get a message that there is an update.... When I select download and update I get another warning saying that I have not backed up my purchased apps and to do so... When I select "back up" in iTunes, I don't see anything happening and when I try and download/update it again..... yup, you guessed it... Same warning.
    Help!

    When you go into iTunes, select your iPad and click on the Apps header, the Sync Apps checkbox is checked, correct? Is Automatically sync new apps checked? Does the iTunes layout of your iPad match your actual iPad contents? Have you tried the iTunes>Store>Check for Available Downloads... menu item? You are getting just a warning - Do you still have an active button to do the download and update?  I just want to know if it is there. I would at least like to figure out which apps it is warning you about. I'm pretty sure I got the same message during my upgrade. I do not recall it being a big deal getting past the warning and performing the update.
    When you ctrl/right click the iPad in iTunes, do you get a clear warnings menu item? If so can you try that?
    If you do not get any better advice, I would recommend taking and downloading screenshots of app layouts and going ahead with the update. I think Apple is making sure you have a good, clear and complete backup before starting the update. In case you lose some apps, here is the document for getting them back: http://support.apple.com/kb/HT2519.

  • JSF app extremely slow - too many ActionListeners?

    I'm working on my first JSF app; my assignment is to prepare the next version of an existing app. Currently my testers are complaining that the app is extremely slow. I have observed that page loading takes a very long time; although it isn't nearly so sluggish on my local box (which of course gets bounced more frequently).
    The env is JSF RI 1.1.0 (or 1.1_01, we tried both) running in Sun JES 8.2. Stepping through the debugger I have noticed that the LifecyleImpl maintains a list of ActionListeners. It seems that when the pages, which indirectly extend FacesBean, and have request scope, are constructed they are added to this list, and in the RenderResponsePhase are removed (in the FacesBean afterPhase() method).
    However I am seeing this list growing very large (several hundred listeners), with multiple instances of the same classes. Is this normal/to be expected? It seems that this could be causing a performance drain with the number of times this list is iterated over. What could be causing the removePhaseListener() call to be skipped? What potential harm could be caused if I were to replace the LifecycleImpl with one that in removePhaseListener() removed all listeners of the specified class (rather than just the specified instance).
    I appreciate any clues to what is happening, and how to properly correct it.

    Are you using creator to build your application?No I'm not, but the original team did. So we are dependent on the jsfcl jar.
    Actually, further investigation has revealed at least a part of the problem. And I have to (shamefacedly) admit that I am guilty of poor class structure. The application has a base page class that derives from FacesBean, and provides access to a number of things used throughout the app. I have a utility class that as a convenience extends the base page class in order to take advantage of those objects. But now that I have (at least a rudimentary) grasp on how the PhaseListeners get registered and deregistered, i see that this class will get registered every time one is constructed for use by an actual page. But since it is not itself a real page, it will not get deregistered.
    My task for today is to refactor that class the way it should have been done in the first place. Then I'll connect to the app to see what other objects are hanging around in the listener list and see if they are also using improper inheritance.
    Thanks

  • Just got a new iphone 5s trying to use the app store but it is telling me i am not connected to itunes so i connected to i tunes so when i go back to app store it is still telling me the same thing not connected or signed in  help

    just got a new iphone 5s and i am trying to get on the app store but it is telling me that not connected to itunes  when i connect to itunes it was fine then went back to app store it is telling me sign in to itunes store so i do that with my apple id and password but is still isn't working help

    Hi there wendyfromnewross,
    You may find the troubleshooting steps in the article below helpful.
    Can't connect to the iTunes Store
    http://support.apple.com/kb/ts1368
    Troubleshoot issues on an iPhone, iPad, or iPod touch
    If you haven't been able to connect to the iTunes Store:
    Make sure your date, time, and time zone are correct in Settings > General > Date & Time.
    Note: Time Zone may list another city in your time zone.
    Make sure that your iOS software is up to date by tapping Settings > General > Software Update (iOS 5 or later) or connecting your iOS device to iTunes and clicking Check for Update on your device's Summary page.
    Check and verify that you're in range of a Wi-Fi router or base station. If you're on a device with cellular service, make sure that cellular data is turned on from Settings > General > Cellular.
    Note: If connected to cellular data, larger items may not download. You may need to connect to Wi-Fi to download apps, videos, and podcasts.
    Make sure that you have an active Internet connection. You can check the user guide for your device for help with connecting to the Internet.
    Make sure that other devices (portable computers, for example) are able to connect to the Wi-Fi network and access the Internet.
    Try resetting (turning off and then on again) your Wi-Fi router.
    If the issue persists, try troubleshooting your Wi-Fi networks and connections.
    -Griff W. 

  • HT1766 How do I move a backed up app from my Mac to my iPad?

    How do I move a backed up app from my Mac to my iPad?

    Connect the phone to your computer and select it on the left-hand sidebar of your computer's iTunes (on iTunes 11 on a PC you can enable the sidebar via control-S), and then on the right-hand side of iTunes select the Books tab and you should then be able to select and sync the audiobook to your phone - when you have audiobooks on your phone you should get an Audiobooks section in the Music app

  • I know that iCloud backs-up apps and other stuff to your phone incase you want restore from a back-up if you start a New iPhone. My question is if I start a new iPhone (not use the restore from back-up option) and redownload apps like (games, Instagram),

    I know that iCloud backs-up apps and other stuff to your phone incase you want restore from a back-up if you start a New iPhone. My question is if I start a new iPhone (not use the restore from back-up option) and redownload apps like (Games, Instagram), would my pics show up on Instagram and would my Games show it was saved and the acccomplisments will remain from the last place I left out.

    Davin12 wrote:
    I know that iCloud backs-up apps and other stuff to your phone incase you want restore from a back-up if you start a New iPhone. My question is if I start a new iPhone (not use the restore from back-up option) and redownload apps like (Games, Instagram), would my pics show up on Instagram and would my Games show it was saved and the acccomplisments will remain from the last place I left out.
    Icloud or itunes backup, only backs up app data, not the app itself.
    so if you restore as new, then there is no app data on your phone, you start out new...

  • I have lost my Safari app and all the bookmarks that go with it. I have tried to download my back-up on external drive but cannot access it. Tried a start with C key held down but still no access to the back-up app.

    I have lost my Safari app and all the bookmarks that go with it. I have tried to download my back-up on external drive but cannot access it. Tried a start with C key held down but still no access to the back up app.
    Have used Superduper app. to back up and checked back-up occasionally to see if all files present  and appeared OK.
    I had previously started machine using original CD #1 to try and replace Eudora which was acting up. Did not knowingly touch Safari.
    Running iMAC System 10.4.11
    How can I successfully download from the Maxtor back-up?
    Ivan

    Further info.
    I checked the content of my other back-up and found the bookmark Bookmarks.plist in the library under Safari
    Dumped the existing copy in the computer and drag-dropped the back up. All bookmarks restored.
    Solved the Stickies problem by using Spotlight  to find file "stickiesdatabase" and did a drag- drop to replace file. All data restored.
    Re Ical data loss. Used Spotlight to find iCal document in  Library - Preferences where I found com.apple.iCal.plist in folder.
    Got ready to make change but did not immediately remove file. When I returned to Preferences folder to grab above document,
    the readable descriptors had been changed to code consisting of some upper case letters and/or single symbols!
    So now I cannot tell which is the symbol  iCal.plist
    Thanks for leading me so far, but how do I find that plist for my calendar?

  • I downloaded acdsee camera flash (us$0.99) in Hong Kong's app store, but i cannot find it in the app store after i changed to another iphone. it seems that the app is no longer available in HK, how can I get back the app?

    i downloaded acdsee camera flash (us$0.99) in Hong Kong's app store, but i cannot find it in the app store after i changed to another iphone. it seems that the app is no longer available in HK, how can I get back the app?

    First make sure you are searching the name correctly.
    If the app is no longer in the App Store it is no longer available for download. This happens when Apple has found the app violates the agreement with the developer or when the developer no longer wants the app listed in the App Store.
    If the app is truly no longer in the App Store your only option is to copy it from iTunes on the computer you normall sync with.

  • Beginners question : http 500 error when starting my first jsf-app

    i�ve just read a book about jsf, and now i�ve tried my first own jsf-app, but it seems that i have some kind of configuration problems with my tomcat, but have a look for yourself :
    after deploying my app out of eclipse with ant without any errors, i get the following screen in my firefox when i try to get to the first jsf page :
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Exception in JSP: /pages/start.jsp:13
    10: <link rel="stylesheet" type="text/css" href="basic.css">
    11: </head>
    12: <body>
    13: <f:view>
    14:      <h:form>
    15:           <h:commandButton action="#{naviHandler.startButton1}" value="Seite Eins" />
    16:           <h:commandButton action="#{naviHandler.startButton2}" value="Seite Zwei" />
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NullPointerException
         javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:929)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:310)
         org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:70)
         org.apache.jsp.pages.start_jsp._jspx_meth_f_view_0(start_jsp.java:93)
         org.apache.jsp.pages.start_jsp._jspService(start_jsp.java:68)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
    it says that i have a problem in the line where the first jsf-tag appears : <f:fiew> , but i don�t get it what should be wrong with this?!
    i think theres a kind of config problem with my tomcat or something else, but i dont know where to look after it, the book i�ve read didn�t say much about those things, unfortunately..
    anyone out here who can help me?
    thanks in advance,
    stefan

    ok, i use :
    tomcat 5.5
    myfaces 1.1.4
    jre 1.5.0_09
    anything more you need? as i said in the topic, i�m a real beginner with this..
    and one more thing that i don�t understand :
    all example applications that come with the book that i�ve read are working perfectly with this configuration, but when i try to start my own app i get this error. quite strange for me..
    Message was edited by:
    elliptic

  • My itouch keeps kicking me back to apps screen as it startys to download. It is doing that for most of my games. How do I fix it?

    My itouch kicks me back to app screen every time I try to play games. It starts to download and just jumps back to app screen. How can I fix this?

    Basics from the manual are restart, reset, restore.
    Have you tried each of these?

  • Initial forward in RichFaces app gets 404, but simple JSF app works fine

    (I asked about this on the RichFaces forum, but perhaps this isn't a RichFaces issue.)
    've just started to look deeply into JSF. I'm deploying some test apps to WebLogic 9.2.2. I have two simple apps I'm testing. One is a plain JSF app, and the other is the "echo" RichFaces app.
    When I go to the URL for the plain JSF app, the "index.jsp" successfully forwards to the main page, and it shows up.
    When I go to the URL for the RichFaces "echo" app, I immediately get a 404.
    I added some debug, so I know that it executes my "index.jsp". I also set a breakpoint in org.ajax4jsf.webapp.BaseFilter.doFilter(), and I see it hit that. I also added a debugging lifecycle listener.
    So, with this debug enabled, I get this:
    [DEBUG] BaseFilter - Filter start request processing at 12/31/07 12:05 PM for uri: /AjaxEcho/faces/echo.jsp
    [DEBUG] BaseFilter - Filter request output to XML
    BeforePhase: RESTORE_VIEW 1
    AfterPhase: RESTORE_VIEW 1
    BeforePhase: RENDER_RESPONSE 6
    AfterPhase: RENDER_RESPONSE 6
    [DEBUG] BaseFilter - Finished request processing total time 31ms for uri: /AjaxEcho/faces/echo.jsp
    As that didn't tell me anything, I enabled debug for "com.sun.faces" and "org.ajax4jsf", which produced the output following this. I still don't see any obvious clues here.
    [DEBUG] BaseFilter - Filter start request processing at 12/31/07 1:57 PM for uri: /AjaxEcho/faces/echo.jsp
    [DEBUG] BaseFilter - Filter request output to XML
    [DEBUG] BaseXMLFilter - XML filter service start processing request
    [DEBUG] LifecycleImpl - execute(com.sun.faces.context.FacesContextImpl@1539b09)
    [DEBUG] AjaxPhaseListener - Process before phase RESTORE_VIEW 1
    [DEBUG] InitPhaseListener - Perform additional framework initialization on first request
    BeforePhase: RESTORE_VIEW 1
    [DEBUG] RestoreViewPhase - Entering RestoreViewPhase
    [DEBUG] ViewHandlerImpl - URL pattern of the FacesServlet executing the current request /faces
    [DEBUG] AjaxStateManager - Can't restore view state : no saved view states in se ssion
    [DEBUG] AjaxViewHandler - Detect session expiration in AJAX request - view don't restored for a viewId /echo.jsp
    [DEBUG] RestoreViewPhase - New request: creating a view for /echo.jsp
    [DEBUG] ViewHandlerImpl - Created new view for /echo.jsp
    [DEBUG] ViewHandlerImpl - Locale for this view as determined by calculateLocale en
    [DEBUG] ViewHandlerImpl - RenderKitId for this view as determined by calculateRenderKitId HTML_BASIC
    [DEBUG] RestoreViewPhase - Exiting RestoreViewPhase
    AfterPhase: RESTORE_VIEW 1
    [DEBUG] InitPhaseListener - Remove init phase listener from factories
    [DEBUG] LifecycleImpl - removePhaseListener(ANY 0,org.ajax4jsf.event.InitPhaseListener@b61de0
    [DEBUG] AjaxPhaseListener - Process after phase RESTORE_VIEW 1
    [DEBUG] LifecycleImpl - Skipping rest of execute() because of a reload
    [DEBUG] LifecycleImpl - render(com.sun.faces.context.FacesContextImpl@1539b09)
    [DEBUG] AjaxPhaseListener - Process before phase RENDER_RESPONSE 6
    [DEBUG] AjaxPhaseListener - PhaseListener enter Before RenderView Phase with ViewId /echo.jsp and RenderKitId HTML_BASIC
    BeforePhase: RENDER_RESPONSE 6
    [DEBUG] RenderResponsePhase - Entering RenderResponsePhase
    [DEBUG] RenderResponsePhase - About to render view /echo.jsp
    [DEBUG] ViewHandlerImpl - About to render view /echo.jsp
    [DEBUG] ViewHandlerImpl - URL pattern of the FacesServlet executing the current request /faces
    [DEBUG] ViewHandlerImpl - Found no URL patterns mapping to FacesServlet
    [DEBUG] AjaxContext - Process component tree for collect used scripts and styles
    [DEBUG] InternetResourceBuilder - Return instance of internet resource builder org.ajax4jsf.resource.ResourceBuilderImpl@1011211
    [DEBUG] RenderResponsePhase - Exiting RenderResponsePhase
    AfterPhase: RENDER_RESPONSE 6
    [DEBUG] AjaxPhaseListener - Process after phase RENDER_RESPONSE 6
    [DEBUG] BaseXMLFilter - create HTML/XML parser for content type: null
    [DEBUG] BaseXMLFilter - Parser not have support for the such content type, send response as-is
    [DEBUG] BaseFilter - Finished request processing total time 17721ms for uri: /AjaxEcho/faces/echo.jsp

    I got this working, but it sure seems odd to me. In the working JSF app, I didn't notice that the forward from "index.jsp" references "/faces/main.jsp", even though "main.jsp" is in the root of the app. I changed my RichFaces app to do the same, so it references the "fake" root directory of "/faces". Now it works fine, it's just odd looking. I didn't notice this being called out in the JSF book (Complete Reference).

  • Deploying jsf app on glassfish

    Hello all,
    Deploying a JSF app on glassfish I get the followinf error messsage from admin console:
    Deploying application in domain failed; JSP Compilation Error: org.apache.jasper.JasperException: jsp.error.tld.invalid.signature -- jsp.error.tld.invalid.signature JSP Compilation Error: org.apache.jasper.JasperException: jsp.error.tld.invalid.signature -- jsp.error.tld.invalid.signature
    What does it mean invalod signature

    You are probably missing the ADF Binding layer - You'll need to figure out which JARs are requiered.
    Try looking at your project properties->classpath and libraries and make sure all of them are included.
    For example check out the libraries this guy used to run ADF on Tomcat:
    Re: JDev 11.1.1.1.0 + ADF+ BC4J application on Tomcat6
    Here is a little tip to help you find out which JAR is holding any class that you are missing:
    http://kingsfleet.blogspot.com/2009/10/know-which-class-you-want-but-not-which.html

  • Error deploying JSF app on Sun 8.1 (Works fine on 9.0)

    Hello All,
    I have a simple JSF app which works fine on Sun App server 9.0 but throws the error below on 8.1. Please help!!!
    exception
    javax.servlet.ServletException: java.lang.Boolean
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    root cause
    java.lang.ClassCastException: java.lang.Boolean
         com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
         javax.faces.component.UICommand.broadcast(UICommand.java:312)
         javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
         javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
         com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
         com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)Thanks.
    Message was edited by:
    ndnguy

    Make sure you don't include any JSF implementation jars in your web application.

Maybe you are looking for

  • I-pod crashes and then can't access it for afew hours?

    Hi all, Sometimes my ipod crashes and I cant get in2 it for afew hours sometimes. It just stays on the same screen and I cant go back a menu or play/stop/rew./f.forward. and if the light was on even that stays lit til' it sorts itself out. Often I ha

  • Weblogic client not shutting down properly in web app

    Hi, We have an application running on Tomcat which uses wlfullclient.jar to connect to EJB's hosted on a Weblogic server.  We're seeing errors like the following in the logs when the web application is shutdown, which appear to indicate that the Webl

  • No Airport Card Installed - Post 10.6.6 update

    Hey everyone, I have a fairly new iMac (under 8 months old), and it runs beautifully. However, after the latest update 10.6.6, I'm getting a "No Airport Card Installed" when I click on the grayed out wifi icon in the toolbar. I've gone to the system

  • Can i use my ipod as a temp storage devise?

    to transferr photos from one computer to another?

  • Web Counter

    I have a very simple database that consist of three fields. HitNumber (AutoNumber), Date (Now() which automatically inserts the date) and Site which is the problem. Its very simple all I need is for my page to add the text "Employment" to the site fi