> 
> Message: 1
> Date: Tue, 30 Sep 2014 10:01:52 -0400
> From: Yann Bourdeau <ybourd...@mnubo.com>
> Subject: [Stripes-users] Stripes Ajax calls on error
> To: stripes-users@lists.sourceforge.net
> Message-ID: <d73b7b75-8297-4b87-9298-d37f41842...@mnubo.com>
> Content-Type: text/plain; charset=windows-1252
> 
> 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
> 
> 
> 
> 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

> Message: 3
> Date: Tue, 30 Sep 2014 09:35:13 -0600
> From: Nathan Maves <nathan.ma...@gmail.com>
> Subject: Re: [Stripes-users] Stripes Ajax calls on error
> To: Stripes Users List <stripes-users@lists.sourceforge.net>
> Message-ID:
>       <CAG=psibgdfpe72cbwh_2w0r+modbc_il81vdzor988rk9g9...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> Sure, you just need to have your action class
> implement ValidationErrorHandler.  Then you can do what ever you want when
> there are validation errors.
> 
> http://stripes.sourceforge.net/docs/current/javadoc/net/sourceforge/stripes/validation/ValidationErrorHandler.html
> 

Hi Both of you,

It is not for validation error. Let me clarify, the AJAX call do call a REST 
API which it can return an error. I need to return this error to the client 
(JQUERY). I have seen in your code example JSONResolution. I don’t think this 
is part of Stripes. Do I need to implement a Resolution to do it?(Like it seems 
you have done).

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

Reply via email to