Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 5685 invoked from network); 17 May 2007 18:15:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 May 2007 18:15:06 -0000 Received: (qmail 19707 invoked by uid 500); 17 May 2007 18:15:05 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 19663 invoked by uid 500); 17 May 2007 18:15:05 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 19652 invoked by uid 99); 17 May 2007 18:15:05 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 May 2007 11:15:05 -0700 X-ASF-Spam-Status: No, hits=0.9 required=10.0 tests=FORGED_YAHOO_RCVD,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 May 2007 11:14:58 -0700 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1HokUo-00014L-7P for users@myfaces.apache.org; Thu, 17 May 2007 11:14:38 -0700 Message-ID: <10669495.post@talk.nabble.com> Date: Thu, 17 May 2007 11:14:38 -0700 (PDT) From: bansi To: users@myfaces.apache.org Subject: RE: How to Share Session between JSF(MyFaces) and Spring In-Reply-To: <01fe01c798aa$d2fce5c0$78f6b140$@com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: mail2bansi@yahoo.com References: <10667077.post@talk.nabble.com> <01fe01c798aa$d2fce5c0$78f6b140$@com> X-Virus-Checked: Checked by ClamAV on apache.org 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.