I use something like this from an AbstractApiActionBean

    /**
     *  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 ) throws 
Exception
    {
        JSONObject obj = new JSONObject();

        obj.put( "error", constructErrorObject(errors) );

        return getJSONResolution( obj );
    }

where constructErrorObjects() just turns the errors into a JSON object, { 
field1: [error1,error2], field2: [error1, error2] }.

/Janne

On 2 Sep 2012, at 19:56, Gérald Quintana wrote:

> Hi,
> 
> Stripes is very nice for Form validation thanks to annotations, and Stripes 
> is nice for Ajax request handling. But handling validation errors when a form 
> is submitted with Ajax is not immediate. A recent article about Spring MVC 
> awoke my desire to have something more efficient.
> http://blog.springsource.org/2012/08/29/integrating-spring-mvc-with-jquery-for-validation-rules/
> 
> What's you approach for displaying errors when submitting a form using Ajax? 
> Returning page fragments? Returning error messages in JSON?
> 
> Just to share: I tried something very similar to Spring blog, tell me what 
> you think.
> https://github.com/gquintana/stripes-jquery (then 
> AjaxCalculator.jsp/AjaxCalculatorAction).
> 
> Cheers,
> Gérald
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. 
> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to