You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by bansi <ma...@yahoo.com> on 2007/05/17 18:21:38 UTC

How to Share Session between JSF(MyFaces) and Spring

Hi Gurus
Could you please tell me 
What are the best practices to  pass Session object from JSF to Spring.  For
example lets say  LoginBean in JSF has to store userId and userRole in
Session object and then pass Session object to Spring Layer so that it can
be accessible by any spring bean

- Do you recommend using Httpsession?

- Does OpenSessionInViewFilter provides a mechanism to store userId &
userRole in session & then pass it onto spring layer

OR

- Is their any other mechanism that you would recommend for storing userId &
userRoles into Session object at JSF Layer and then retrieve the same
Session object at Spring layer so that it can be accessible by an spring
bean 

Any pointers/suggestions will be highly appreciated

Regards
Bansi

-- 
View this message in context: http://www.nabble.com/How-to-Share-Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10667077
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Custom picklist component

Posted by Cagatay Civici <ca...@gmail.com>.
Hi,

This would help;

http://myfaces.apache.org/sandbox/selectManyPicklist.html

Cagatay

On 5/18/07, Cormier, Matthieu <ma...@abridean.com> wrote:
>
> Hello All,
>
> I am attempting to build a picklist JSF component.  Here is a prototype
> of a pick list with javascript only:
>
> http://torch.cs.dal.ca/~mcormier/picker/
>
>
> To create a picklist with columns tables are used. Rows in the table are
> built dynamically with javascript from supplied data.
>
> I have built a simple "Hello world" component but am at a loss as to
> whether a picklist component is possible.  My main mental hurdle is how
> to get the data back after a form submit, because tables are not form
> elements.
>
> Do you think building such a component is possible?  Are any components
> in myfaces/tomahawk similar to what I am attempting to build? (I could
> get a headstart by reading the component source)
>
> M@
>
>
>

RE: How to Share Session between JSF(MyFaces) and Spring

Posted by bansi <ma...@yahoo.com>.
i am using Springs DelegatingVariableResolver to make  my Spring beans
accessible from JSF layer . Thats exactly how i am passing user session
object (  i.e. user Id and user Roles ) as argument to business method in
Spring.

I am able to retrieve this user session object & its attributes into Base
bean of Spring Layer but the subclasses of Base bean are not able to get the
same value as in Base bean even though i declare them as protected
<variable_name>

When i reached this point, i started rethinking on my design whether its
good way to pass HttpSession object as argument to business method in Spring 

OR

Should i use Servlet Filters but again how to access it in business Layer as
Spring doesnt provide any handle to HttpServletRequest in business Layer.
The other issue was ThreadLocal

Finally when i ran out of options i posted on Forums to see how other people
are doing

Regards
Bansi



Nebinger, David wrote:
> 
>> Thanks Everyone for providing valuable suggestions We 
>> usein-house Security system which  gives employee Id and 
>> Roles on successful authentication. We need to store  
>> employee Id &Roles into some kind of object maybe  session so 
>> that it can be accessible by any Spring bean in the business layer.
>> David i totally agree with you that i should rethink my 
>> design . Not sure whats the best practice to pass user info 
>> viz. user Id , user Roles , privileges etc from JSF to Spring. 
>> Are you refering to POJO instead of session object for 
>> wrapping userId and roles. Thats a good idea even i thought 
>> about BUT users will have different session objects with 
>> their user Info in it and also we want the Lifecycle of the 
>> object to be under session i.e. as the session terminates the 
>> object should be destroyed
> 
> Well, I guess an option here is to mimic what acegi would do; place the
> authentication object into a ThreadLocal object.  That way it is
> available to any layer w/o requiring any runtime binding...
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-Share-Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10687302
Sent from the MyFaces - Users mailing list archive at Nabble.com.


RE: How to Share Session between JSF(MyFaces) and Spring

Posted by bansi <ma...@yahoo.com>.
Thanks David . As i am newbie i would appreciate a snippet code on how to
place the
 authentication object into a ThreadLocal object so that its available to
Spring layer w/o  any runtime binding

Here is what i am doing currently
The Homegrown security application on successful authentication returns
Request Header Variables i.e.  userId  which i retrieve thru FaceContext in
JSF backing bean  i.e. LoginBean, based on which i retrieve user roles from
the database. 
As a next step, i wrap  user Id and user roles into Http Session object  
and  pass it on as argument to business method in Spring


Regards
Bansi


Nebinger, David wrote:
> 
>> Thanks Everyone for providing valuable suggestions We 
>> usein-house Security system which  gives employee Id and 
>> Roles on successful authentication. We need to store  
>> employee Id &Roles into some kind of object maybe  session so 
>> that it can be accessible by any Spring bean in the business layer.
>> David i totally agree with you that i should rethink my 
>> design . Not sure whats the best practice to pass user info 
>> viz. user Id , user Roles , privileges etc from JSF to Spring. 
>> Are you refering to POJO instead of session object for 
>> wrapping userId and roles. Thats a good idea even i thought 
>> about BUT users will have different session objects with 
>> their user Info in it and also we want the Lifecycle of the 
>> object to be under session i.e. as the session terminates the 
>> object should be destroyed
> 
> Well, I guess an option here is to mimic what acegi would do; place the
> authentication object into a ThreadLocal object.  That way it is
> available to any layer w/o requiring any runtime binding...
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-Share-Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10687416
Sent from the MyFaces - Users mailing list archive at Nabble.com.


RE: How to Share Session between JSF(MyFaces) and Spring

Posted by "Nebinger, David" <dn...@tbbgl.com>.
> Thanks Everyone for providing valuable suggestions We 
> usein-house Security system which  gives employee Id and 
> Roles on successful authentication. We need to store  
> employee Id &Roles into some kind of object maybe  session so 
> that it can be accessible by any Spring bean in the business layer.
> David i totally agree with you that i should rethink my 
> design . Not sure whats the best practice to pass user info 
> viz. user Id , user Roles , privileges etc from JSF to Spring. 
> Are you refering to POJO instead of session object for 
> wrapping userId and roles. Thats a good idea even i thought 
> about BUT users will have different session objects with 
> their user Info in it and also we want the Lifecycle of the 
> object to be under session i.e. as the session terminates the 
> object should be destroyed

Well, I guess an option here is to mimic what acegi would do; place the
authentication object into a ThreadLocal object.  That way it is
available to any layer w/o requiring any runtime binding...


Re: How to Share Session between JSF(MyFaces) and Spring

Posted by Thomas Lutz <ma...@gmx.at>.
We use a "in house" security provider, too, but I found it quite easy to 
adapt acegi.. implementing my own UserDetailService and PasswordEncoder 
did they job.

So, maybe if you have a look at the acegi examples/source, and then try 
to implement the interfaces

org.acegisecurity.userdetails.UserDetailsService
org.acegisecurity.providers.encoding.PasswordEncoder

so that they communicate with your in house solution, and then wire 
everything up in the spring config, you're done...

For integration fo acegi search the myfaces wiki, jsf-spring project on 
sourceforge, or even the spring documentation itself... there are lots 
of out of the box working examples out there...

hth,
Tom

bansi wrote:
> Thanks Everyone for providing valuable suggestions
> We usein-house Security system which  gives employee Id and Roles on
> successful authentication. We need to 
> store  employee Id &Roles into some kind of object maybe  session so that it
> can be accessible by any Spring bean in the business layer.
> David i totally agree with you that i should rethink my design . Not sure
> whats the best practice to pass user info viz. user Id , user Roles ,
> privileges etc from JSF to Spring. 
> Are you refering to POJO instead of session object for wrapping userId and
> roles. Thats a good idea even i thought about BUT users will have different
> session objects with their user Info in it and also we want the Lifecycle of
> the object to be under session i.e. as the session terminates the object
> should be destroyed
>
> Regards
> Bansi
>  
>
> Nebinger, David wrote:
>   
>>> Besides the spring integration, maybe you should rethink your 
>>> design ? 
>>> Use somthing like acegi security to perform authentification 
>>> and authorization instead of passing Session objects to the 
>>> business layer...
>>> At least consider wrapping the info you need (user id and 
>>> roles) in an object, instead of passing the session object...
>>> As far as I remember (after quite some time using frameworks 
>>> I guess I've lost some basics :-)) there's no need to store 
>>> the user's details in the session ? Everything should be 
>>> there, at least if you use container (or tomcat) based auth ?
>>>       
>> Yes, Acegi uses a security context holder which is basically bound to
>> the thread.  A filter on the incoming request ensures the thread has the
>> appropriate user.  It is then available throughout your application,
>> including the spring beans.
>>
>>
>>     
>
>   


RE: How to Share Session between JSF(MyFaces) and Spring

Posted by bansi <ma...@yahoo.com>.
Thanks Everyone for providing valuable suggestions
We usein-house Security system which  gives employee Id and Roles on
successful authentication. We need to 
store  employee Id &Roles into some kind of object maybe  session so that it
can be accessible by any Spring bean in the business layer.
David i totally agree with you that i should rethink my design . Not sure
whats the best practice to pass user info viz. user Id , user Roles ,
privileges etc from JSF to Spring. 
Are you refering to POJO instead of session object for wrapping userId and
roles. Thats a good idea even i thought about BUT users will have different
session objects with their user Info in it and also we want the Lifecycle of
the object to be under session i.e. as the session terminates the object
should be destroyed

Regards
Bansi
 

Nebinger, David wrote:
> 
>> Besides the spring integration, maybe you should rethink your 
>> design ? 
>> Use somthing like acegi security to perform authentification 
>> and authorization instead of passing Session objects to the 
>> business layer...
>> At least consider wrapping the info you need (user id and 
>> roles) in an object, instead of passing the session object...
>> As far as I remember (after quite some time using frameworks 
>> I guess I've lost some basics :-)) there's no need to store 
>> the user's details in the session ? Everything should be 
>> there, at least if you use container (or tomcat) based auth ?
> 
> Yes, Acegi uses a security context holder which is basically bound to
> the thread.  A filter on the incoming request ensures the thread has the
> appropriate user.  It is then available throughout your application,
> including the spring beans.
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-Share-Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10685315
Sent from the MyFaces - Users mailing list archive at Nabble.com.


RE: How to Share Session between JSF(MyFaces) and Spring

Posted by "Nebinger, David" <dn...@tbbgl.com>.
> Besides the spring integration, maybe you should rethink your 
> design ? 
> Use somthing like acegi security to perform authentification 
> and authorization instead of passing Session objects to the 
> business layer...
> At least consider wrapping the info you need (user id and 
> roles) in an object, instead of passing the session object...
> As far as I remember (after quite some time using frameworks 
> I guess I've lost some basics :-)) there's no need to store 
> the user's details in the session ? Everything should be 
> there, at least if you use container (or tomcat) based auth ?

Yes, Acegi uses a security context holder which is basically bound to
the thread.  A filter on the incoming request ensures the thread has the
appropriate user.  It is then available throughout your application,
including the spring beans.

Where is ...renderkit.html.util.AddResource?

Posted by "Cormier, Matthieu" <ma...@abridean.com>.
Hello All, 

I am looking for the jar that contains import
org.apache.myfaces.renderkit.html.util.AddResource;

Does anyone know where this class is?  It is used by
HtmlPicklistRenderer "package org.apache.myfaces.custom.picklist;"

M@

Re: Custom picklist component

Posted by Josué Alcalde González <jo...@gmail.com>.
You will need to use some inputHidden to send the data to the server.

El vie, 18-05-2007 a las 07:03 -0600, Cormier, Matthieu escribió:
> Hello All,
> 
> I am attempting to build a picklist JSF component.  Here is a prototype
> of a pick list with javascript only:
> 
> http://torch.cs.dal.ca/~mcormier/picker/
> 
> 
> To create a picklist with columns tables are used. Rows in the table are
> built dynamically with javascript from supplied data.
> 
> I have built a simple "Hello world" component but am at a loss as to
> whether a picklist component is possible.  My main mental hurdle is how
> to get the data back after a form submit, because tables are not form
> elements.
> 
> Do you think building such a component is possible?  Are any components
> in myfaces/tomahawk similar to what I am attempting to build? (I could
> get a headstart by reading the component source)
> 
> M@
> 



Custom picklist component

Posted by "Cormier, Matthieu" <ma...@abridean.com>.
Hello All,

I am attempting to build a picklist JSF component.  Here is a prototype
of a pick list with javascript only:

http://torch.cs.dal.ca/~mcormier/picker/


To create a picklist with columns tables are used. Rows in the table are
built dynamically with javascript from supplied data.

I have built a simple "Hello world" component but am at a loss as to
whether a picklist component is possible.  My main mental hurdle is how
to get the data back after a form submit, because tables are not form
elements.

Do you think building such a component is possible?  Are any components
in myfaces/tomahawk similar to what I am attempting to build? (I could
get a headstart by reading the component source)

M@



Re: How to Share Session between JSF(MyFaces) and Spring

Posted by Thomas Lutz <ma...@gmx.at>.
Hi !

I use jsf-spring ( http://jsf-spring.sourceforge.net/ ) and it works 
very well. See the quickstart tutorial on their homepage, very easy to 
setup.

Besides the spring integration, maybe you should rethink your design ? 
Use somthing like acegi security to perform authentification and 
authorization instead of passing Session objects to the business layer...
At least consider wrapping the info you need (user id and roles) in an 
object, instead of passing the session object...
As far as I remember (after quite some time using frameworks I guess 
I've lost some basics :-)) there's no need to store the user's details 
in the session ? Everything should be there, at least if you use 
container (or tomcat) based auth ?

Hope that helps,
Tom

bansi wrote:
> Hi Kito
> Thanks for quick response. The reason Spring beans need direct access to
> session object is to perform some business logic based on userId and user
> Roles stored in session object. Hence the need to pass the session object
> >from JSF to Spring.  As you suggested i already implemented injecting Spring
> beans into JSF managed beans via managed-property in faces-config.xml. And i
> am able to successfully call Spring bean method  i.e.
> getUserSession(userSession) to pass the session object to Spring layer. But
> this call is limited to single Spring Bean. How if i wanna use same session
> object in other spring beans . 
> Here are the limitations of this approach
> - Redundant code in each  Backing bean calling Spring bean to pass session
> object
> - Is it recommended to pass HttpSession object to business (Spring) layer
> - Is it recommended to store userId and user Role in HttpSession object
> inside JSF Backing Bean. My requirement is all my Spring beans perform
> business logic based on userId and user Roles
> - The reason i put question mark on HttpSession object is even within JSF
> backing beans session is lost. For example i construct  session object in
> LoginBean and when i try to retrieve session in other backing bean it
> returns null. So i have to do something like this in the constructor of
> backing bean
> if(userSession == null){
> 		  System.out.println("Inside Manuf Constructor userSession");
> 	  userSession =
>           (HttpSession)
> FacesContext.getCurrentInstance().getExternalContext()
>                                     .getSession(true);
> 	  Object sess = userSession.getAttribute("userId");
> 	  System.out.println("userId in Session="+sess.toString());
> - Also the constructor of backing bean doesnt allow me to make a call Spring
> bean and results in Null Pointer Exception. So not sure where exactly in the
> backing bean i should make a call to getUserSession() method of Spring. For
> test purposes i am making this call from register() method of backing bean
> Overall i didnt have good success stories to share with by adopting this
> approach. Any pointers/suggestions will be highly appreciated
>
> Regards
> Bansi
>  
>
>
> Kito D. Mann wrote:
>   
>> Hello Bansi,
>>
>> You can inject Spring beans into your JSF managed beans via the Spring
>> DelegatingVariableResolver. Given that, you should be able to call your
>> Spring bean methods and pass in the appropriate parameters. Why do your
>> Spring beans need direct access to the session?
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Kito D. Mann (kmann@virtua.com)
>> Author, JavaServer Faces in Action
>> http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
>> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
>>
>>     
>>> -----Original Message-----
>>> From: bansi [mailto:mail2bansi@yahoo.com]
>>> Sent: Thursday, May 17, 2007 12:22 PM
>>> To: users@myfaces.apache.org
>>> Subject: How to Share Session between JSF(MyFaces) and Spring
>>>
>>>
>>> Hi Gurus
>>> Could you please tell me
>>> What are the best practices to  pass Session object from JSF to Spring.
>>> For
>>> example lets say  LoginBean in JSF has to store userId and userRole in
>>> Session object and then pass Session object to Spring Layer so that it
>>> can
>>> be accessible by any spring bean
>>>
>>> - Do you recommend using Httpsession?
>>>
>>> - Does OpenSessionInViewFilter provides a mechanism to store userId &
>>> userRole in session & then pass it onto spring layer
>>>
>>> OR
>>>
>>> - Is their any other mechanism that you would recommend for storing
>>> userId &
>>> userRoles into Session object at JSF Layer and then retrieve the same
>>> Session object at Spring layer so that it can be accessible by an
>>> spring
>>> bean
>>>
>>> Any pointers/suggestions will be highly appreciated
>>>
>>> Regards
>>> Bansi
>>>
>>> --
>>> View this message in context: http://www.nabble.com/How-to-Share-
>>> Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10667077
>>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>>       
>>
>>     
>
>   


RE: How to Share Session between JSF(MyFaces) and Spring

Posted by bansi <ma...@yahoo.com>.
Hi Kito
Thanks for quick response. The reason Spring beans need direct access to
session object is to perform some business logic based on userId and user
Roles stored in session object. Hence the need to pass the session object
from JSF to Spring.  As you suggested i already implemented injecting Spring
beans into JSF managed beans via managed-property in faces-config.xml. And i
am able to successfully call Spring bean method  i.e.
getUserSession(userSession) to pass the session object to Spring layer. But
this call is limited to single Spring Bean. How if i wanna use same session
object in other spring beans . 
Here are the limitations of this approach
- Redundant code in each  Backing bean calling Spring bean to pass session
object
- Is it recommended to pass HttpSession object to business (Spring) layer
- Is it recommended to store userId and user Role in HttpSession object
inside JSF Backing Bean. My requirement is all my Spring beans perform
business logic based on userId and user Roles
- The reason i put question mark on HttpSession object is even within JSF
backing beans session is lost. For example i construct  session object in
LoginBean and when i try to retrieve session in other backing bean it
returns null. So i have to do something like this in the constructor of
backing bean
if(userSession == null){
		  System.out.println("Inside Manuf Constructor userSession");
	  userSession =
          (HttpSession)
FacesContext.getCurrentInstance().getExternalContext()
                                    .getSession(true);
	  Object sess = userSession.getAttribute("userId");
	  System.out.println("userId in Session="+sess.toString());
- Also the constructor of backing bean doesnt allow me to make a call Spring
bean and results in Null Pointer Exception. So not sure where exactly in the
backing bean i should make a call to getUserSession() method of Spring. For
test purposes i am making this call from register() method of backing bean
Overall i didnt have good success stories to share with by adopting this
approach. Any pointers/suggestions will be highly appreciated

Regards
Bansi
 


Kito D. Mann wrote:
> 
> Hello Bansi,
> 
> You can inject Spring beans into your JSF managed beans via the Spring
> DelegatingVariableResolver. Given that, you should be able to call your
> Spring bean methods and pass in the appropriate parameters. Why do your
> Spring beans need direct access to the session?
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Kito D. Mann (kmann@virtua.com)
> Author, JavaServer Faces in Action
> http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
> 
>> -----Original Message-----
>> From: bansi [mailto:mail2bansi@yahoo.com]
>> Sent: Thursday, May 17, 2007 12:22 PM
>> To: users@myfaces.apache.org
>> Subject: How to Share Session between JSF(MyFaces) and Spring
>> 
>> 
>> Hi Gurus
>> Could you please tell me
>> What are the best practices to  pass Session object from JSF to Spring.
>> For
>> example lets say  LoginBean in JSF has to store userId and userRole in
>> Session object and then pass Session object to Spring Layer so that it
>> can
>> be accessible by any spring bean
>> 
>> - Do you recommend using Httpsession?
>> 
>> - Does OpenSessionInViewFilter provides a mechanism to store userId &
>> userRole in session & then pass it onto spring layer
>> 
>> OR
>> 
>> - Is their any other mechanism that you would recommend for storing
>> userId &
>> userRoles into Session object at JSF Layer and then retrieve the same
>> Session object at Spring layer so that it can be accessible by an
>> spring
>> bean
>> 
>> Any pointers/suggestions will be highly appreciated
>> 
>> Regards
>> Bansi
>> 
>> --
>> View this message in context: http://www.nabble.com/How-to-Share-
>> Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10667077
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-Share-Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10669495
Sent from the MyFaces - Users mailing list archive at Nabble.com.


RE: How to Share Session between JSF(MyFaces) and Spring

Posted by Jan-Kees van Andel <jk...@planet.nl>.
Hi Bansi,

Personally, I would only pass the userId and userRole (and probably other
properties), but definitely not the Managed Bean itself. It's no problem for
the Managed Bean to know the Spring Bean, but the other way around (Spring
Bean knowing the JSF Managed Bean) is a situation I in almost all cases
don't want.

By the way, I'm assuming you're Spring Beans perform some kind of business
logic

Greets,

Jan-Kees

-----Oorspronkelijk bericht-----
Van: Kito D. Mann [mailto:kmann@virtua.com] 
Verzonden: donderdag 17 mei 2007 19:43
Aan: 'MyFaces Discussion'
Onderwerp: RE: How to Share Session between JSF(MyFaces) and Spring

Hello Bansi,

You can inject Spring beans into your JSF managed beans via the Spring
DelegatingVariableResolver. Given that, you should be able to call your
Spring bean methods and pass in the appropriate parameters. Why do your
Spring beans need direct access to the session?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kito D. Mann (kmann@virtua.com)
Author, JavaServer Faces in Action
http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info

> -----Original Message-----
> From: bansi [mailto:mail2bansi@yahoo.com]
> Sent: Thursday, May 17, 2007 12:22 PM
> To: users@myfaces.apache.org
> Subject: How to Share Session between JSF(MyFaces) and Spring
> 
> 
> Hi Gurus
> Could you please tell me
> What are the best practices to  pass Session object from JSF to Spring.
> For
> example lets say  LoginBean in JSF has to store userId and userRole in
> Session object and then pass Session object to Spring Layer so that it
> can
> be accessible by any spring bean
> 
> - Do you recommend using Httpsession?
> 
> - Does OpenSessionInViewFilter provides a mechanism to store userId &
> userRole in session & then pass it onto spring layer
> 
> OR
> 
> - Is their any other mechanism that you would recommend for storing
> userId &
> userRoles into Session object at JSF Layer and then retrieve the same
> Session object at Spring layer so that it can be accessible by an
> spring
> bean
> 
> Any pointers/suggestions will be highly appreciated
> 
> Regards
> Bansi
> 
> --
> View this message in context: http://www.nabble.com/How-to-Share-
> Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10667077
> Sent from the MyFaces - Users mailing list archive at Nabble.com.


RE: How to Share Session between JSF(MyFaces) and Spring

Posted by "Kito D. Mann" <km...@virtua.com>.
Hello Bansi,

You can inject Spring beans into your JSF managed beans via the Spring
DelegatingVariableResolver. Given that, you should be able to call your
Spring bean methods and pass in the appropriate parameters. Why do your
Spring beans need direct access to the session?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kito D. Mann (kmann@virtua.com)
Author, JavaServer Faces in Action
http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info

> -----Original Message-----
> From: bansi [mailto:mail2bansi@yahoo.com]
> Sent: Thursday, May 17, 2007 12:22 PM
> To: users@myfaces.apache.org
> Subject: How to Share Session between JSF(MyFaces) and Spring
> 
> 
> Hi Gurus
> Could you please tell me
> What are the best practices to  pass Session object from JSF to Spring.
> For
> example lets say  LoginBean in JSF has to store userId and userRole in
> Session object and then pass Session object to Spring Layer so that it
> can
> be accessible by any spring bean
> 
> - Do you recommend using Httpsession?
> 
> - Does OpenSessionInViewFilter provides a mechanism to store userId &
> userRole in session & then pass it onto spring layer
> 
> OR
> 
> - Is their any other mechanism that you would recommend for storing
> userId &
> userRoles into Session object at JSF Layer and then retrieve the same
> Session object at Spring layer so that it can be accessible by an
> spring
> bean
> 
> Any pointers/suggestions will be highly appreciated
> 
> Regards
> Bansi
> 
> --
> View this message in context: http://www.nabble.com/How-to-Share-
> Session-between-JSF%28MyFaces%29-and-Spring-tf3772789.html#a10667077
> Sent from the MyFaces - Users mailing list archive at Nabble.com.