Grabbing the "Current" Resolution

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Grabbing the "Current" Resolution

Asleson, Ryan
 
Hello,
 
Let's say I annotate a method like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
When the annotated method is called, I assume that some Resolution has been chosen, but has yet to be executed.  Is there a way, in that annotated method, to get a reference to the Resolution that is about to be executed?  If so, how do I do so?  Also, will there also be a Resolution available when binding/validation errors have occurred?
 
Thanks!!
 
-Ryan
 
 

This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing the "Current" Resolution

levi_h
When you define an Interceptor, Stripes passes an ExecutionContext. This object contains the resolution. I'm not sure, but I don't think that the BeforeAfterMethodInterceptor hands @Before/@After methods the execution context (it would be nice, though, to have the interceptor support an optional parameter).

On Mon, Jun 23, 2008 at 8:41 PM, Asleson, Ryan <[hidden email]> wrote:
 
Hello,
 
Let's say I annotate a method like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
When the annotated method is called, I assume that some Resolution has been chosen, but has yet to be executed.  Is there a way, in that annotated method, to get a reference to the Resolution that is about to be executed?  If so, how do I do so?  Also, will there also be a Resolution available when binding/validation errors have occurred?
 
Thanks!!
 
-Ryan
 
 

This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing the "Current" Resolution

Ben Gunter
In reply to this post by Asleson, Ryan
Maybe do something like this?

public class SomeActionBean extends BaseActionBean {


On Mon, Jun 23, 2008 at 2:41 PM, Asleson, Ryan <[hidden email]> wrote:
 
Hello,
 
Let's say I annotate a method like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
When the annotated method is called, I assume that some Resolution has been chosen, but has yet to be executed.  Is there a way, in that annotated method, to get a reference to the Resolution that is about to be executed?  If so, how do I do so?  Also, will there also be a Resolution available when binding/validation errors have occurred?
 
Thanks!!
 
-Ryan
 
 

This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users




--
Ben Gunter
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing the "Current" Resolution

Ben Gunter
Sorry; fat fingers.

public class SomeActionBean extends BaseActionBean {
  private Resolution resolution;

  @Before(LifecycleStage.ResolutionExecution)
  public blah() {
    if (this.resolution != null) {
      // do something with the resolution
    }
  }

  public Resolution doSomething() {
    return this.resolution = new RedirectResolution( ... );
  }
}

Someone correct me if I'm wrong, but I don't think the interceptor method will ever execute on B&V errors because the lifecycle gets cut short.

-Ben

On Mon, Jun 23, 2008 at 3:17 PM, Ben Gunter <[hidden email]> wrote:
Maybe do something like this?

public class SomeActionBean extends BaseActionBean {


On Mon, Jun 23, 2008 at 2:41 PM, Asleson, Ryan <[hidden email]> wrote:
 
Hello,
 
Let's say I annotate a method like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
When the annotated method is called, I assume that some Resolution has been chosen, but has yet to be executed.  Is there a way, in that annotated method, to get a reference to the Resolution that is about to be executed?  If so, how do I do so?  Also, will there also be a Resolution available when binding/validation errors have occurred?
 
Thanks!!
 
-Ryan
 
 

This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users




--
Ben Gunter



--
Ben Gunter
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing the "Current" Resolution

Asleson, Ryan
In reply to this post by levi_h
 
OK, so if I define an interceptor that intercepts like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
Will the method be called when there's a binding/validation error, or is it totally skipped?
 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Levi Hoogenberg
Sent: Monday, June 23, 2008 2:17 PM
To: Stripes Users List
Subject: Re: [Stripes-users] Grabbing the "Current" Resolution

When you define an Interceptor, Stripes passes an ExecutionContext. This object contains the resolution. I'm not sure, but I don't think that the BeforeAfterMethodInterceptor hands @Before/@After methods the execution context (it would be nice, though, to have the interceptor support an optional parameter).

On Mon, Jun 23, 2008 at 8:41 PM, Asleson, Ryan <[hidden email]> wrote:
 
Hello,
 
Let's say I annotate a method like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
When the annotated method is called, I assume that some Resolution has been chosen, but has yet to be executed.  Is there a way, in that annotated method, to get a reference to the Resolution that is about to be executed?  If so, how do I do so?  Also, will there also be a Resolution available when binding/validation errors have occurred?
 
Thanks!!
 
-Ryan
 
 

This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing the "Current" Resolution

levi_h
I just tried this and yes, the interceptor will be invoked (with both the validation errors in place and a net.sourceforge.stripes.action.ValidationErrorReportResolution as resolution).

On Mon, Jun 23, 2008 at 9:50 PM, Asleson, Ryan <[hidden email]> wrote:
 
OK, so if I define an interceptor that intercepts like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
Will the method be called when there's a binding/validation error, or is it totally skipped?
 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Levi Hoogenberg
Sent: Monday, June 23, 2008 2:17 PM
To: Stripes Users List
Subject: Re: [Stripes-users] Grabbing the "Current" Resolution

When you define an Interceptor, Stripes passes an ExecutionContext. This object contains the resolution. I'm not sure, but I don't think that the BeforeAfterMethodInterceptor hands @Before/@After methods the execution context (it would be nice, though, to have the interceptor support an optional parameter).

On Mon, Jun 23, 2008 at 8:41 PM, Asleson, Ryan <[hidden email]> wrote:
 
Hello,
 
Let's say I annotate a method like this:
 
@Before(LifecycleStage.ResolutionExecution)
 
When the annotated method is called, I assume that some Resolution has been chosen, but has yet to be executed.  Is there a way, in that annotated method, to get a reference to the Resolution that is about to be executed?  If so, how do I do so?  Also, will there also be a Resolution available when binding/validation errors have occurred?
 
Thanks!!
 
-Ryan
 
 

This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

is it possible to redirect response while rendering stripes template definition jsp?

Leonard Gestrin

Hello,

 

I have the following task. I need to make sure that user gets redirected to a certain page anywhere in the app, if certain condition happens. I have all pages using stripes layout.jsp. Naturally, I tried to put condition in layout.jsp before or after <stripes:layout-definition> tag  and do <% response.sendRedirect(:http://google.com”) %> as a proof concept. However, it did not work and there were no exceptions. My theory is that once stripes starts writing to response object by processing layout tags (pulling layout.jsp), redirect can no longer be performed.

 

I could prove it by moving the check condition outside layout.jsp into home.jsp (which is defined layout.jsp as it’s template) – then, redirect happens.  

Does it make sense? Is it possible to do what I am trying to do using layout.jsp?

 

This is tomcat 5.20 stipes 1.4.3

 

 


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to redirect response while rendering stripes template definition jsp?

Freddy D.
Hi Leonard,

Why not just use an Interceptor? And if said condition happens,
return new RedirectResolution("http://www.google.com");

Cheers,
Freddy




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Grabbing the "Current" Resolution

Freddy D.
In reply to this post by Ben Gunter
Except for ResolutionExecution

> Someone correct me if I'm wrong, but I don't think the interceptor method
> will ever execute on B&V errors because the lifecycle gets cut short.

For most other lifecycle stages, the lifecycle gets cut short if at any
point, a resolution gets returned (which is what happens on B&V errors).
However, ResolutionExecution stage does get called, as well as its
interceptors, because the resolution still needs to be executed.

However, if something bad happens (e.g. exception thrown), all bets are off.
Only RequestComplete will be called, since it is in a finally block. That's
a good place for resource cleanup.

Sorry if I gave more information than necessary, I just happen to be buried
in that stuff right now ;)

Cheers,
Freddy



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to redirect response while rendering stripes template definition jsp?

Leonard Gestrin
In reply to this post by Freddy D.
Hi Freddy,
I think this would definitely work. I am reluctant to put interceptor
because it does obfuscate the logic; in our case, the requirement is
basically to check for an ACL. We have custom tags that evaluate ACL and
render the body of the tag or skip it.  I wanted to keep this logic on
the page since I did not want some ACL resolution to be done by
interceptor and others within the pages.

I think stripes 1.5 has better support for ACL in general, so I was
thinking of reevaluating our security in general once we move to 1.5

My question was more driven by curiosity why redirect does not happen
and there are no Exceptions at all.

I do have an OK workaround, so I am not stuck.



-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Freddy
D.
Sent: Monday, June 23, 2008 7:53 PM
To: [hidden email]
Subject: Re: [Stripes-users]is it possible to redirect response while
rendering stripes template definition jsp?

Hi Leonard,

Why not just use an Interceptor? And if said condition happens,
return new RedirectResolution("http://www.google.com");

Cheers,
Freddy




------------------------------------------------------------------------
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to redirect response while rendering stripes template definition jsp?

W. Hartung

On Jun 23, 2008, at 8:07 PM, Leonard Gestrin wrote:

> My question was more driven by curiosity why redirect does not happen
> and there are no Exceptions at all.

A redirect is done by setting an HTTP header. Once the response  
starts streaming, header can no longer be written.

To add to the fun, this isn't precisely true.

JSPs stream in to a buffer, when the buffer fills up, it's  
"committed" to the browser. Up until that commit point, you can set  
headers and what not.

So, you could expand the buffer for all of your JSPs, of you can make  
your redirect decision earlier in the process.

Regards,

Will Hartung


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to redirect response whilerendering stripes template definition jsp?

Leonard Gestrin
Thanks for the explanation.

P.S.
I switched to interceptor. Works likes a charm.

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Will
Hartung
Sent: Monday, June 23, 2008 8:50 PM
To: Stripes Users List
Subject: Re: [Stripes-users] is it possible to redirect response
whilerendering stripes template definition jsp?


On Jun 23, 2008, at 8:07 PM, Leonard Gestrin wrote:

> My question was more driven by curiosity why redirect does not happen
> and there are no Exceptions at all.

A redirect is done by setting an HTTP header. Once the response  
starts streaming, header can no longer be written.

To add to the fun, this isn't precisely true.

JSPs stream in to a buffer, when the buffer fills up, it's  
"committed" to the browser. Up until that commit point, you can set  
headers and what not.

So, you could expand the buffer for all of your JSPs, of you can make  
your redirect decision earlier in the process.

Regards,

Will Hartung


------------------------------------------------------------------------
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users