JSF error handling when the bean is not correctly loaded

Hi,
I am doing some error handling in JSF and I want to do it in an elegant way. I have the following scenario for error handling.
When the bean is initialized I load the bean with values from DAO which give SQL Exceptions.
Since the bean is not loaded I properly I have to send the user to an error page showing the error message why I am sending the user to this page.
I can do it by [ FacesContext.getCurrentInstance.redirect("/error.jsf") ] doing so I will loose all the FacesMessages that are added by the exceptions.
Instead I want to use the [ FacesContext.getCurrentInstance.dispatch("url") ] which will allow the transfer of the user but I get the following
16:59:39,341 WARN [lifecycle] executePhase(RESTORE_VIEW 1,com.sun.faces.context.FacesContextImpl@8537f9) threw exception
java.lang.ClassCastException: javax.faces.component.UIViewRoot
and the method that I am calling is
public static void programErrorEnd() {
logger.info("in the prgmErrorEnd mehod");
//intializing the contex object
FacesContext ctx = FacesContext.getCurrentInstance();
try {
//ready to dispatch the url.
//ctx.getExternalContext().redirect("app/error/prgmerror.jsf");
ctx.getExternalContext().dispatch("error/prgmerror.jsf");
} catch (IOException e) {
//TODO what to do when there is an error at this stage.
finally {
ctx.responseComplete();
}Thanks and Regarding
Edited by: sgatl2 on Aug 28, 2008 2:32 PM
Edited by: sgatl2 on Aug 28, 2008 2:45 PM

Just let it throw the exception and define an error-page entry in the web.xml which catches the specified exception (or a superclass of it or a HTTP status code) and displays the error.jsf page accordingly.

Similar Messages

  • Why does URLStream complete event get dispatched when the file is not finished loading?

    I'm writing an AIR kiosk app that every night connects to a WordPress server, gets a JSON file with paths to all the content, and then downloads that content and saves it to the kiosk hard drive. 
    There's several hundred files (jpg, png, f4v, xml) and most of them download/save with no problems.  However, there are two f4v files that never get downloaded completely.  The complete event does get dispatched, but if I compare the bytesTotal (from the progress event) vs bytesAvailable (from the complete event) they don't match up; bytesTotal is larger.  The bytesTotal (from the progress event) matches the bytes on the server. 
    The bytesLoaded in the progress event never increases to the point that it matches the bytesTotal so I can't rely on the progress event either.  This seems to happen on the same two videos every time. The videos are not very large, one is 13MB and the other is 46MB.  I have larger videos that download without any problems.  
    [edit] After rebooting the compter, the two videos that were failing now download correctly, and now it's a 300kb png file that is not downloading completely.  I'm only getting 312889 of 314349 bytes.
    If I paste the url into Firefox it downloads correctly, so it appears to be a problem with Flash/AIR.
    [edit] I just wrote a quick C# app to download the file and it works as expected, so it's definitely a problem with Flash/AIR. 
    Here's the code I'm using:
    package  {
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import flash.net.URLRequest;
        import flash.net.URLStream;
        [SWF(backgroundColor="#000000", frameRate="24", width="640", height="480")]
        public class Test extends Sprite {
            private var fileSize:Number;
            private var stream : URLStream;
            private var url:String = "http://192.168.150.219/wordpress2/wp-content/uploads/2012/12/John-Butler-clip1.f4v";
            public function Test() {
                if (stage)
                    init();
                else
                    this.addEventListener(Event.ADDED_TO_STAGE, init);
            private function init(e:Event=null):void {
                this.removeEventListener(Event.ADDED_TO_STAGE, init);
                stream = new URLStream();
                stream.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
                stream.addEventListener(Event.COMPLETE, onLoadComplete);
                stream.load(new URLRequest(url));
            private function onLoadProgress(event:ProgressEvent):void {
                fileSize = event.bytesTotal;
                var percent:Number = event.bytesLoaded / event.bytesTotal * 100;
                trace(percent + "%");
            private function onLoadComplete(event:Event):void {
                trace("loaded", stream.bytesAvailable, "of", fileSize);
                // outputs "loaded 13182905 of 13184365"
                // so why is it "complete" when it isn't finished downloading?

    Thanks for your quick reply !
    I am relatively new to programming so please bear with me on this as I still haven't managed to grasp some of those things that "make perfect sense". If I am setting mouseEnabled to false doesn't that mean that the object no longer gets MouseEvents ?
    If I have understood you correctly then once the mouseEnabled is set to false the btn object is removed from the objects recognizable by the mouse - hence dispatching a mouseout event (and I am guessing here) from the mouse?
    I still don't get it though, if the listeners are set to the object and the object is no longer accessible to the mouse why is the event still being dispatched ?
    I get it that the making of the object unavailable to the mouse causes the "removing" (deactivating) of the object from under the mouse,
      step 1. deactivate object, and  step 2. (as a result of step 1) register the removal of the object.
    but why is the mouse still listening after step 1?
    Even if the action is that of "out" (as in the object is no longer under the mouse) it still is an action isn't it ? so haven't we turned off the listening for actions ?
    I promise I am not trying to drive you crazy here, this is just one of those things that I really want to get to the root of !
    Thanks,

  • Ask your question.please help itunes will not launch on my computer the icon on desktop has changed to a white folder no error message appears and it appears but then disappears in task manager when the programme will not open quick time is working

    please help i need to fix my itunes it will not launch on my computer . no error message appears it simply will not run. the icon on desktop has changed to a white folder and it still appears in programmes in start menu but will not open. it appears in task manager but disappears when the programme will not open

    You music etc should not be affected by problems with the iTunes program, nevertheless it is always a good idea to backup your data.
    You haven't said if there was any error message when you tried to start iTunes. If  there was one please give it in full.
    Also check to see if QuickTime works, iTunes can not work without it. If QuickTime doesn't work, it has to be fixed before worrying about iTunes.
    Then restart your PC and open your Task manger and select the Processes tab.
    Try to start iTunes, does iTunes.exe appear on the processes tab? If so does it disappear again or remain although the programs does not open?

  • When trying to restore and update my ipod touch it comes up with an error message saying: "The ipod can not be restored this device isnt eligible for the requested build"

    When trying to restore and update my ipod touch it comes up with an error message saying: "The ipod can not be restored this device isnt eligible for the requested build" How do i fix this?

    I am having the same issue. I just had the battery replaced at a third party store. The battery powers the ipod up but it needs to be restored. It is saying it isn't eligible for rebuild. I am running MAC OS 10.4.11  itunes v. 9.0   and I just want it to be restored. I need help.  Oh and its an 8 gb ipod touch.

  • When restoring an iPhoto library I got an "unexpected error" message and the operation could not be completed. Is my best choice to try again?

    One of my external hard drives died. I had several iPhoto libraries in it. Fortunately, I used Time Machine to backup to a Time Capsule and I can see all the iPhoto library icons in Backups.
    When restoring the first iPhoto library, after three hours, I got an "unexpected error" message and the operation could not be completed. Indeed, the restored library is smaller than the library in Backups. Is my best choice to try again and replace the restored library (which apparently must be missing some photos)? It would mean another 3 hours plus of restoration with fingers crossed...
    Any suggestions? Thank you in advance!

    I am always suspicious of using a different OS to the one that was used to run the backup.. ie if you used Snow L to backup then there is absolutely nothing wrong with using SL to restore.
    Mount the TC sparsebundle and verify it using disk utility.
    A5 here. http://pondini.org/TM/Troubleshooting.html
    You might also like to load the widget in Time Machine so you get whatever the full error message is..
    I cannot find any reference to the error code you are getting..
    My recommendation would be to try it on a different computer.. restore the whole backup to an external drive large enough to accept the whole backup.
    Use the manual methods pondini recommends.
    http://pondini.org/TM/FAQ.html
    Q16 17
    Use ethernet only. Turn off wireless so it does not enter the situation.

  • I have LR 5.  When I'm in the book module and select the option to "Send Book to Blurb" i get an error message saying "The file does not have a program associated with it...."  How do I fix this?

    I have LR 5.  When I'm in the book module and select the option to "Send Book to Blurb" i get an error message saying "The file does not have a program associated with it for performing this action.  Please install a program, or if one is already installed, create an association in the Default Programs control panel."
    How do I fix this?

    Try the following user tip:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • HT201210 My iPad is not recognized by Finder or iTunes when it is plugged into the computer.  i ran the Restore sequence and got an error message stating "The iPad could not be restored.  An unknown error occurred (1611).  Can this be fixed?

    My iPad is not recognized by Finder or iTunes when it is plugged into the computer.  i ran the Restore sequence and got an error message stating "The iPad could not be restored.  An unknown error occurred (1611).  Can this be fixed?

    iTunes: Specific update-and-restore error messages and advanced troubleshooting - http://support.apple.com/kb/TS3694 - relating to iPad, iPhone, iPod touch, iTunes
    Security software issues covered in: iTunes: Troubleshooting security software issues - http://support.apple.com/kb/TS3125

  • I get an error message when downloading ITunes :could not access the network location %public%\desktop\

    I get an error message when downloading ITunes "could not access the network location" %public%\desktop\?
    windows vista 32 bit

    Try the following user tip:
    "Could not access network location %PUBLIC%\Desktop\" install errors

  • Recently bought  a new computer and all my music appears in iTunes as well as on my computer in a saved folder. When I try to play the music in iTunes I get an error that reads"the song could not be used because the original file could not be found."

    Recently bought  a new computer and all my music appears in iTunes as well as on my computer in a saved folder. When I try to play the music in iTunes I get an error that reads"the song could not be used because the original file could not be found. Would you like to locate it?" Hope you can help me solve this issue.
    Thanks,
    Shellyboo

    This happens if the file is no longer where iTunes expects to find it. Possible causes are that you or some third party tool has moved, renamed or deleted the file, or that the drive it lives on has had a change of drive letter. It is also possible that iTunes has changed from expecting the files to be in the pre-iTunes 9 layout to post-iTunes 9 layout, or vice-versa, and so is looking in slightly the wrong place.
    Select a track with an exclamation mark, use Ctrl-I to get info, then cancel when asked to try to locate the track. Look on the summary tab for the location that iTunes thinks the file should be. Now take a look around your hard drive(s). Hopefully you can locate the track in question. If a section of your library has simply been moved, or a drive letter has changed, it should be possible to reverse the actions.
    Alternatively, as long as you can find a location holding the missing files, then you should be able to use my FindTracks script to reconnect them to iTunes .
    tt2

  • When I attempt to Extend a PDF document via my LiveCycle server I get the error"Application Alert" The file could not be saved. Are you sure you want to lose your results?

    When I attempt to Extend a PDF document via my LiveCycle server I get the error"Application Alert" The file could not be saved. Are you sure you want to lose your results?
    I can login fine via this address.
    http://[Server Address]:[Port Number]/ReaderExtensions
    And I can apply the extension successfully, but when I attempt to download I receive the error above.
    Application Alert" The file could not be saved. Are you sure you want to lose your results?

    Please check the supported version of flash player on your client machine for LiveCycle : http://bit.ly/1wGD9t4
    Upgrade or downgrade it accordingly.
    Thanks,
    Wasil

  • I restored my ipod, when I went to put everything back on it, I got a message that said, "an error writing to the device, can not sinc.  Then it said the required disc can not be found.  Now what do I do, I have all of this music and apps that I can't get

    Before I restored my ipod, I backed it up then I updated and restored.  The problem is when I went to put everything back on it, I got a message saying that an error writing to the device, can not sync.  Then another message appeared saying that "the required disc can not be found.  Now what do I do?

    Try resetting the iPOd. Nothing will be lost.
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.
    - Also, delet the iPod Phot Cache folder for the second error. For its loation see:
    iTunes: Photo sync creates iPod Photo Cache folder

  • TS3899 When I send an email I get an error message that the receiver does not allow "relaying" it doesn't matter who the recipient si

    When I send/forward an email I get an error message that the recipient does not allow "relaying". It doesn't matter who the recipient is.

    Go into Settings>Mail, Contacts, Calendars>your account>Outgoing mail Server>SMTP>Primary Server then turn Server ON and fill in both User Name & Password>under Outgoing Mail Server.

  • SSRS in SharePoint2013:Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModule

    SSRS in SharePoint2013: There is a report in SharePoint and it contains a sub-report and the sub-report hyperlink. When I click the hyperlink to go to the sub-report, after >10min, I click the "Back to.." button
    on IE to go to the previous page. Then it catch the error as:
    Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
    Details: Error parsing near '
    <!DOCTYPE html PUB'.
    I am using SQL2012 and Sharpoint2013.

    Hi Alisa,
    Thanks for your reply, I changed the web.config, but the issue did not resolved. 
    I add the codes in two parts of the web.config as below, you can find in by keywords “aspnet:MaxHttpCollectionKeys”
    This issue can not reproduce on Chrome only occur on IE.
    So, do you have some details suggestion for me to fix it?
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <configuration>
    <configSections>
    <sectionGroup name="SharePoint">
    </sectionGroup>
    <location path="_layouts/15/TA_AppMonitoringDetails.aspx">
    <appSettings>
    <add key="ChartImageHandler" value="storage=memory;timeout=20" />
    </appSettings>
    </location>
    <location path="_layouts/15/ReportServer/RSViewerPage.aspx">
    <appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="10000" />
    </appSettings>
    </location>
    <system.net>
    <defaultProxy />
    </system.net>
    <appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="10000" />
    <add key="aspnet:RestrictXmlControls" value="true" />
    <add key="FeedCacheTime" value="300" />
    <add key="FeedPageUrl" value="/_layouts/15/feed.aspx?" />
    <add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" />
    <add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    </appSettings>

  • I get an error message when running a back-up from my Macbook Pro: The backup disk image Macbook.sparsebundle could not be accessed (error-1) and the backup did not complete? What is the issue?

    I get an error message when running a back-up from my Macbook Pro: The backup disk image Macbook.sparsebundle could not be accessed (error-1) and the backup did not complete? What is the issue?

    Try Here  >  http://pondini.org/TM/C12.html
    More Info here  >  http://pondini.org/TM/Time_Capsule.html

  • All of a sudden tonight when I went to sync with my iTunesMacPro, I received an error message that the iPhone could not be sync'ed because it needed 6.25 GB more space

    I have a 16 GB iPhone 4S.  Tonight when I went to sync with my iTunes on my MacPro, I received an error message that the iPhone could not be sync'ed because it needed 6.25 GB more space. I still have 2.5 GB free. I sync'ed last night fine.  How could I need 8.75 GB (6.25 +2.5) more space on a 16GB iPhone.  I have added nothing but audio podcasts to my iTunes library on my Mac in the last two days and I have not change the sync setting on my iPhone.  Something has gone haywire.  Any ideas.  Mahalo, Oahu Guy

    I resolved this after some analysis.  Turnes out that iTunes was not recognizing that my music was already installed on my iPhone, so when I tried to sync, iTunes was attempting to load all my music a second time, and there was not enough room on my iPhone for that.  I did a restore from backup today and this appears to have resolved the problem.  I initiatied an iTunes sync and it worked fine.  Not sure where the glitch was.  Could have been in the latest update of the iTunes software.  Not sure.  Anyway, I'm good now.
    Oahu Guy

Maybe you are looking for

  • Should i upgrade from Snow Leopard to Lion on my Macbook Air1,1 ?

    Hi,  I just found out the Macbook Air i bought from my friend recently isn't compatible to upgrade to Mountain Lion. I'm very dissapointed, but thought i would upgrade to OS X Lion instead, so at least i would be able to use iCloud. Two problems: Thi

  • Apple Lossless...is it really???

    Isn't music from Apple's iTunes Music Store purported to be "Apple Lossless?" Of the songs I've downloaded, all are labeled as "Protected AAC audio file," at a bit rate of 128k. Needless to say, they sound like crap when played on a hifi. Is this for

  • Question re: my new iPad

    Hi There-   A question for you. If I have purchased an app for my iPod Touch,,,do I have to re-purchase the same app for the iPad ??? Thanks for your help- Doug

  • Extend tablespace issue

    Hi Experts, We are facing an issue with extending tablespaces using BRTOOLS. As you can see in [this|http://tinypic.com/r/2hx5ydc/4] screen shot, the previous BASIS guy tried to extend the tablespace which caused these errors. Can you please guide me

  • Help with poplist record group query

    Hi, I want to populate a poplist based on the following query: SELECT value FROM table.value WHERE code_parent IS NULL UNION ALL SELECT 'ALL' FROM dual ORDER BY code Now I know that you need 2 columns in the record group to populate a poplist, but I