Regd integration.
Approach we took was:
ofbiz does not have GWT native RPC support but it can do JSON and Http/XML more
easily.
Use http/JSON RPC instead of GWT Native RPC + GWT serialization.
Regd getting LocalServiceDispacher
You should be able to do:
LocalDispatcher dispatcher = (LocalDispatcher)
request.getAttribute("dispatcher");
result = dispatcher.runSync(...)
LocalDispatcher is set in ControlServlet.
ControlServlet is in each web.xml
<servlet>
<servlet-name>ControlServlet</servlet-name>
<display-name>ControlServlet</display-name>
<description>Main Control Servlet</description>
<servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ControlServlet</servlet-name>
<url-pattern>/control/*</url-pattern>
</servlet-mapping>
Note Load on startup and that your URLS will have /control/ i.e. loading
ControlServlet.
Make sure your control servlet is loaded or look at how ofbiz is setting things
in ControlServlet. Perhaps override if you cannot use ControlServlet
configuration as is.
Harmeet
----- Original Message -----
From: "Gintare Ragaisiene" <[email protected]>
To: [email protected]
Sent: Monday, July 20, 2009 3:11:32 AM GMT -05:00 US/Canada Eastern
Subject: Ofbiz service call from GWT RPC
Hello,
I'm working on tintegration GWT into ofbiz. GWT compiled js files is
placed into ofbiz "images" component in order ftl access them:
gwt_test.ftl
<script type="text/javascript" language="javascript"
src="/images/gwttest1/gwttest1.nocache.js"></script>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your
name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
</table>
Then I access GWT RPC from javascript. For this I corrected "images"
component war, because javascrip searches for servlet with path
"/gwttest1/greet" :
framework/images/webapp/images/war.xml :
<web-app>
<display-name>Open For Business - demostore images</display-name>
<description>Demo Store Images for the Open For Business
Project</description>
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>org.ginsoftware.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/gwttest1/greet</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>1</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>main.jsp</welcome-file>
</welcome-file-list>
</web-app>
And I implemented servlet it self GreetingServiceImpl.java and classes
is put into images/WEB-INF :
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
public String greetServer(String input) {
//Haw to call ofbiz service ?
String serverInfo = getServletContext().getServerInfo();
String userAgent =
getThreadLocalRequest().getHeader("User-Agent");
return "Hello, " + input + "!<br><br>I am running " + serverInfo
+ ".<br><br>It looks like you are using:<br>" + userAgent;
}
}
Until now everything works fine and my question is how do I call ofbiz
service from greetServer() method ? I've tried obtain LocalServiceDispacher
in variuos ways, but no luck at all.
Or is there somebody who already did that integration in more convenient way
that me ?
Thanks,
Gintare