OpenLaszlo’s javaRPC with Spring - workaround
as trying to manage Spring with javaRPC I came to a simple workaround:
public String passInteger(int i, HttpServletRequest request) {
try {
ServletContext servletContext = ((HttpServletRequest)request).getSession().getServletContext();
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
TestService serviceClass = (TestService) context.getBean(”testService”);
System.out.println(”serviceClass: “+serviceClass);
return “got integer parameter: ” + serviceClass.doTest();
} catch (Exception err) {
err.printStackTrace();
}
return “-1″;
}
while testService is a defined Bean in your application-Context.xml
of couse it would be better to directly manage OpenLaszlo javaRPC .. or to inject the dependencies with Spring into the Classes but I didn’t manage to do so.
**********
Update:
Starting with r13070 in trunk you can access the HTTPServletContext through the javaRPC Method directly, see
http://openlaszlo.org/svn/openlaszlo/trunk/WEB-INF/classes/examples/javarpc/CustomMapping.java