struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "carlo scarioni (JIRA)" <>
Subject [jira] Commented: (WW-3232) New Cookie Interceptor
Date Thu, 03 Sep 2009 06:26:24 GMT


carlo scarioni commented on WW-3232:

It actually does that two things...

If you set the @Cookie annotated property in the action, when the action returns the beforeResult
method is invoked on the interceptor and
the new value from the action property will be setted on the cookie... If the property's value
is null, the cookie's age will be setted to zero so it will be deleted from the browser...

So you the interceptor do all of that...

It injects the cookie to the action if it exists, and on return  takes the value from the
action's property (which can be the same value as before) and set it again on the cookie.
In case of null, cookie is deleted...

You can see the source code i attached..


> New Cookie Interceptor
> ----------------------
>                 Key: WW-3232
>                 URL:
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Interceptors
>    Affects Versions: 2.1.6
>            Reporter: carlo scarioni
>            Assignee: carlo scarioni
>         Attachments: struts-cookie-interceptor.tar.gz
> Hello, I've developed for my current project a simple Cookie Interceptor. It's like the
one in the distribution but different, :)
> It works by annotating in the action with a @Cookie(name="cookieName",timeToLive=100,path="xxx")
a String property.
> The Interceptor (Which is also a PreResultListener) Scans the action. if it finds a @Cookie
annotation it injects the cookie value into the action's property. When the action is executed,
the interceptor's beforeResultMethod scans the action again and the values from properties
annotated with @Cookie are saved in the response's cookies.
> This is the basic idea, than using just the getters and setters in the action you can
retrieve and set a cookie..
> I would love to share this simple interceptor, i would love to see a little of my code
added to your project :D ... what can i do for you to see the code and if it's something you
like, submit it... thanks..

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message