I suppose you mean validation errors in particular?  We use something like this 
in our AbstractApiActionBean from which all our Api beans inherit from:

    /**
     *  Normally Stripes turns validation errors into HTML, but since this is 
an API,
     *  we turn it into JSON.  Returns a JSON or JSONP resolution with a single
     *  field "error" which then contains a number of errors.
     */
    @Override
    public Resolution handleValidationErrors( ValidationErrors errors )
    {
        JSONObject obj = new JSONObject();
    
        obj.put( "error", constructErrorObject(errors) );
    
        if( m_callback != null )
            return new JSONPResolution( m_callback, obj );
    
        return new JSONResolution( HttpServletResponse.SC_BAD_REQUEST, obj );
    }

/Janne

On 30 Sep 2014, at 17:01, Yann Bourdeau <ybourd...@mnubo.com> wrote:

> Hello,
> 
>       I was wondering is it possible to have an Ajax Call in a Stripes 
> handler to return an error code and specific body (like a JSON) instead of 
> the default HTML error message in ErrorResolution. I use StreamingResolution 
> for returning JSON on successful call and ErrorResolution to returns an 
> error. However, ErrorResolution returns an html text body and i’d like to 
> return a JSON containing the error. It will be easier to parse in JQuery. Any 
> idea?
> 
> thanks
> 
> Yann Bourdeau, M. Ing.
> 514-219-4607
> ybourd...@mnubo.com
> 
> 
> 
> 
> -- 
> 
> 
> CONFIDENTIALITY: This e-mail message (including attachments, if any) is 
> confidential and is intended only for the addressee. Any unauthorized use 
> or disclosure is strictly prohibited. Disclosure of this e-mail to anyone 
> other than the intended addressee does not constitute waiver of privilege. 
> If you have received this communication in error, please notify us 
> immediately and delete this. Thank you for your cooperation.  This message 
> has not been encrypted.  Special arrangements can be made for encryption 
> upon request.
> 
> CONFIDENTIALITÉ:  Ce message courriel (y compris les pièces jointes, le cas 
> échéant) est confidentiel et destiné uniquement à la personne ou  à 
> l'entité à qui il est adressé. Toute utilisation ou divulgation non permise 
> est strictement interdite.  L'obligation de confidentialité et de secret 
> professionnel demeure malgré toute divulgation.  Si vous avez reçu le 
> présent courriel et ses annexes par erreur, veuillez nous en informer 
> immédiatement et le détruire.  Nous vous remercions de votre 
> collaboration.  Le présent message n'a pas été crypté.  Le cryptage est 
> possible sur demande spéciale.
> 
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to