1 Reply Latest reply on Nov 8, 2007 11:11 AM by Pete Muir

    facesMessages and @Redirect question

    John McClain Newbie

      here is my custom exception

      public class FraudException extends Exception {
       public FraudException(){}

      here is my genericErrorPage.xhtml
       id="globalMessages" />

      here is where I throw it:
      private void doQry(String qry) throws FraudException {
       Connection con = null;
       Statement st = null;
       try {
       con = ds.getConnection();
       st = con.createStatement();
       ResultSet rs = st.executeQuery(qry);
       while (rs.next()) {
       caseList.add(new Tblcase(rs.getObject(1), rs.getObject(2), rs
       .getObject(3), rs.getObject(4), rs.getObject(5), rs
       .getObject(6), rs.getObject(7), rs.getObject(8), rs
       .getObject(9), rs.getObject(10), rs.getObject(11), rs
       } catch (Exception e) {
       log.error("ERROR: " + e.getMessage());
       facesMessages.add("ERROR RENDERING DATA: " + e.getMessage());
       throw new FraudException();
       } finally {
       try {
       } catch (Exception e) {
       log.error("ERROR: " + e.getMessage());
       facesMessages.add("ERROR CLOSING CONNECTIONS: " + e.getMessage());
       throw new FraudException();

      Why Does facesMessages get blown away before rendering in the debug page? The result is no error message displaying.

      When I put a hardcoded message in the redirect, the hardcoded message displays, but the message I programmatically added to facesMessages does not display - as follows:
      @Redirect(viewId="/genericErrorPage.xhtml", message="TESTMESSAGE")

      To solve, I tried the following:

      I added this to my session bean
      @Out(Scope = ScopeType.SESSION)

      That did not work - the errmessage still did not display

      I also tried this:
      @Redirect(viewId="/genericErrorPage.xhtml", message="#{errMessage}")

      using an outject errMessage as follows:
      } catch (Exception e) {
       log.error("ERROR: " + e.getMessage());
       //facesMessages.add("ERROR RENDERING DATA: " + e.getMessage());
       errMessage = "ERROR RENDERING DATA: " + e.getMessage();

      - neither works.