Results 1 to 3 of 3

Thread: Java + Struts 2 + Ext - How to use failure method?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User lucasguaru's Avatar
    Join Date
    May 2011
    Location
    Guaruj, Brazil
    Posts
    77
    Answers
    9
    Vote Rating
    2
      0  

    Default Answered: Java + Struts 2 + Ext - How to use failure method?

    How can I handle and error on Struts 2 and send it to Ext in a way I can get it on failure?
    I tried using a specific jsp with exception-mapping but I was going to success.
    If I let the error come, the response text is and page from tomcat.
    I would like to receive in the same way but if the message was my error message.
    What I'm doing know is setting success false but I'm not confortable with that.

    Does anyone is using the failure method for the requests and can get the error message?

    Thanks

  2. Have you tried setting the status code for the response? If you return as 4xx or 5xx error it should go to the failure handler.

    http://en.wikipedia.org/wiki/HTTP_status_code

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Answers
    583
    Vote Rating
    390
      0  

    Default

    Have you tried setting the status code for the response? If you return as 4xx or 5xx error it should go to the failure handler.

    http://en.wikipedia.org/wiki/HTTP_status_code

  4. #3
    Sencha User lucasguaru's Avatar
    Join Date
    May 2011
    Location
    Guaruj, Brazil
    Posts
    77
    Answers
    9
    Vote Rating
    2
      0  

    Default

    That worked. Thanks!

    What I did on struts.xml
    Code:
    <global-results>
        <result name="errorExt">/errorPages/errorExt.jsp</result>
    </global-results>
    
    <global-exception-mappings>
        <exception-mapping exception="br.com.g3.exception.G3Exception" result="errorExt" />
    </global-exception-mappings>
    errorExt.jsp:
    Code:
    <%=request.getAttribute("errorExt")%>
    Sending the error:
    Code:
    this.response.setStatus(500);
    G3Error g3error = new G3Error(errorCode, erroMsg);
    String errorString = this.getJSONSerializer().serialize(g3error);
    request.setAttribute("errorExt", errorString);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •