and cleaner way ! Good idea !
Thanks a lot.
On 8/27/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
or better yet, use a simple application factory and create your application object as a bean, make it context aware and you got a cleaner integration:public class SpringApplicationFactory implements IWebApplicationFactory
{public WebApplication createApplication(WicketServlet servlet)
{
ServletContext sctx=servlet.getServletContext();
WebApplicationContext wctx=WebApplicationContextUtils.getRequiredWebApplicationContext(sctx);
WebApplication app=(WebApplication)wctx.getBean("wicketApplication");
return app;
}}-Igor
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Igor Vaynberg
Sent: Friday, August 26, 2005 9:12 AM
To: wicket-user@lists.sourceforge.net
Subject: RE: [Wicket-user] Lookup Spring WebApplicationContextWhy not store the context in the application subclass?that way your final static Object getBean() can look like thisgetBean() { return ((MyAppSubclass)WebApplication.get()).getContext(); }-Igor
I have browsed Spring integration from Wicket-Stuff, but it is a little
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Ingram Chen
Sent: Friday, August 26, 2005 7:37 AM
To: wicket-user@lists.sourceforge.net
Subject: [Wicket-user] Lookup Spring WebApplicationContext
complex... I would like to use "direct" lookup from a super class Page:
public class BaseWebPage extends WebPage {
private static WebApplicationContext webApplicationContext;
protected final static Object getBean(String beanName) {
if (webApplicationContext == null) {
HttpServletRequest httpRequest = ((WebRequest) RequestCycle.get()
.getRequest()).getHttpServletRequest();
ServletContext servletContext = httpRequest.getSession()
.getServletContext();
webApplicationContext = RequestContextUtils
.getWebApplicationContext(httpRequest, servletContext);
if (webApplicationContext == null) {
throw new IllegalStateException(
"Spring Web Appliction Context is not ready");
}
}
return webApplicationContext.getBean(beanName);
}
}
subclass-Page just invoke getBean("myService") to obtain Spring
managed bean. It likes what ActionSupport does when integrating Struts with Spring,
and it works great (and easily) for our past Struts+Spring application.
Since programming style of wicket Page often consist various inner class or static inner class,
it would be helpful to declare webApplicationContext as "static". WebApplicationContext is a
"singleton" through the whole applicaiton life, so I guess this may work... but I still some
concern needs your help:
Does this violating any contract of wicket?
Is there any potential thread or clustering issues ?
--
Ingram Chen
Java [EMAIL PROTECTED]
Institue of BioMedical Sciences Academia Sinica Taiwan
blog: http://www.javaworld.com.tw/roller/page/ingramchen
--
Ingram Chen
Java [EMAIL PROTECTED]
Institue of BioMedical Sciences Academia Sinica Taiwan
blog: http://www.javaworld.com.tw/roller/page/ingramchen