3 Replies Latest reply on Oct 7, 2014 4:33 AM by Michal Petrov

    Any way to return server side error message to datascroller when page forward clicked?

    Anne Childress Newbie

      I have a datascroller on a page that when clicked, calls a server side action method that does some database work. I have a need to send back an error message if something goes wrong with the database work and a server side exception occurs, thus causing a status 500 to be returned to the ajax call.

       

      Currently I'm doing this on the server side when the exception occurs:

       

      throw new Exception("something bad happened");

      catch (Exception e) {

         FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), e.getMessage()));

      }

       

      Implementing the onError method of XMLHttpRequest to display what is returned as follows does no good, as the message doesn't seem to be coming back in either the message variable, or in the responseText variable of req:

      A4J.AJAX.onError = function(req,status,message) {

           window.alert(req.getResponseText());

            window.alert(req.responseText);

           window.alert(message);

      }

       

      I've also tried droping a <a4j:log/> tag on the page just to see what is returning, but nothing is being displayed.

       

      We are using the 3.3.1 GA release of richfaces currently.

       

      How can I send feedback to the calling page when the datascroller is clicked and it results in a server side exception?