Error handling in overridden methods in AbstractPageBean

Hi,
I'm writing a small app in JSF. One of the pages populates a bunch of text fields from an XML file whose name is passed into the app as an initialization parameter. The purpose of the page is to allow editing of the fields.
It seemed that the prerender() method was the right place to initialize the fields in the form. I have an application-scoped bean trying to open the XML file. I don't want the app to barf on initialization if the file doesn't exist, because the application contains the logic to create the file. So it just sets the appropriate forward target ("file does not exist" page, or maybe XML parse error) and lets the pages that use those bean properties decide when and if they need to display the initialization error page.
I would like to throw an exception from the prerender() method in my page, and have the error handling specified in web.xml. The problem, of course, is that I can't throw my own exception from prerender().
So, have I got the wrong place to initialize my form, or do I have to throw a javax.faces.FacesException, or have I got this whole error-handling thing wrong?
Any advice would be gratefully received.
Many thanks.
Regards,
Mike
public void prerender(){
        // Get ApplicationBean1 to forward the request if we fail to
        // initialize properly.
        ApplicationBean1 ab1 = getApplicationBean1();
        HttpServletRequest req = (HttpServletRequest) this.getFacesContext().
                getExternalContext().
                getRequest();
        HttpServletResponse res = (HttpServletResponse) this.getFacesContext().
                getExternalContext().
                getResponse();
        if(!ab1.isInitialized()){
            //The initialization code for ApplicationBean1() sets the
            //target when it detects an error and then forwards the
            //request to that target upon invocation of the forwardRequest
            //method
            ab1.forwardRequest(req,res);
        // These are the input components
        tfClonebase.setValue(ab1.getClonebase());
        tfDhcpdconf.setValue(ab1.getDhcpdconf());
        tfNamedrev.setValue(ab1.getNamedrev());
        tfNamedzone.setValue(ab1.getNamedzone());
        tfPxelinux.setValue(ab1.getPxelinux());
        tfXmldir.setValue(ab1.getXmlDir());
    }

Well, I'm certainly no expert, but prerender() is called, as you might expect, just before rendering takes place (but only if the page will actually be rendered). This means it won't be called for a page that handled a postback but then navigated to a different page. Good place to handle initializations that happen before rendering.
So my thinking was that I could initialize stuff before there's anything in the response, making it easier to bail out if something goes bad.
But I really can't work out the right way to bail out: I can't throw my own exception because the prerender() is overridden from AbstractPageBean. So I suppose I could create a MikesBadInitException e and throw it inside a new javax.faces.FacesException(e). But I'd like to specify an error-page in my web.xml for MikesBadInitException, and don't want to handle all javax.faces.FacesExceptions, if you get my drift.

Similar Messages

  • Error handling by Add_from_instance method

    Hello,
    I would like to know how can we handle errors in ABAP OO by the add_from_instance method.
    Kindly suggest your answers.
    Regards,
    Prerna.

    Hello Perna
    I assume that you mean the instance method from interface <b>IF_RECA_MESSAGE_LIST</b>.
    The logic is quite simple. Let's assume a scenario where you have a <b>model instance</b> (containing the business logic -> <b>MVC </b>model). This model instance creates instance of others classes (e.g. for sales orders, etc.). Thus, we have a <b>composition </b>of classes.
    Both the model instance and the others instances (which are customer classes) have a message handler (of TYPE REF TO if_reca_message_list). The message handler is defines as <b>public </b>and <b>read-only</b> instance attribute.
    Following is some sample coding which demonstates the logic:
    " We are here in a method of the model instance. We access the message handler
    " using me->msg_msglist.
    " The model instance has a list of object instance (e.g. me->mt_orders).
    " Before processing these orders the model instance has already added
    " several messages (e.g. for validation) to its message handler.
    " Now the model instance processes the order instances:
      LOOP AT me->mt_orders INTO ls_order.
    "   While creating the order instance they have done themselves some validation
    "   an added the message to their own message handler,
    "   e.g. ls_order-instance->mo_msglist.
    "   Now we add the messages from the order instances to the message handler
    "   of the model instance.
        CALL METHOD me->mo_msglist->add_from_instance( ls_order-instance->mo_msglist).
    "   NOTE: this method has an IMPORTING parameter which allows to add
    "              the messages as subnode
      ENDLOOP.
    Regards
      Uwe

  • Multi-thre​aded error handling method

    I have a multi-threaded application.  When an error occurs in any of the threads which causes the system to fail, all of the threads throw an error and display an error dialog box.  I am thinking about removing the call to the error handler in the secondary threads and instead send the error to the main thread for disposition.  Is that a common design pattern?  Is there a better way to do this?
    Solved!
    Go to Solution.

    kc64 wrote:
    I have a multi-threaded application.  When an error occurs in any of the threads which causes the system to fail, all of the threads throw an error and display an error dialog box.  I am thinking about removing the call to the error handler in the secondary threads and instead send the error to the main thread for disposition.  Is that a common design pattern?  Is there a better way to do this?
    Not as common as it SHOULD be.
    We use an Event Logger that passes all errors to a background process that logs them to file for review later. That is the minimum. If the errors a fatal then we adjust the app design to react accordingly when bad things happen.
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Is this a qucik and satisfactory method for CLD error handling? (see image)

    http://i.imgur.com/IiI8D1w.png
    with reference to: http://i.imgur.com/TyNVWQX.png (from success package document)
    Is this too simple an error handler setup?  Assuming non-catastrophic errors are taken care of before leaving any case in my qsm?  An error is only acceptable during debugging isnt it? (unless instructed by requirements?)  
    I'm trying to think of ways to save some time as I've been working so much I let my test date creep up on me...  
    Thanks
    Solved!
    Go to Solution.

    PatLyons wrote:
    Is this too simple an error handler setup?
    In the real world, yes.  For the CLD, that is a minimum to get the points.  Just throw down the Simple Error Handler to show the error dialog and you have "handled the error".  If the spec does not say how to handle the error, stop the loop(s) and show the error dialog.  If you are given a spec of how to handle the error, do whatever you are told.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • DCErrorHandlerImpl is failing to handle POJO DataControl method exceptions

    Hi All,
    I need a help to understand Adf DCErrorHandlerImpl  and to resolve a particular issue in using it.
    All what I am doing is, extending DCErrorHandlerImpl  class to handle the exceptions in data control and showing a message on the page.
    1) Extended DCErrorHandlerImpl   & overridden reportException method
    2) Extended FacesPageLifecycle to set errorhandler
    3) Created a SitePortalADFPhaseListener class to create page life cycle & configured the life cycle in faces-config.xml
    This works fine in the cases where DataContol methods used as Operation Binding & called from backing bean.
    But when the a method is directly bound to the grid in the UI, reportException() does not handle the error.
    Any idea why handler isn't called in this case?
    Thanks & Regards
    KP

    I followed the steps given in oracle documentation. In the given Sample project, error handler is implemented for AppModule exceptions.
    But what I have is custom Data Control created out of Java class. And it has a method which returns a list.
    public class MyDataControl {
         public MyDataControl() {    
               super();
        public List<MyPojo> getData(){
               try{
                      List<MyPojo> list = new ArrayList<MyPojo>();    
                      list.add(new MyPojo("Name1","25"));
                      list.add(new MyPojo("Name2","30"));
                      return list;    
               } catch (Exception e){
                      e.printStackTrace();    
                     throw new JboException(e);    
    Once I created a DataControl for MyDataControl class, created table by dragging and dropping Data(accessor for getData) from DataControl.
    Now if any exception in getData method, I am throwing a JboException instance.
    According to documentation this exception need to intercepted by reportException() of DCErrorHandlerImpl. But reportException is not called in this case.
    -KP

  • Report and Alert don't executed in the error handler with a JMS proxy service

    Hi,
    I'm working with OSB 11.1.1.4.0 and I'm facing a problem with the error handler of my JMS proxy service.
    My error handler contains two main elements :
    - a Report action
    - an Alert with a JMS destination defined
    When the business service failed the message remain in the queue. It's the expected behavior.
    The problem is :
    - the report is missing
    - the alert is raised but missing in the JMS destination defined in the Alert setting.
    I've noticed if I add a Reply with Failure or Success, Report and Alert are successfully executed.
    Unfortunately the message don't remain in the JMS queue.
    What can I do in order to have my report/alert done and the JMS transaction rollback in order to keep the message in the queue ?
    I've already met this problem in the past with alsb v3 and my solution was to add Service Callout in the error handler in order to externalize these actions.
    This solution is not convenient and I hope another solution is possible.

    Inventorying workgroups can be difficult, especially when it comes to remote access and network security. Because workgroups are not centrally managed, some of the items discussed in this
    wiki article on preparing your workgroup environment may require you to visit each machine individually.
    For non-domain credentials, you do not use the <systemname>\<user> format, you simply enter the user name. Regarding how to enter the credentials, if you have an account that uses the same username and password on all machines and is an administrator
    on all of those machines, then you can enter that in the All computers credentials page of the wizard. You can also do this if they are different user names. However, if some machines have an account with the same user name, such as Administrator,
    but different passwords on each machine, you will need to use the Manually enter computer names discovery method, and then enter the information for each group or each machine.
    As you can tell, workgroup environments can quickly negate any benefit that the agentless inventory nature of MAP provides.
    Please remember to click "Mark as Answer" on the post that helps you, and to click
    "Unmark as Answer" if a marked post does not actually answer your question. Please
    VOTE as HELPFUL if the post helps you. This can be beneficial to other community members reading the thread.

  • Issue with SRDemo error handling

    Hi All,
    Glad the forums are back up and running. In debugging some error-handling issues in our own application, I found an issue in the error handling code of SRDemo. I thought I'd post the issue here, as many of us (myself included) use some SRDemo code as the basis for our own applications.
    The issue can be found in the oracle.srdemo.view.frameworkExt.SRDemoPageLifecycle class, specifically in the translateExceptionToFacesErrors method. I'll show the code that has the issue first, and explain the issue afterwards:
            if (numAttr > 0) {
                Iterator i = attributeErrors.keySet().iterator();
                while (i.hasNext()) {
                    String attrNameKey = (String)i.next();
                     * Only add the error to show to the user if it was related
                     * to a field they can see on the screen. We accomplish this
                     * by checking whether there is a control binding in the current
                     * binding container by the same name as the attribute with
                     * the related exception that was reported.
                    ControlBinding cb =
                        ADFUtils.findControlBinding(bc, attrNameKey);
                    if (cb != null) {
                        String msg = (String)attributeErrors.get(attrNameKey);
                        if (cb instanceof JUCtrlAttrsBinding) {
                            attrNameKey = ((JUCtrlAttrsBinding)cb).getLabel();
                        JSFUtils.addFacesErrorMessage(attrNameKey, msg);
                }Now, this bit of code attempts to be "smart" and only show error messages relating to attributes if those attributes are in fact displayed on the screen. It does so by using a utility method to find a control binding for the attribute name. There are two issues with this code, one obvious, and one that is a bit more subtle.
    The obvious issue: if there is a binding in the page definition, it doesn't necessarily mean that the attribute is shown on the screen. It's a good approximation, but not exact.
    The other issue is more subtle, and led to errors being "eaten," or not shown, in our application. The issue comes if you are using an af:table to display and update your data. In that case, the findControlBinding will not find anything for that attribute, since the attribute is contained within a table binding.
    Just posting this as a word to the wary.
    Best,
    john

    somehow, this message got in the wrong thread....
    Hi Frank,
    Yes, I simply scripted it out this way to contrast the behaviour if the first attribute was read-only vs not read-only. I found the issue on a page in our app that was simply drag-and-drop the VO from the data control on the page.
    It's quite annoying, because our particular use case that hit this error is a "save" button on the page. If the commit operation doesn't return any errors (and it doesn't in this use case!), we add a JSF message saying "save successful" - then the attribute errors are further added later in the page lifecycle, so we get 3 messages: "Save successful" and "Fix this error" and "Tried to set read-only attribute" - quite confusing to the end-user when the only message they should see is "fix this error."
    At any rate, the fix is to simply re-order the attributes in the page definition - that doesn't affect the UI at all, other than to fix this issue.
    John
    it was supposed to be something like:
    Hi Frank,
    Thanks for the reply. I was simply posting this here so that people who use the SRDemo application techniques as a basis for developing the same functionality in their own apps (like me) can be aware of the issue, and avoid lots of head-scratching to figure out "what happened to the error message?"
    John

  • 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.

  • Error Handling in table control for line item.

    Hi,
    Please how to do error handling in table control for line item in bdc,i have used format_message for header but i don't no fill decamps internal tabled and  how to do background processing in call transaction.
    Thanks

    Background processing is not possible using call transaction method.
    You can create an executable program which can have CALL TRANSACTION BDC code. And this can be run in background.
    What do you exactly mean by Error handling for Items in table control. Can you give some more details.

  • Error handling in abap proxy

    Hi,
    In my scenario, I have written code in the execute_synchronous method of the abap proxy in ECC. I want to capture all possible errors that might occur here and for all of them i want to capture the message id and the text and send it out. what kind of possible errors/exceptions can occur and how to handle them. My proxy class simply selects data from multiple tables in ECC and returns the same.
    thks

    Hi,
    for outbound proxies the error handling should be done within R3 itself and there is no need to send errors to XI or receiving system for that matter. You would want someone from R3 side to take a note of it.
    For Inbound proxies, you will have to implement the Fault messages
    Fault message types are designed for application-specific errors that occur on the inbound side and that are reported back to the sender or persisted in monitoring.
    ·        In the synchronous case, when an application-specific error occurs on the inbound side, instead of sending a response message back to the sender, the application can send a fault message to handle the error.
    ·        The fault message of the application for an asynchronous ABAP server proxy is persisted for monitoring. In the case asynchronous of Java server proxies, the fault message is part of a negative application acknowledgement (see Acknowledgments).
    Application-specific means that the application on the inbound side triggers the error itself because, for example, the request message did not contain sufficient information.
    For more information on the same.
    http://help.sap.com/saphelp_nw04s/helpdata/en/dd/b7623c6369f454e10000000a114084/frameset.htm
    In your case, since you said that you are selecting data from some tables, the possibility is that an entry is not found in the DB tables you will have to simply populate the fault message data and raise an expection CX_FM. It also depends on what error handling requirements from the Business .
    regards,
    Advait.

  • What is Considered Best Practice for Error Handling in Components?

    What would be the best approach to handling errors in custom (possibly composite) components?
    I see three different possibilities:
    Having the error handling funciton within the component. The problem is that this is not adaptable to the consumers error handling setup (i.e. logging to database, redirecting to a pretty error screen, etc.).
    Passing in an error function as a parameter. The problem here is how to have the externally defined error function interact with external elements that are not defined within the component, i.e. passing the error or fault object to a logging class, or something similar, of which the component knows nothing about.
    Referencing the external error handling methods directly from within the component. (Of course that's shabby programming, just listing as a technical option.)
    How do you solve this?
    My goal is to have a versatile custom component that can utilize any given consumer's error handler.
    Thanks,
    Mike

    or define a customized event and dispatch it when error occur, then you can just listen to it outside

  • Error Handling in Forms

    Dear all,
    we are using oracle developer suite 10g r2 with oracle database 10g r2 against windows server 2003.
    Error handling is a very big issue.
    i try to do the following, just correct me, or make the trigger more efficient.
    i face unexpected messages, like a message two time displayed, sometime important message never displayed.
    i just set the :system.message_level =20 in the when-new-form-instance trigger.
    and create on-error trigger like below
    declare
    errcode number:=error_code;dbmserrcode number;dbmserrtext varchar2(200);
    formtxt varchar2(200);
    errtype varchar2(3);
    begin
    --------- user defined database exceptions errors raised by --RAISE_APPLICATION_ERROR
    IF DBMS_ERROR_CODE in (-20738,.......) then
    raise form_trigger_failure;
    end if;
    if error_code=50017 then
    message('duration must be between 0 and 23');message(' ',no_acknowledge);
    raise form_trigger_fialure;
    elsif
    error_code=40202 then
    clear_message;
    message('please provide the required fields.');message(' ',no_acknowledge);
    raise form_trigger_fialure;
    elsif error_code=50022 then
    clear_message;
    message('time must be in the correct format.');message(' ',no_acknowledge);
    raise form_trigger_fialure;
    end if;
    if error_code in (40509,40508) then
    dbmserrcode:=dbms_error_code; dbmserrtext:=dbms_error_text;
    if dbmserrcode=-1438 then
    clear_message;
    message('your number is too large.try again.');message(' ',no_acknowledge);
    raise form_trigger_fialure;
    elsif dbmserrcode=-1400 then
    clear_message;
    message('your forgot to provide a value.try again.');message(' ',no_acknowledge);
    raise form_trigger_fialure;
    elsif dbmserrcode=-2291 then
    clear_message;
    message('header is not found for this insertion.');message(' ',no_acknowledge);
    raise form_trigger_fialure;
    elsif dbmserrcode=-1 then
    clear_message;
    message('record already exists');message(' ',no_acknowledge);
    raise form_trigger_fialure;
    else
    clear_message;
    message(error_code||' : '||error_text);message(' ',no_acknowledge);
    raise form_trigger_fialure;
    end if;
    else
    clear_message;
    message(error_code||' : '||error_text);message(' ',no_acknowledge);
    raise form_trigger_fialure;
    end if;
    exception
    when others then
    if dbms_error_code=-20738 then
    clear_message;
    message('Error: absent or later record errror from the database trigger.);
    raise form_trigger_failure;
    elsif .....
    esle
    clear_message;
    message(error_code||' : '||error_text);message(' ',no_acknowledge);
    raise form_trigger_fialure;
    end if;
    end;any suggession?
    Regards

    i must come with a plsql code which handle every error and suppress unnecessary messages.Good luck with that. No matter how well thought out or planned, you're not going to be able to take all scenarios into account. The design of an exception handler takes time to address all possible scenarios you want handled and even then, you're not likely to handle every situation in the beginning.
    could we implement the oracle ebusiness error handling procedures here in our application?if yes, then where could we find that procedure?>
    I've dug through that code and it is not a thorough as you think it is. It handles specific situations and then defaults the rest. It is a good model for your own exception handler, however. That is what I used it for. :) I don't recall which library it is in, but I'll look around and if I find it, I'll post it.
    I agree with Andreas's comment...
    Simply remove your ON-ERROR-trigger, then you have a default. That's nothing better or worse than what apex has.I'm not too familiar with Apex; I've worked with it, but it's been a little while. Even with Apex, you're going to have to develop a customized Exception Handler so more intuitive or application specific messages are displayed in response to an exception.
    As to Andreas's comment...
    For your own error-handling... The "simplest" way in my eyes is create your own error-table where you have appropiate columns for the error-code and the error-type (FRM,ORA,Whatever), then in your ON-ERROR-trigger read the appropiate record from that table and show the error. You could also have a flag in your table which decides what to do with a specific error (Show as Message, Show as Alert, Don't show at all) and react accordingly.This is exactly what we implemented in our application. We created a set of tables that contain all of the Oracle Runtime errors and their attributes (Error Type, Severity Level, etc). Then we wrote a standard On-Error trigger that is subclassed to all of our forms that calls a Library "On_Error" package. This package evaluates the exception raised, compares it to the database entry for the error and then displays an appropriate message depending on the Severity Level, Error Type (ORA or FRM) and Message Type (Informational, Error, Caution) and we display the message in either the Status Bar, Note Alert, Caution Alert or Stop Alert or it is supressed. If an error is not found in the table, then it is displayed in a Stop Alert as an "Unhandled Exception." The second table I mentioned contains all of the messages used by our application and is cross referenced with the table that contains the Oracle messages. By simply assigned one of our messages to an Oracle message - our package will display our message instead of the default Oracle Message. Yes, this took sometime to build and test and once implemented, we spent another couple of months perfecting it, but now it is pretty solid and we haven't had to modify it in over a year.
    While this level of complexity may be overkill for your application, it does offer the greatest flexibility in the long-run. Also, if your application must support multiple languages, having all of your messages in a table make internationalization extremely easy. :)
    The point of all this, is that no matter which system you use (Forms, Apex, or Java) you will still need to invest some time into designing an Excpeiton Handling method for your application and then implement it accross the application. This is not something you can develop in a short period of time and it will not be perfect in the beginning. However, in the long-run, you will be happy you spent the time up-front to build a flexible and robust Exception Handling system.
    Craig...

  • SAP NetWeaver Gateway and JSON Error Handling

    Hello All,
    I am developing a small test application using Netweaver Gateway to understand the error handling.  I am using Postman to test the Gateway service.  I have developed small RFC FM to read return list of deliveries for a shipment.  The RFC reads in a shipment number and returns the list of deliveries.  The RFC also has Return parameter of type BAPIRET2 that stores the error message if shipment is not found.  We want to use only JSON format for the application.  So, I have set the 'Accept' parameter at request header to 'content/json'.  I am also aware of the exception /IWBEP/CX_MGW_BUSI_EXCEPTION that allows to throw an error message from backend suite.  I have that by having a Return parameter of type BAPIRET2, the generated method automatically handles the error message and sets the correct HTTP status.
    Now the Problem:
    As mentioned earlier, we want to use JSON format.  When I set the header parameter or specify $format=json in the URI the HTTP status code is always set to 500 when there is an error.  The error message about invalid shipment also is not returned.
    When I remove the JSON format parameters, the XML format is returned and HTTP status is set to 400 with appropriate error message.
    How can we get the Gateway to set the HTTP status code to 400 along with error message in the event of an error in RFC.  I have tried with the exception /IWBEP/CX_MGW_BUSI_EXCEPTION and BAPIRET2 return parameter but still does not work.  Is this a known issue in Gateway/JSON?
    Please see attached screenshots.
    Thanks,
    Rutul Thakkar

    Anyone have encountered this issue?  Any suggestions?
    Thanks,
    Rutul Thakkar

  • Error handling for importing a file

    Hi, I have only been doing java for 1 semester, and have got terribly stuck on my final assg. I have to import a txt file, and catch any exceptions. I know I am not using the correct method to read the file, but am not sure what the alternatives are. I am getting a compile time..illegal character msg for my Mydata.txt file. Here is my code.
    PS I do have a CatalogueItem class and a bit more to the main class, I have not attached it as I do not want this to be too long.
    /The program reads 10 sets of catalogue data from the Mydata.txt file
    //it prompts the user to use one of the 5 menu options displayed on the screen
    //depending on which option is selected the program displays the data
    //back on the screen.
    import java.awt.*;
    import java.lang.*;
    import java .io.*;
    import java.util.StringTokenizer;
    import java.text.NumberFormat;
    import java.util.Locale;
    //set up a class to call on the constructors from the catalogueitem class
    public class Myassg5
         private static final int MAX = 10; //sets the length to 10(for most exp products)
         private static CatalogueItem[] prodlist; //sets array for product list
         NumberFormat cash = NumberFormat.getCurrencyInstance(new Locale("en","AU"));
         public static void main(String[] args) throws IOException
         CatalogueItem prodlist = new CatalogueItem[10];//sets the length to 10
         {//create Buffered FileStream and initialise to zero
         //use bufferedReader to read in data my Mydata.txt file.
         BufferedReader inFile = null;
         BufferedReader inFile = new BufferedReader(new FileReader(C:\Mydata.txt);
         //print a msg stating the file is loading
         System.out.println("Loading file data from Mydata.txt...10 item(s) OK");
         //initialise the array elments to zero
         for( int a = 0; a < prodlist.length; a++)
         prodlist[a] = 0;
         //if incorrect command lines were passed in display
         //usage msg and quit program
         if(prodlist.length != 1)
              System.out.println("Usage: java assg <Mydata.txt>");
              System.exit(0);
         try
              inFile = new BufferedReader(new FileReader(args[0]));
         //display the error and quit if the file is not found
         catch(FileNotFoundException e)
              System.err.println("File not found--program will terminate");
              System.exit(1);
         //display error msg and quit if there is a problem
         //when opening the file
         catch(IOException e)
              System.err.println("Error opening file--program will terminate")
              System.exit(1);
         //repeat this error handling process as often as neccessary
         boolean go = true;
         while (go)
         //get a line of data from the file
         boolean valid = false;
         CatalogueItem prodlist =-1;
         while(!valid)
         //read the line of text from the file
         String temp = null;
         try
              temp = inFile.readLine();
         //display error msg and quit if there is a problem
         //reading from the file
         catch (IOException e)
              System.err.println("error reading from the file--program will terminate");
         System.exit(1);
         //if the string is null the EOF has been reached
         if(temp ==null)
              valid = true;
              go = false;
         //close the file stream
         try
              inFile.close();
         //display error if there was a problem closing the file
         catch (IOException e)
              System.err.println("error closing data file")
         

    I think the problem is the "\M" in "C:\Mydata.txt". It is trying to make that into an escape character. Use "C:\\Mydata.txt" or "C:/Mydata.txt" instead.
    The logic here is odd. You open a BufferedReader for Mydata.txt, then you trash it without closing it and create another BufferedReader for whatever command line argument the user passes in. Which reader do you want to keep?

  • ADF Mobile Error handling and redirect

    I'm stuck on how to handle errors within my ADF Mobile application. My application consumes a number of web services and we have found we often get error messages when phone connections switch from wifi to 3g or lose connection altogether. These are errors such as SSL handshake failure, HTTP500 errors, and also errors where it can't display the binding eh "Unable to get value for the property due to invalid binding iterator" because a WS call has failed. From the little information I can find - and none of it specific to ADF Mobile, I think I need to write an error handler class which I set against ErrorHandlerClass in databinding.cpx - if that correct? Am I able to catch these errors using that method and if so has anyone got any examples at all. Ideally what I'd like to do when I've caught those errors is redirect to another page (showing something like facebooks app does when it loses a connection and says tap to try again), does anyone have any suggestions or examples?
    thanks
    lynsey

    A sample for ADF Mobile Error Handling.
    SDA013
    Error Handling in ADF Mobile
    https://java.net/projects/smuenchadf/pages/ADFMobile#SDA013

Maybe you are looking for