0 Replies Latest reply on Apr 17, 2010 2:02 PM by sbhatia

    Associated object modiication flushed with redirect on the current page after runtime exception

    sbhatia
      I am trying to achieve exception handling in my application in which i am throwing a Arithmetic exception in my service layer method.

      I have view userDetails.xhtml  :
      |
      <page| view-id="userDetails.xhtml"
                login-required="true">
      <param name="userId" value""="#{userDTO.user_id_lo}" />
                <action execute="#{userBackingBeanImpl.readUserDetails}"
                     on-postback="false" />
                <begin-conversation join="true" />
                <navigation from-action="#{userBackingBeanImpl.createUserDetails}">
                     <rule if-outcome="success">
                          <redirect />
                     </rule>
                </navigation>
           </page>

      & form is loaded with data from database and after whenever i make some changes on any of the field in the field and click save button backingBean method is called which delegates the call to the service layer method where i am throwing my arithmetic exception before the call reaches to the dao layer(data persistence layer).

      I want the custom message should be displayed on current page.

      entry in pages.xml for exception:

      <exception class="java.lang.ArithmeticException" >
           
        <redirect view-id="#{facesContext.externalContext.requestServletPath}">
                
           <message severity="error">---You have encountered a Exception---</message>
           
        </redirect>
      </exception>

      What i have noticed is that any changes to the associated object is saved to the database and
      messages is displayed as:

      transaction failed
      ---You have encountered a Exception---

      but i dont my data to be saved whenever a exception occur

      Please  help...!!