How to handle exception on a backing bean constructor ?

Hello,
I would like to handle the exceptions throw on the constructor of a backing bean, and redirect the user to a "service not available" page.
When I use "request.sendRedirect()" method to redirect the user to such page, I logically got an "IllegalStateException: Cannot forward a response that is already committed".
Do you have any idea how can I redirect or forward a user to a page when the response is already commited? Is it possible to use servlet filter and do a forward after the doFilter()?
Thank you.

Just throw the exception and map an error page in the web.xml.
<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>error.jsp</location>
</error-page>

Similar Messages

  • How to handle exception thrown in standard bo method in the workflow design

    Hi Experts
        how to handle exception thrown from standard bo method in the workflow design. For example, bo BUS2032, METHOD confirm. If the user cancel it, it will throw exception. In the workflow, how to catch this exception and add corresponding steps in the workflow.

    @jrockman li
    Try to implement the logic that what ever you are performing in the BO mehtod in a FM and in the FM you have tab with name EXECPTIONS define the execption in that tab.Now in the BO method you call this FM  and if the exception occurs by using RAISE you can raise the exception in the FM and based on the number of exceptions your sy-subrc value will be set
    so when sys-subrc is not eq 0 then pass a value back t the workflow container., I think this will work.
    a sample Snippet for understanding purpose
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename         = <path>
        filetype         = 'ASC'
      IMPORTING
        filelength       = lv_len
      TABLES
        data_tab         = l_txt_tab
      EXCEPTIONS
        file_write_error = 1          " If this Exception occurs
        invalid_type     = 2
        no_authority     = 3
        unknown_error    = 4
        OTHERS           = 10.
    CASE sy-subrc.
      WHEN 1. " SY-SUBRC value will be 1 then,
          " Pass or set the value back to the workflow conatiner element
    ENDCASE.

  • How to handle exceptions in web dyn pro

    Hi Frndz....
                     Can any one kindly xplain how to handle exceptions in web dyn pro..like we hav exceptionhandling in java ....so is there any for NWDS
    THANKS & REGARDS
    Rajesh

    Hi,
    Web Dynpro Java is basically java only.i.e You program in java. Hence exceptions are supported in the same way as in java i.e. via try,catch and finally block.
    Additionally,
    In 04/04s if you create a method in any controller in web dynpro you cann't specify exception that can be thrown in the method. This is now possible in new programming web dynpro model in CE.
    Hence when creating a method you can also specify custom or core java (lib)excetions.
    Regards,
    Ashwani Kr Sharma

  • How RMI handle exception in RMI kernel ?

    hi everyone.
    How RMI handle exception in RMI kernel ?
    That is , when RMI catch an exception ,
    what RMI should do to handle the exception?
    best regards.

    it throws an exception (some derived class of RemoteException) which is transmitted to, rethrown at, and must be caught at, the client.

  • How to decide when to keep backing bean in request and session.Pros/cons

    How to decide when to keep backing bean in request and session.Pros/cons

    Depends on where the bean data must be available. Start with request scope. If you need the data in session scope, then think twice about impacts (memory usage, multiple browser tabs, etc) unless the data is obviously targeted on the session scope (loggedin user, user settings, dropdown data, etc).

  • How to handle Valuechange events, when page bean is in request scope

    Hello balusc and forum mates,
    I want to know is there any good way to handle ValueChangeEvents events, when the page's bean in request scope.
    My problem is, I have a page having more than 1 value change event so How can I maintain page values at backing bean. My bean is request scope, I can't change to session scope.
    Please I really need it.

    Hi Frank...
    In my code i used almost same logic as Andrejus Baranovskis has explained in his Editable Table example...
    You can refer that example to see what problem I'm facing...
    http://andrejusb.blogspot.com/2007/04/create-edit-and-delete-operations-in.html
    The Bean Scope in this Example is Session scope...Save button is working fine...
    But as i Change the bean scope to Request scope then Save button is not working for Edit but it is working for Delete Action very well..
    I want that save button should work also for Edit action in Request Scope..
    Please Make me understand that why it is happened like that..
    and help me to find the solution..
    and Also if you have a better document to Explain the life cycle of Application in Different Bean Scope...So please provide me that Doc to me...
    It would be a great help for me to understand the concept of session...
    Thanks Frank
    Fizzz...

  • H:inputText ; How To initialize value Property from back/bean method?

    Hello Guys at Sun Forums.
    I am a newbie at using JSF. and I'm having a bit of a Problem.
    I don't know how to initialize the value property of a h:inputText from a method inside a backing bean that returns a String data type.
    My Method inside the Backing bean is this:
    public String getLastDate()
            Connection con = null;
            Statement stmt = null;
            ResultSet rs = null;
            Date DateCapt = null;
            String DateConv= null;
            try{
                Class.forName("com.sybase.jdbc2.jdbc.SybDrive").newInstance();
                con = DriverManager.getConnection("jdbc:sybase:Tds:localhost/BAN_PRO_SNP", "xxxx", "xxxx");
                if(!con.isClosed()){
                    stmt = con.createStatement();
                    stmt.executeQuery ("SELECT TOP 1 CONVERT(VARCHAR(10), fec_parametro, 103) fec_parametro FROM snp_sei_parametros" +
                    "     WHERE cod_parametro = 'FECHA'" +
                    "     ORDER BY fec_parametro DESC");
                    rs = stmt.getResultSet();
                    while (rs.next())
                                DateCapt = rs.getDate("fec_parametro");
                rs.close();  
                stmt.close(); 
            catch (Exception ex)
                        System.out.println("COULD NOT LOAD THE DRIVER!!!!");
                        System.out.println(ex);
                    DateConv = String.valueOf(DateCapt).toString();
        return DateConv;
    }As you can see the Method returns a String data type, and all I want to know is how put that returned String as the initial value of a h:inputText. when the jsf-jsp page loads.
    Please Help Me.

    You should be able to do
       <h:inputText value="#{bean.lastDate}"/>Where 'bean' is the managed bean name containing
    the method getLastDate().
    When the view is rendered, the getter (getLastDate())
    will be called to display whatever value is returned.

  • Some basic questions how to handle Exceptions with good style

    Ok I have two really basic Exception questions at once:
    1. Until now I always threw all exceptions back all the way to my main method and it always worked well for me but now I am sitting at a big project where this method would explode the programm with throwings of very many exceptions in very many methods. So I would like to know if there is a more elegant solution.
    2. What do I do with exceptions that will never occur?
    Lets say I have a method like this:
    void main() {calculate();}
    void calculate()
    sum(3,5);
    void sum(int a,int b)
    MathematicsA.initialise("SUM"); // throws AlgorithmNotFoundException, will never occur but has to be handled
    }So what is the most elegant way?:
    h4. 1. Ignore because it will not happen
    void sum(int a,int b)
    try {MathematicsA.initialise("SUM");}
    catch(AlgorithmNotFoundException) {}
    }h4. 2. Print stacktrace and exit
    void sum(int a,int b)
    try {MathematicsA.initialise("SUM");}
    catch(AlgorithmNotFoundException e)
    e.printStackTrace();
    System.exit();
    }h4. 3. throw it everywhere
    void main() throws AlgorithmNotFoundException, throws ThousandsOfOtherExceptions  {}
    void calculate()  throws AlgorithmNotFoundException, throws HundretsOfOtherExceptions
    sum(3,5);
    void sum(int a,int b) throws AlgorithmNotFoundException
    MathematicsA.initialise("SUM");
    }h4. 4. Create special exceptions for every stage
    void main() throws MainParametersWrongException
    try {calculate();}
    catch(Exception e)
      throw new MainParametersWrongException();
    void calculate()  throws SumInternalErrorException
    try {sum(3,5);}
    catch (SumInternalErrorException)    {throw new CalculateException();}
    void sum(int a,int b) throws SumInternalErrorException
    try
    MathematicsA.initialise("SUM");
    } catch (AlgorithmNotFoundException e) {
    throw new SumInternalErrorException();
    }P.S.: Another problem for me is when a method called in a constructor causes an Exception. I don't want to do try/catch everytime I instantiate an object..
    Example:
    public class MySummation()
         Mathematics mathematics;
         public MySummation()
                 mathematics.initialise("SUM"); // throws AlgorithmNotFoundException
         void sum(int x,int y)
              return mathematics.doIt(x,y);
    }(sorry for editing all the time, I was not really sure what I really wanted to ask until i realised that I had in fact 2 questions at the same time, and still it is hard to explain what I really want to say with it but now the post is relatively final and I will only add small things)
    Edited by: kirdie on Jul 7, 2008 2:21 AM
    Edited by: kirdie on Jul 7, 2008 2:25 AM
    Edited by: kirdie on Jul 7, 2008 2:33 AM
    Edited by: kirdie on Jul 7, 2008 2:34 AM

    sphinks wrote:
    I`m not a guru, but give my point of view. First of all, the first way is rude. You shouldn`t use try with empty catch. "rude" isn't the word I'd use to describe it. Think about what happens if an exception is thrown. How will you know? Your app fails, and you have NO indication as to why. "stupid" or "suicidal" are better descriptions.
    Then for the second way, I`ll reccomend for you use not printStackTrace(); , but use special method for it:
    public void outputError (Exception e) {
    e.printStackTrace();
    }It`ll be better just because if in future you`d like to output error message instead of stack of print it on GUI, you`ll need change only one method, but not all 'try' 'catch' statements for changing e.printStackTrace(); with the call of new output method.I disagree with this. Far be it from me to argue against the DRY principle, but I wouldn't code it this way.
    I would not recommend exiting from a catch block like that. It's not a strategy for recovery. Just throw the exception.
    Then, the third way also good, but I suppose you should use throws only if the caller method should know that called method have a problem (for example, when you read parametrs from gui, so if params are inccorect, main method of programm should know about it and for example show alert window)."throw it everywhere"? No, throw it until you get to an appropriate handler.
    If you're writing layered applications - and you should be - you want to identify the layer that will handle the exception. For example, if I'm writing a web app with a view layer, a service layer, and a persistence layer, and there's a problem in the persistence tier, I'd let the service layer know what the persistence exception was. The service layer might translate that into some other exception with some business meaning. The view layer would translate the business exception into something that would be actionable by the user.
    And in all other cases I suppose you should use the fourth way. So I suppose it`s better to combine 2,3,4 ways as I have mentioned above.I don't know that I'd recommend special exceptions for every layer. I'd reuse existing classes where I could (e.g., IllegalArgumentException)
    Sorry, I can give you advice how to avoid problem with try-catch in constructor. :-(You shouldn't catch anything that you can't handle. If an exception occurs in a constructor that will compromise the object you're trying to create, by all means just throw the exception. No try/catch needed.
    You sound like you're looking for a single cookie cutter approach. I'd recommend thinking instead.
    %

  • How to handle exceptions

    we atarting new project first module.front end java back end oracle.
    when we are writing procedures and functions in backend when errors and exceptions are raised we insert that values into error log table which contains all eroor and exception messages.
    but when we run actual application front end people has to know which error is occured in back end .how to handle to display theese errors into front end people

    yinghan wrote:
    you can add an out parameter to the procedure, output the error message by the out parameter, then JAVA can get the erro message.This is about the worst thing you could do. Better would be not to handle the exception at all.
    Also the op might consider googleing for the log4plsql package which does something similiar as the popular log4j routine.
    There seems also a beta version available for 10g that uses DBMS_UTILITY.FORMAT_ERROR_BACKTRACE/FORMAT_ERROR_STACK.
    Edited by: Sven W. on Oct 22, 2008 2:31 PM
    Edited by: Sven W. on Oct 22, 2008 2:31 PM

  • How to handle exception CX_SY_REF_IS_INITIAL

    hi experts,
    im working on a test scenario for abap mapping in SAP XI im getting this error
    An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause Dereferencing of the NULL reference
    i understand that i need to catch this exception in the abap coding but i'm not familiar with oops concepts
    can any one please suggest me how to handle this exception for the following code...
    method IF_MAPPING~EXECUTE.
      break x1149.
    * initialize iXML
      TYPE-POOLS: ixml.
      class cl_ixml definition load.
    ** Instances & Variable declaration =======================
    * instance main factory
      TYPES: BEGIN OF t_xml_line,
              data(256) TYPE x,
            END OF t_xml_line.
      DATA: l_ixml TYPE REF TO if_ixml,
    * instance input stream factory
       l_streamfactory TYPE REF TO if_ixml_stream_factory,
    * instance input stream
      l_istream  TYPE REF TO if_ixml_istream,
    * instance input document
      l_document TYPE REF TO if_ixml_document,
    * instance parse input document
      l_parser TYPE REF TO if_ixml_parser,
    * instance for elements within the nodes
      node      TYPE REF TO if_ixml_node,
    *instance of nodemap
      nodemap   TYPE REF TO if_ixml_named_node_map,
    * instance for iterator
      iterator  TYPE REF TO if_ixml_node_iterator,
      name      TYPE string,
      value     TYPE string,
    * instance main factory
       o_ixml   TYPE REF TO if_ixml,
    * instance output document
       o_document TYPE REF TO if_ixml_document,
    * instance output stream
      o_istream  TYPE REF TO if_ixml_ostream,
    * instance parse output document
      o_parser  TYPE REF TO if_ixml_parser,
    * instance fot renderer
      renderer type ref to if_ixml_renderer,
      irc type i,
      l_xml_size   TYPE i,
    *ROOT ELEMENT
    l_element_MT_DEMANDTEC_COST TYPE REF TO if_ixml_element,
    *NEXT CHILD ELEMENT FROM THE ABOVE PARENT
    l_element_DT_DEMANDTEC TYPE REF TO if_ixml_element,
    *CHILDREN1 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_WHSE  TYPE REF TO if_ixml_element,
    *CHILDREN2 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_DC    TYPE REF TO if_ixml_element,
    *CHILDREN3 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_PLANT    TYPE REF TO if_ixml_element,
    *CHILDREN4 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_QTY    TYPE REF TO if_ixml_element.
    *saving the xml document
      DATA: l_xml_table       TYPE TABLE OF t_xml_line.
      types: begin of t_source,
              whse(5),
              dc(4) ,
              plant(4),
              qty    type i,
             end of t_source.
      types: tt_source TYPE STANDARD TABLE OF t_source.
      data:  wa_source type t_source.
      data: it_source TYPE  tt_source,
            ivalue type string.
    * Procedures and business logic =======================================
    *   Creating the main iXML factory
      l_ixml = cl_ixml=>create( ).
    *   Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
    * create input stream
      l_istream = l_streamfactory->create_istream_xstring( source ).
    *  initialize input document
      l_document = l_ixml->create_document( ).
    *  Create a Parser
      l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
    * parse input document
      l_parser->parse( ).
    *   Validate a document
      l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
    *   Parse the stream
      IF l_parser->parse( ) NE 0.
        IF l_parser->num_errors( ) NE 0.
          DATA: parseerror TYPE REF TO if_ixml_parse_error,
                str        TYPE string,
                i          TYPE i,
                count      TYPE i,
                index      TYPE i.
          count = l_parser->num_errors( ).
          WRITE: count, ' parse errors have occured:'.
          index = 0.
          WHILE index < count.
            parseerror = l_parser->get_error( index = index ).
            i = parseerror->get_line( ).
            WRITE: 'line: ', i.
            i = parseerror->get_column( ).
            WRITE: 'column: ', i.
            str = parseerror->get_reason( ).
            WRITE: str.
            index = index + 1.
          ENDWHILE.
        ENDIF.
      ENDIF.
    *   Process the document
      IF l_parser->is_dom_generating( ) EQ 'X'.
        refresh : it_source.
        node ?= l_document.
        CHECK NOT node IS INITIAL.
    *   create a node iterator
        iterator  = node->create_iterator( ).
    *   get current node
        node = iterator->get_next( ).
    *   loop over all nodes
        WHILE NOT node IS INITIAL.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
    *         element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
            WHEN if_ixml_node=>co_node_text.
    *         text node
              value  = node->get_value( ).
              if name eq 'DT_WHSE'.
                wa_source-whse = value.
              ELSEIF name eq 'DT_DC'.
                wa_source-DC = value.
              ELSEIF name eq 'DT_PLANT'.
                wa_source-PLANT = value.
              ELSEIF name eq 'DT_QTY'.
                wa_source-QTY = value.
                COLLECT wa_source INto it_source.
                CLEAR   wa_source.
              ENDIF.
          endcase.
          node = iterator->get_next( ).
        endwhile.
      ENDIF.
      loop at it_source into wa_source .
        at first.
    *       Creating a ixml factory
          o_ixml = cl_ixml=>create( ).
    *       Creating the dom object model
          o_document = l_ixml->create_document( ).
        endat.
    *       Build and Fill  root node MT_DEMANDTEC_COST
        AT FIRST.
          l_element_MT_DEMANDTEC_COST    =
    O_document->create_simple_element(
                                  name   = 'MT_DEMANDTEC_COST'
                                  parent = o_document ).
        ENDAT.
    *      Build and Fill  Child node DT_DEMANDTEC for parent
    *                                                  MT_DEMANDTEC_COST
        l_element_DT_DEMANDTEC    = O_document->create_simple_element(
                                     name   = 'DT_DEMANDTEC'
                                     parent = l_element_MT_DEMANDTEC_COST ).
    *      Build and Fill  Child node1 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-WHSE.
        l_element_DT_WHSE    = O_document->create_simple_element(
                                         name   = 'DT_WHSE'
                                         VALUE  = ivalue
                                         parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node2 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-DC.
        l_element_DT_DC   = O_document->create_simple_element(
                                             name   = 'DT_DC'
                                              VALUE  = ivalue
                                    parent = l_element_DT_DEMANDTEC ).
    *      Build and Fill  Child node3 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-PLANT.
        l_element_DT_PLANT   = O_document->create_simple_element(
                                                 name   = 'DT_PLANT'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node4 DT_QTY for parent DT_DEMANDTEC
        ivalue              = wa_source-QTY.
        l_element_DT_QTY     = O_document->create_simple_element(
                                                 name   = 'DT_QTY'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
      endloop.
    * render document ======================================================
    * create output stream
      o_istream  = l_streamfactory->create_ostream_xstring( result ).
    *   Connect internal XML table to stream factory
      o_istream  = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      renderer = o_ixml->create_renderer( ostream = o_istream
                                              document = o_document ).
      irc = renderer->render( ).
    * how do i catch the exception for type CX_SY_REF_IS_INITIAL ...?
    endmethod.
    full reward points for answers.
    Thanks & Regards,
    Uday Kumar.
    Edited by: UDAY on May 6, 2008 9:32 PM

    Hi Uday,
    Its occurs because you're trying to access a objects with null reference. Or you forgot to create an instance or an error occurs during the instance creation. So You should put all your "Procedures and business logic" inside a Try/catch block. as follow.
    " Define a class exception object to get error message......
    DATA o_exception TYPE REF TO cx_sy_ref_is_initial.
    "// Use the statment Try block to catch the error.
    TRY.
    *   Creating the main iXML factory
      l_ixml = cl_ixml=>create( ).
    *   Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
    * create input stream
      l_istream = l_streamfactory->create_istream_xstring( source ).
    *  initialize input document
      l_document = l_ixml->create_document( ).
    *  Create a Parser
      l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
    * parse input document
      l_parser->parse( ).
    *   Validate a document
      l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
    *   Parse the stream
      IF l_parser->parse( ) NE 0.
        IF l_parser->num_errors( ) NE 0.
          DATA: parseerror TYPE REF TO if_ixml_parse_error,
                str        TYPE string,
                i          TYPE i,
                count      TYPE i,
                index      TYPE i.
          count = l_parser->num_errors( ).
          WRITE: count, ' parse errors have occured:'.
          index = 0.
          WHILE index < count.
            parseerror = l_parser->get_error( index = index ).
            i = parseerror->get_line( ).
            WRITE: 'line: ', i.
            i = parseerror->get_column( ).
            WRITE: 'column: ', i.
            str = parseerror->get_reason( ).
            WRITE: str.
            index = index + 1.
          ENDWHILE.
        ENDIF.
      ENDIF.
    *   Process the document
      IF l_parser->is_dom_generating( ) EQ 'X'.
        refresh : it_source.
        node ?= l_document.
        CHECK NOT node IS INITIAL.
    *   create a node iterator
        iterator  = node->create_iterator( ).
    *   get current node
        node = iterator->get_next( ).
    *   loop over all nodes
        WHILE NOT node IS INITIAL.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
    *         element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
            WHEN if_ixml_node=>co_node_text.
    *         text node
              value  = node->get_value( ).
              if name eq 'DT_WHSE'.
                wa_source-whse = value.
              ELSEIF name eq 'DT_DC'.
                wa_source-DC = value.
              ELSEIF name eq 'DT_PLANT'.
                wa_source-PLANT = value.
              ELSEIF name eq 'DT_QTY'.
                wa_source-QTY = value.
                COLLECT wa_source INto it_source.
                CLEAR   wa_source.
              ENDIF.
          endcase.
          node = iterator->get_next( ).
        endwhile.
      ENDIF.
      loop at it_source into wa_source .
        at first.
    *       Creating a ixml factory
          o_ixml = cl_ixml=>create( ).
    *       Creating the dom object model
          o_document = l_ixml->create_document( ).
        endat.
    *       Build and Fill  root node MT_DEMANDTEC_COST
        AT FIRST.
          l_element_MT_DEMANDTEC_COST    =
    O_document->create_simple_element(
                                  name   = 'MT_DEMANDTEC_COST'
                                  parent = o_document ).
        ENDAT.
    *      Build and Fill  Child node DT_DEMANDTEC for parent
    *                                                  MT_DEMANDTEC_COST
        l_element_DT_DEMANDTEC    = O_document->create_simple_element(
                                     name   = 'DT_DEMANDTEC'
                                     parent = l_element_MT_DEMANDTEC_COST ).
    *      Build and Fill  Child node1 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-WHSE.
        l_element_DT_WHSE    = O_document->create_simple_element(
                                         name   = 'DT_WHSE'
                                         VALUE  = ivalue
                                         parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node2 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-DC.
        l_element_DT_DC   = O_document->create_simple_element(
                                             name   = 'DT_DC'
                                              VALUE  = ivalue
                                    parent = l_element_DT_DEMANDTEC ).
    *      Build and Fill  Child node3 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-PLANT.
        l_element_DT_PLANT   = O_document->create_simple_element(
                                                 name   = 'DT_PLANT'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node4 DT_QTY for parent DT_DEMANDTEC
        ivalue              = wa_source-QTY.
        l_element_DT_QTY     = O_document->create_simple_element(
                                                 name   = 'DT_QTY'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
      endloop.
    * render document ======================================================
    * create output stream
      o_istream  = l_streamfactory->create_ostream_xstring( result ).
    *   Connect internal XML table to stream factory
      o_istream  = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      renderer = o_ixml->create_renderer( ostream = o_istream
                                              document = o_document ).
      irc = renderer->render( ).
    "   The Statement CATCH define a block that catches the exceptions of the
    "   exception class cx_sy_ref_is_initial
        CATCH cx_sy_ref_is_initial INTO o_exception.
    " If you need to get the error message text do as follow
    DATA errorMsg type string.
    " Get the message text
      errorMsg = o_exception->GET_TEXT( ).
    " Display the error information
      MESSAGE errorMsg TYPE 'I'.
      ENDTRY.
    The TRY block defines a guarded area whose class-based exceptions can be caught in the subsequent CATCH blocks. If no exception occurs in the TRY block and it reaches its end, the system continues the processing after ENDTRY. If a class-based exception occurs in the TRY block, the system searches for an exception handler in the same or an external TRY control structure.
    Font: SAP Help
    You can see a how to create and use an exception in this example [ ABAP Objects - Defining a Class-based exceptions|https://wiki.sdn.sap.com/wiki/x/19w] .
    Best Regards.
    Marcelo Ramos

  • How i can display data from backing bean from jsf adf page

    Hi all
    I am creating a adf bc jsf application i am referring hr schema employee table
    in my jsf page i have a inputtext with label employee number if i enter employee number and press tab i should get employee name and jobid and salary for this purpose i am doing like as follows
    my view object query is as follows
    SELECT EMPLOYEE_ID,FIRST_NAME,JOB_ID,SALARY
    FROM EMPLOYEES
    WHERE EMPLOYEE_ID=:EMP_NO
    and my backing bean for my jsf page is as follows
    package view.backing;
    import javax.faces.component.html.HtmlForm;
    import javax.faces.event.ValueChangeEvent;
    import oracle.adf.view.faces.component.core.input.CoreInputText;
    import oracle.adf.view.faces.component.core.output.CoreOutputText;
    import oracle.adf.view.faces.component.html.HtmlBody;
    import oracle.adf.view.faces.component.html.HtmlHead;
    import oracle.adf.view.faces.component.html.HtmlHtml;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.Row;
    import oracle.jbo.ViewObject;
    import oracle.jbo.client.Configuration;
    public class BindTest3
    private HtmlHtml html1;
    private HtmlHead head1;
    private HtmlBody body1;
    private HtmlForm testForm;
    private CoreInputText employeeId;
    private CoreOutputText firstName;
    private CoreOutputText jobId;
    private CoreOutputText salary;
    public void setHtml1(HtmlHtml html1)
    this.html1 = html1;
    public HtmlHtml getHtml1()
    return html1;
    public void setHead1(HtmlHead head1)
    this.head1 = head1;
    public HtmlHead getHead1()
    return head1;
    public void setBody1(HtmlBody body1)
    this.body1 = body1;
    public HtmlBody getBody1()
    return body1;
    public void setTestForm(HtmlForm form1)
    this.testForm = form1;
    public HtmlForm getTestForm()
    return testForm;
    public void setEmployeeId(CoreInputText inputText1)
    this.employeeId = inputText1;
    public CoreInputText getEmployeeId()
    return employeeId;
    public void changeMethod(ValueChangeEvent event)
    String EmployeeId=(String)event.getNewValue();
    CheckForBind check=new CheckForBind();
    System.out.println(check.getEmployeeNo());
    String amDef = "model.AppModule";
    String config = "AppModuleLocal";
    ApplicationModule am =
    Configuration.createRootApplicationModule(amDef,config);
    ViewObject vo = am.findViewObject("EmployeeBindViewObj1");
    vo.setNamedWhereClauseParam("EMP_NO",EmployeeId);
    System.out.println("Query will return "+
    vo.getEstimatedRowCount()+" rows...");
    vo.executeQuery();
    while (vo.hasNext()) {
    Row curUser = vo.next();
    System.out.println(vo.getCurrentRowIndex()+" "+
    curUser.getAttribute("EmployeeId")+" "+
    curUser.getAttribute("FirstName")+" " curUser.getAttribute("JobId")" "+curUser.getAttribute("Salary"));
    //firstName =(String)curUser.getAttribute("EmployeeId");
    //setFirstName(curUser.getAttribute("EmployeeId"));
    firstName.setValue((String)curUser.getAttribute("FirstName"));
    //jobId.setValue((CoreOutputText) curUser.getAttribute("FirstName"));
    // salary.setValue((CoreOutputText)curUser.getAttribute("Salary"));
    // values.setJobId((CoreOutputText)curUser.getAttribute("JobId"));
    // values.setFirstName((CoreOutputText) curUser.getAttribute("FirstName"));
    //values.setSalary((CoreOutputText)curUser.getAttribute("Salary"));
    Configuration.releaseRootApplicationModule(am,true);
    public void setFirstName(CoreOutputText outputText1)
    this.firstName = outputText1;
    public CoreOutputText getFirstName()
    return firstName;
    public void setJobId(CoreOutputText outputText2)
    this.jobId = outputText2;
    public CoreOutputText getJobId()
    return jobId;
    public void setSalary(CoreOutputText outputText3)
    this.salary = outputText3;
    public CoreOutputText getSalary()
    return salary;
    and my jsf page is as follows
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
    <f:view>
    <afh:html binding="#{backing_BindTest3.html1}" id="html1">
    <afh:head title="Home" binding="#{backing_BindTest2.head1}" id="head1">
    <meta http-equiv="Content-Type"
    content="text/html; charset=windows-1252"/>
    <style type="text/css">
    body {
    background-color: #f7f7f7;
    </style>
    </afh:head>
    <afh:body binding="#{backing_BindTest3.body1}" id="body1">
    <h:form binding="#{backing_BindTest3.testForm}" id="testForm">
    <af:inputText label="Employee No" binding="#{backing_BindTest3.employeeId}"
    id="employeeId" valueChangeListener="#{backing_BindTest3.changeMethod}" autoSubmit="true"/>
    <af:outputText value="#{backing_BindTest3.firstName.value}"
    binding="#{backing_BindTest3.firstName}"
    id="firstName"/>
    <af:outputText value="outputText2"
    binding="#{backing_BindTest3.jobId}"
    id="jobId"/>
    <af:outputText value="outputText3"
    binding="#{backing_BindTest3.salary}"
    id="salary"/>
    </h:form>
    </afh:body>
    </afh:html>
    </f:view>
    <%-- oracle-jdev-comment:auto-binding-backing-bean-name:backing_BindTest2--%>
    but i am getting result in console but i cant get the value of firstname into my jsf page
    can any one can tell me for get the value to jsf page what i can do
    and what are the changes i can do in my jsf page

    hi,
    i tried to set value like as follows
    name=(CoreOutputText)curUser.getAttribute("FirstName");
    but that time i getting exception like as follows
    ec 22, 2007 2:17:27 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
    SEVERE: java.lang.ClassCastException: java.lang.String
    javax.faces.el.EvaluationException: java.lang.ClassCastException: java.lang.String
         at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:150)
         at oracle.adf.view.faces.component.UIXComponentBase.__broadcast(UIXComponentBase.java:1087)
         at oracle.adf.view.faces.component.UIXEditableValue.broadcast(UIXEditableValue.java:247)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:269)
         at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:363)
         at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:98)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:123)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:162)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.ClassCastException: java.lang.String
         at view.backing.ChangeValue.changeMethod(ChangeValue.java:49)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
    What will be the resion please help it is very critical for me

  • How to handle exceptions of rfc in web dydnpro

    hi all,
    i want to handle exceptions of Remote function module in webdynpro.how can we do that one.are there any variables in model class for those exceptions.
    regards
    Naidu

    Hi,
    Hope the following snippet answers ur query
    IWDMessageManager manager = wdComponentAPI.getMessageManager();
                   try{
                        wdContext.currentB_Quotation_Createfromdata_InpElement().modelObject().execute();
                        wdContext.nodeOutputQuotation().invalidate();
                   } catch(WDDynamicRFCExecuteException ce) {
                        manager.reportException(ce.getMessage(), false);

  • How to handle exceptions thrown by event

    Hi all,
    i have this slight problem, i'm trying to handle accessing a databse from a button click, i'm trying to simulate somebody logging on to a network. the code is as follows;
    *@author James Taylor
    *@version 30-11-2003
    *Logon gui
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    public class LogonUI extends JFrame {
         //instance variables
         private JLabel userNameL;
         private JPasswordField password;
         private JButton logon;
         ButtonHandler handler;
         Connection con;
         Statement stmt;
          *Constructor initialises and creates UI, adds functionality to the button.
         public LogonUI() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              super("Employee Logon");
              Container c = getContentPane();
              c.setLayout(new FlowLayout() );
              //handles what happens when user presses the button
               handler = new ButtonHandler();
              userNameL = new JLabel("Please Enter Password:");
              c.add(userNameL);
              password = new JPasswordField(15);
              c.add(password);
              logon = new JButton( "Logon" );
              //anonymous inner class that is created once the button is pressed.
              //it connects to database to validate user
              logon.addActionListener( handler );
              c.add(logon);
              c.setBackground( Color.pink );
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              setSize(250,150);
              setVisible(true);
          *class that opens connection to validate user
         private class ButtonHandler implements ActionListener {
              public void actionPerformed(ActionEvent ae)throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
                   try{
                        boolean isValidUser = false;
                        //Load mysql driver
                         Class.forName("com.mysql.jdbc.Driver").newInstance();
                         //make a connection
                        String url = "jdbc:mysql://localhost/flight";
                        con = DriverManager.getConnection(url)
                        //Create and instantiate a statement obj
                        stmt = con.createStatement();
                        //get a result set
                        ResultSet rs = stmt.executeQuery("SELECT Password FROM employees");
                        //Iterate through the result set
                        while ( rs.next() ){     
                             String savedPassword = rs.getString("Password");
                             if (password.getText().equals(savedPassword) ){
                                  isValidUser = true;
                                  JOptionPane.showMessageDialog(null,"Yipeeeee");
                        if (isValidUser == false){
                             JOptionPane.showMessageDialog(null,"Invalid Password");     
                        stmt.close();
                        con.close();
                   }catch(Exception e){ e.printStackTrace();}
              public static void main (String[] args) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              LogonUI testAirApp = new LogonUI();
    }When the user presses the button the app tries to validate the user.
    I have not been able to test the code due to SQL Exceptions thrown in the handler class, and when i try and throw them up from here i get;
    LogonUI.java:52: actionPerformed(java.awt.event.ActionEvent) in LogonUI.ButtonHandler cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; overridden method does not throw java.lang.InstantiationExceptionAny ideas on my code and how to handle these exceptions will be very appreciated. Regards, James

    Turn your checked exceptions into unchecked exceptions and retrieve the cause later:
    RuntimeException unchecked = new RuntimeException(checked);
    Throwable t = unchecked.getCause();Stephen

  • How to handle exception

    I have catch some exception ,but i don't know how to handle them. I means that if a caller call my method, the caller how to know exception .
    This is my codes:
    public byte[] encrypt(String algth,byte[] obj,Key key){
         byte[] data=null;
         try{
         Cipher cipher = Cipher.getInstance(algth);//encrypted secretkey
         cipher.init(Cipher.ENCRYPT_MODE,key);
         data=cipher.doFinal(obj);
    }catch(NoSuchAlgorithmException e){
    }catch (NoSuchPaddingException e) {
    }catch(InvalidKeyException e){
    }catch(IllegalBlockSizeException e){
    }catch(BadPaddingException e){
    return data;
    Can you tell me how to handle NoSuchAlgorithmException ,NoSuchPaddingException,InvalidKeyException and so on

    you dont. you're stuffed. If there's 'NoSuchPadding' or NoSuchAlgorithm, or the encryption fails (the other 3), nothing you can do at that point will change that fact.
    2 options.
    return null, and check the return value every time you call the function
    throw an exception, either the exception caught, or one of your own design with information pertinent to your application.

  • How to init an application scope backing bean once app server startup?

    Hi guys,
    I got an application scope backing bean but I don't know how to initialize it once the app server startup ! I need all the webpage to be able to get the 'defaultCountry' value once the app server startup !
    <managed-bean>
    <managed-bean-name>applicationScopeBean</managed-bean-name>
    <managed-bean-class>com.borneo.webapp.action.ApplicationScopeBean</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
    <managed-property>
    <property-name>defaultCountry</property-name>
                   <property-class>java.lang.String</property-class>
    <value>Singapore</value>
    </managed-property>
    </managed-bean>
    Pls help, Thanks !
    regards,
    Mark

    write a context listener and set up your web.xml as such
    <listener>
    <listener-class>com.package.ContextListener</listener-class>
    </listener>
    Then your class should inmplement ServletContextListener interface.
    The 2 methods need to be implemented
    public void contextDestroyed(ServletContextEvent sc_event) { }
    public void contextInitialized(ServletContextEvent sc_event) { }
    Hope that helps

Maybe you are looking for

  • Firmware upgrade in place?

    I updated my G5 to Panther, 10.3.9, and I have downloaded the firmware upgrade for my early 2004 G5(the DDR RAM G5, not the DDR2). Now when I go to update, I press the shut down button and it shuts down. Fine. Then I press the start button, and wait

  • I restored my phone and now on iTunes it won't let me put anything back on the phone and where it says iPhone there is nothing there

    I just updated my iPhone to the 5 iOS and everything seemed to be ok i still have my contacts but when I plug in to iTunes the page which normally had all the info for the phone is blocked and nothing comes up and I can't put my music back on it or m

  • Problems With The  eGatetutorial Java Caps

    Hello i'm learning to use Java caps and i use the tutorial but when i create my project all run but my output data has don't created i put the directoy where is my xml file c:\eGate\Project3\*.xml this is in the input file and the output file i can't

  • Laptop won't turn on!!! why?

    Here we go again!!   Gateway laptop, 6 months old... was a trade because they had to " JUNK" my other one that was only 8 months old!  gosh! WELL ... I closed the laptop this afternoon, unplugged it... put it in the other room until dinner was done. 

  • Keyboard problem after cleaning

    I decided to clean my aluminium keyboard yesterday, and some of the keys have since stopped working. Several keys are also typing by themselves (if that makes sense). Can anything be done, or do I have to fork out for a new keyboard?