Re: [Stripes-users] Stripes Ajax calls on error

2014-09-30 Thread Rick Grashel
You need to implement your own resolution.

ErrorResolution uses the standard sendError() method on
HttpServletResponse.  The default behavior of any Java web container is to
set the HTTP response code and then set the text of the error as the
message.  This will be returned in text/html format to the caller.

In your resolution, you need to do the following:

response.resetBuffer();
response.setStatus(  );
response.setHeader( "Context-Type",  );
response.getWriter().print( "some response text" );
response.getWriter().flush();

That should give you what you want.




On Tue, Sep 30, 2014 at 11:06 AM, Yann Bourdeau  wrote:

>
> >
> > Message: 1
> > Date: Tue, 30 Sep 2014 10:01:52 -0400
> > From: Yann Bourdeau 
> > Subject: [Stripes-users] Stripes Ajax calls on error
> > To: stripes-users@lists.sourceforge.net
> > Message-ID: 
> > 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 
> > Subject: Re: [Stripes-users] Stripes Ajax calls on error
> > To: Stripes Users List 
> > Message-ID:
> >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
> ___

Re: [Stripes-users] Stripes Ajax calls on error

2014-09-30 Thread Yann Bourdeau

> 
> Message: 1
> Date: Tue, 30 Sep 2014 10:01:52 -0400
> From: Yann Bourdeau 
> Subject: [Stripes-users] Stripes Ajax calls on error
> To: stripes-users@lists.sourceforge.net
> Message-ID: 
> 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 
> Subject: Re: [Stripes-users] Stripes Ajax calls on error
> To: Stripes Users List 
> Message-ID:
>   
> 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


Re: [Stripes-users] Stripes Ajax calls on error

2014-09-30 Thread Nathan Maves
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

On Tue, Sep 30, 2014 at 9:11 AM, Janne Jalkanen 
wrote:

>
> 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  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
>
>
--
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


Re: [Stripes-users] Stripes Ajax calls on error

2014-09-30 Thread Janne Jalkanen

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  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


[Stripes-users] Stripes Ajax calls on error

2014-09-30 Thread Yann Bourdeau
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


Re: [Stripes-users] Stripes, Google Maps and KML

2014-09-30 Thread VANKEISBELCK Remi
Hi,

You don't need to overwrite stream(), just pass your string to
StreamingResolution's constructor (or a reader or input stream)...

Now for your google-specific problem, I have no idea.

Cheers

Rémi


2014-09-27 23:36 GMT+02:00 Heather and Jon Turgeon <
tashiba40_evergr...@hotmail.com>:

> Hi all, my Stripes based mapping site is coming along nicely. (running on
> AWS) I do have a question if anyone has used a Stripes action to be the
> source of a KML for Google maps? So far I have the code written and the KML
> being created in an action but have been unable to get the placemarks to
> show up on the map (no placemarks are created). Here is the Javascript I use
>
> //Load the markers
> var kmlLayer = new google.maps.KmlLayer({
>  url: '../marker/KMLMarker.action'
> });
> kmlLayer.setMap(gemap);
>
> here is the end of the Stripes action, I am using the kmlframework library
> for creating the kml from hibernate objects
>
> return new StreamingResolution("text/kml") {
>public void stream(HttpServletResponse response) throws Exception {
>   response.getWriter().write(kml.toString());
>}
> };
>
> Jon
>
>
> --
> 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