petrus
petrus

Reputation: 31

Spring MVC Portlet: Accessing beans from portlet context in root context

It is possible to access a portlet context bean from root application context in spring mvc portlet?

Upvotes: 1

Views: 1521

Answers (2)

Ritesh
Ritesh

Reputation: 7522

If publishContext property of DispatcherPortletis true (default value) then you can get portlet appcontext from javax.portlet.PortletContext as:

ApplicationContext otherPortletContext = portletContext.getAttribute(FrameworkPortlet.PORTLET_CONTEXT_PREFIX + otherPortletName);

then use bean of other portlet Context as: portletBean = otherPortletContext.getBean(beanName, beanClass);

Note that you can get javax.portlet.PortletContext object by implementing PortletContextAware.

Upvotes: 1

skaffman
skaffman

Reputation: 403481

No, you cannot reach "down" like that. Portlet/servlet beans can see beans in the root context, but not the other way around.

Upvotes: 0

Related Questions