Binding to SpringBeans in ActionBean.setContext

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

Binding to SpringBeans in ActionBean.setContext

manish
Binding to SpringBeans in ActionBean.setContext

Hi there,

We have a single ActionBean that is used by multiple JSPs to view and update different parts of a domain model object graph. (We need to use a single action bean as we have a requirement for the end-user to be able to define which fields appear on which page).

We've tried to implement a initialisation for our action bean that will pre-load the entity object graph before any setters/getters are called by Stripes. We did this as per the article http://stripes.mc4j.org/confluence/display/stripes/Binding+Into+Domain+Models by overriding setContext and loading our object graph there.

The difference in our approach is that we are using SpringBeans to inject services into our ActionBeans that are used to load domain objects. In setContext, however, none of the SpringBeans have been injected yet. So we can't load our domain object there (without going to Spring directly).


Can anyone suggest a way of pre-loading our object graph from a SpringBean?

Thanks,
Manish



This email is intended only for the use of the addressees named above and may be confidential or legally privileged. If you are not an addressee you must not read it and must not use any information contained in it, nor copy it, nor inform any person other than TietoEnator or the addressees of its existence or contents. If you have received this email and are not a named addressee, please delete it and notify the TietoEnator UK Technical Services Team on 0113 390 0700.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding to SpringBeans in ActionBean.setContext

VANKEISBELCK Remi
On 10/17/06, Manish Shah <[hidden email]> wrote:
> Can anyone suggest a way of pre-loading our object graph from a SpringBean?

Maybe in an @Before method ?
Do you use @SpringBean in your ActionBean to inject stuff managed by Spring ?

Cheers

Remi

--
Rémi VANKEISBELCK
[hidden email]
http://www.rvkb.com

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding to SpringBeans in ActionBean.setContext

manish
In reply to this post by manish
Hi Remi,

Yes we do use at SpringBean to inject our beans.

Haven't looked at at BeforeMethod yet - just wondered if anyone else had come across this.

Cheers,
Manish


From: VANKEISBELCK Remi <remi@...>
Subject: Re: Binding to SpringBeans in ActionBean.setContext
Newsgroups: gmane.comp.java.stripes.user
Date: 2006-10-17 10:28:38 GMT (1 hour and 56 minutes ago)

On 10/17/06, Manish Shah <Ext.Manish.Shah@...> wrote:
> Can anyone suggest a way of pre-loading our object graph from a SpringBean?

Maybe in an  <at> Before method ?
Do you use  <at> SpringBean in your ActionBean to inject stuff managed by Spring ?

Cheers

Remi

--
Rémi VANKEISBELCK
remi@...
http://www.rvkb.com

This email is intended only for the use of the addressees named above and may be confidential or legally privileged. If you are not an addressee you must not read it and must not use any information contained in it, nor copy it, nor inform any person other than TietoEnator or the addressees of its existence or contents.  If you have received this email and are not a named addressee, please delete it and notify the TietoEnator UK Technical Services Team on 0113 390 0700.



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding to SpringBeans in ActionBean.setContext

Ben Gunter
Here's the Javadoc page for @Before:

http://stripes.sourceforge.net/docs/current/javadoc/net/sourceforge/stripes/action/Before.html

It will probably do what you need.

-Ben

Manish Shah wrote:
Hi Remi,

Yes we do use at SpringBean to inject our beans.

Haven't looked at at BeforeMethod yet - just wondered if anyone else had come across this.

Cheers,
Manish


From: VANKEISBELCK Remi [hidden email]
Subject: Re: Binding to SpringBeans in ActionBean.setContext
Newsgroups: gmane.comp.java.stripes.user
Date: 2006-10-17 10:28:38 GMT (1 hour and 56 minutes ago)

On 10/17/06, Manish Shah [hidden email] wrote:
  
Can anyone suggest a way of pre-loading our object graph from a SpringBean?
    

Maybe in an  <at> Before method ?
Do you use  <at> SpringBean in your ActionBean to inject stuff managed by Spring ?

Cheers

Remi

  

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding to SpringBeans in ActionBean.setContext

David G Friedman
In reply to this post by manish
Binding to SpringBeans in ActionBean.setContext
I thought @SpringBean only worked on ActionBean setters/getters, not inside an embedded object like the ActionContext.  To make it work for the ActionContext, I have some ideas for you:
 
1. Inside your ActionBean constructor call springContext.getBean("whatever") and set that object to the context's setters appropriately.  This way Spring will give you initialized objects for you to inject yourself.
 
2. Try setting up Spring to create a Context object for you so it can automatically handle setters/getters.  Then you can use @SpringBean on your setActionContext() method and initializing it automatically by Stripes+Spring.  I do see one potentially large "gotcha" with this approach:  Since I do not know when setContext is called compared to @SpringBean initialization, I don't know if this would override the whole Stripes initialization and binding process or not.
 
3. Set your global ActionBeanContext.class to your own "MySpringActionBeanContext."   Then in your constructor you could first invoke springContext.getBean("something") to obtain your Spring instance then set "this" to it.  Unfortunately, I don't have any ideas right now on how to figure out which "something" name to use.  An annotation perhaps?  But how would you figure out the annotation's value, by using the resolverUtils somehow?  I guess there would have to be a reverse/object reference/link from the Context to the ActionBean.   I just don't see anything like that in the source code of the Stripes verison I use (1.4 or 1.4.1, not sure).
 
Regards,
David
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Manish Shah
Sent: Tuesday, October 17, 2006 5:07 AM
To: [hidden email]
Subject: [Stripes-users] Binding to SpringBeans in ActionBean.setContext

Hi there,

We have a single ActionBean that is used by multiple JSPs to view and update different parts of a domain model object graph. (We need to use a single action bean as we have a requirement for the end-user to be able to define which fields appear on which page).

We've tried to implement a initialisation for our action bean that will pre-load the entity object graph before any setters/getters are called by Stripes. We did this as per the article http://stripes.mc4j.org/confluence/display/stripes/Binding+Into+Domain+Models by overriding setContext and loading our object graph there.

The difference in our approach is that we are using SpringBeans to inject services into our ActionBeans that are used to load domain objects. In setContext, however, none of the SpringBeans have been injected yet. So we can't load our domain object there (without going to Spring directly).


Can anyone suggest a way of pre-loading our object graph from a SpringBean?

Thanks,
Manish


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users