Thanks Matt. You save me some time to dig around. In fact, portalProcessor is bound to Jsf portalTabbedBean. I will redo it in the next round of refactoring.

BaTien
DBGROUPS

Matt Raible wrote:


On Dec 16, 2004, at 1:18 PM, BaTien Duong wrote:


Hi Matt:

Up to now, i manually connect Jsf component with Spring components. Would you explain what happens in the following case:

1) A jsf session managed bean (portalTabbedBean) is called the first time a user hits the site. The portalTabbedBean is connected to a non-singleton Spring bean (portalProcessor) which provides hooks to singleton facilities managed by Spring.

2) Currently i connect these 2 by looking at the user session to see if it has an instance of portalProcessor. If not, i instantiate the portalProcessor, connect to the portalTabbedBean and put it in as a session attribute. The lifecycles of both beans go with the user session.

3) Now, if i use Spring Jsf support to connect Jsf portalTabbedBean with Spring portalProcessor, what is the lifecycle of non-singleton portalProcessor?


If it's a non-singleton (indicated by singleton="false") then the portalProcessor will be instantiated similar to if you called "new" on it - except it's dependencies will be injected by Spring.

and how do i programmatically access the instance of Spring portalProcessor since there is now NO user session attribute attached to the bean (portalProcessor)?


If portalProcessor is not bound to a managed-bean as a managed-property, then you'll have to lookup the WebApplicationContext and get it from there. There's a FacesContextUtils that simplifies this process.

http://www.springframework.org/docs/api/org/springframework/web/jsf/ FacesContextUtils.html

Hope this helps.

Matt

.




Reply via email to