Ted,

I studied the Stripes API a while ago and found nothing relavant and that‘s why 
I came up with the interceptor. At first I was also a bit surprised that the 
current action bean’s context was not exposed in the customization APIs 
(formatters, type factories etc.). 

 Honza

 

From: ted_smith2...@comcast.net [mailto:ted_smith2...@comcast.net] 
Sent: 15. listopadu 2011 11:49
To: Stripes Users List
Subject: Re: [Stripes-users] Two way type conversion possible?

 

Thanks for the info.  Does it mean there is no built-in global static method to 
get the actionbean or context of current thread?



  _____  

From: "Jan Moravec" <h...@seznam.cz>
To: "Stripes Users List" <stripes-users@lists.sourceforge.net>
Sent: Tuesday, November 15, 2011 4:13:35 AM
Subject: Re: [Stripes-users] Two way type conversion possible?




Hi Ted,

 

To obtain the current action bean/bean context within the formatter (and other 
Stripes extension APIs) I use a custom RequestResponseThreadLocalInterceptor 
that binds the current request/response/servlet context to a set of 
thread-locals during the RequestInit stage and performs a cleanup during the 
RequestComplete stage. Then I can access the current request/response/context 
anywhere in the „Stripes request processing chain“ regardless of whether the 
invoked component exposes the current request/response/context through its API. 
Once you get hold of the current servlet request, you can access the current 
action bean as it is bound to a request attribute 
(StripesConstants.REQ_ATTR_ACTION_BEAN). And once you have the current action 
bean, you can access its context.

 

Note: When using the above technique you just need to keep in mind that the 
action bean gets bound to the current request at some stage between the 
RequestInit and RequestComplete (I would bet on the ActionBeanResolution 
stage). So for example the action bean would not be available during the 
RequestInit stage. I think you should not have a problem with the formatter as 
its format method is most likely invoked after the action bean has been 
resolved and bound, but it is definitely something to be aware of.

 

Cheers,

Honza

 

 

From: ted_smith2...@comcast.net [mailto:ted_smith2...@comcast.net] 
Sent: 15. listopadu 2011 4:33
To: Stripes Users List
Subject: Re: [Stripes-users] Two way type conversion possible?

 

I am using freemarker (jsp should be similar)
<@s.text name="dateTime"  
value=actionBean.customeDateTimeString(actionBean.dateTime/>
does not work.   I created a method in bean,  getCustomDateTimeString() to 
generate the special string.

BTW, I am trying to go the route of creating  a custom DateFormatter.
How can I reference the action bean/context   from within the formatter?

Thanks

  _____  

From: "Anthony DePalma" <fatef...@gmail.com>
To: "Stripes Users List" <stripes-users@lists.sourceforge.net>
Sent: Monday, November 14, 2011 8:22:14 AM
Subject: Re: [Stripes-users] Two way type conversion possible?

Well that wouldn't really make sense seeing as validation is only converting 
from a request string to an object. once you have the object, its the jsp that 
needs it formatted differently.

At that point you have the object in your action bean and you want to display 
it a certain way. you have a bunch of options now. you can create a getter that 
does the formatting manually and call that from the jsp. you can use a jsp tag 
to convert it ( most useful if you want certain dates to display differently). 
or if you are using the object as a form parameter, you can register the type 
converter for the class and that's where the auto conversion happens. but now 
you are limited in that all dates are formatted this way.

In the end if its just for display, a fmt tag is the best route because you can 
use different formats wherever you want. Id argue that's the jsps 
responsibility anyway.

On Nov 14, 2011 8:13 AM, <ted_smith2...@comcast.net> wrote:


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to