[opencms-dev] Opencms with Spring

Steve Bryan steve at bright-interactive.com
Fri Oct 1 13:36:36 CEST 2010


Hi Jacek & all

It is easy to access data from Spring in OpenCms JSP/Java code - just put
the data generated by Spring beans in pageContext. You can use Spring as the
controller then forward to OpenCms servlet urls as the view.

I think the key issue is that OpenCms doesn't put anything useful in
HttpSession by default, so it doesn't work the other way round. So when your
spring controller code is running it can't access the OpenCms API,
specifically the CmsObject which is the gateway to OpenCms data. 

The link I sent previously
http://lists.opencms.org/pipermail/opencms-dev/2009q3/032699.html discusses
how you could create a suitably initialised CmsObject (actually initialised
from the HttpSession), and make that available to Spring controllers.

At the time there was no static OpenCms method available for getting the
initialised CmsObject, so the article discusses adding such a method to the
core. This could then be called by a filter for example, and put in request
scope so the spring code can get at it.

I hope I'm talking sense here?

Steve


-----Original Message-----

Date: Thu, 30 Sep 2010 16:47:24 +0100
From: "jacek grzebyta (RRes-Roth)" <jacek.grzebyta at bbsrc.ac.uk>
Subject: Re: [opencms-dev] R?f. :  Opencms with Spring
To: The OpenCms mailing list <opencms-dev at opencms.org>
Message-ID:
	
<CAA01648FEB55745AA24C694DA91D0A20192C73CA7 at rothexch1.rothamsted.bbsrc.ac.uk
>
	
Content-Type: text/plain; charset="utf-8"

Hi again 2,

I?ve just found in PageContext  method getServletContext() so I guess this
is what we need to do that. Also I found in HttpSession :? Session
information is scoped only to the current web application (ServletContext)?
so it means that cms and sprig share the same session IMHO if they are in
the same web application.

Jacek

*******************************************




More information about the opencms-dev mailing list