I am trying to write a front end site with GWT and want to use the Konakart shopping cart api on the back-end as rpc calls from my web front end. I don't see anywhere where this is specified how I need to get things setup, i.e. what jars to include.
Basically I just want to be able to call all the api soap services through the GWT rpc asynchronous interface. Any help would be appreciated.
Thanks.
Greg
Hi Greg,
This is a great idea - I wish you every success with this idea and will look forward to seeing the results - please let us know when you've finished.
What I would do is create a layer of your own that receives the asynchronous calls from the GWT client and calls the KonaKart APIs (using SOAP or directly in java).
Regards,
Heidi
Hi KonaKarts,
I worked through the basics and more features of googles StockWatcher tutorial and now I will start to use gwt for konakart frontends. Onepagecheckout is embedded gwt in struts. Is this a good entrypoint;-) for me as gwt newbie to start with a complete frontend. How is the way from struts to gwt? How can I simple replace the struts actions by gwt procedure calls, if possible? Many newbie questions, I try to start with the ui. Help would be nice. regards, rula
It rather depends what you want to achieve. For minor additions to the jsp version you could use techniques as used in the one-page-checkout. See gwt references in:
MainLayout.jsp: <meta name='gwt:module' content='com.konakart.Konakart'>
OnePageCheckoutBody.jsp:<script language="javascript" src="gwt.js"></script>
Also look at CheckoutDeliveryAction.java
Also, note the web.xml servlet definition for this:
<!-- Servlet for GWT code -->
<servlet>
<servlet-name>KonakartGWTServlet</servlet-name>
<display-name>KonaKart GWT App</display-name>
<description>KonaKart GWT App</description>
<servlet-class>com.konakart.server.KKGWTServiceImpl</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>
Also, you could use the documentation at http://www.konakart.com/javadoc/struts_doc/index.html to help you understand the Struts configuration.
A new Google Group (http://groups.google.com/group/konakart) has been created that is dedicated to creating open source store fronts using different technologies. It may well use GWT as the client technology but this is not yet decided.
Hi ming,
I want to achieve a complete but small and simple gwt frontend.
My entrypoint could be the mail sample in googles gwt 1.5 doc.
First I try to create the ui with panels, widgets and listeners and use hardcoded data like in the mail sample too. Then I try to get the data from the clientEngine over RPC (is it correct!?). It would be not so easy for me, but little by little I recognize the possibilities of gwt.
When starts your new google group probably with development of konakart frontends.
I am interessted but only a gwt newbie.
regards, rula
Hi,
It sounds like you're heading in the right direction. I would create a GWT service layer that your GWT client calls asynchronously. The GWT service layer can instantiate the KonaKart engines to call the APIs (via web services, or direct java calls).
The Google Group has started a discussion on the technology that should be used to build the first client. Once that's decided, work will get underway, but I don't know when exactly.
Regards - Ming
Hi KonaKarts,
I think it should be possible to run your onepagecheckout kit in a gwt application without struts but I don't
no in details what I have to do, to reach this. Okay, I could remove struts specific parts and I have to add a GWT servlet and mapping like in konakart. But than I am at the end with my knowhow. Would the rpc mechanism also work ? In moduleLoad methode of the Konakart entryPointClass theres controller logic with states and actions. Is it a good way to use all these things? regards, rula
The one page checkout app is a GWT application which just happens to be embedded within a Struts app and doesn't rely on struts in any way (i.e. it runs in GWT hosted mode without struts). KKGWTServiceImpl is the class that acts as an interface between GWT and KonaKart, so you may want to take a look at it.
QuoteIn moduleLoad methode of the Konakart entryPointClass theres controller logic with states and actions. Is it a good way to use all these things?
The reason for such an implementation is to keep the decisional logic all in one place (similar to struts) but without having the luxury of a struts like framework for GWT.
Hi julie,
when I run my konakart gwt app in hosted mode it throws the following exception.
Why org/apache/struts/action/Action?
regards rula
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/apache/struts/action/Action
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.access$100(Unknown Source)
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
com.konakart.al.KKAppEng.<init>(Unknown Source)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.konakart.server.KKGWTServiceImpl.<init>(KKGWTServiceImpl.java:149)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.google.gwt.dev.shell.GWTShellServlet.tryGetOrLoadServlet(GWTShellServlet.java:953)
com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:278)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
If you look at the source code you'll see that it uses a struts action at the points where the GWT application has to give control back to the stuts application. i.e. redirect("ShowCartItems.do");
Hi julie,
I commented out all the struts redirects in the client sources and the exception remaitds. I searched all the gwt sources and I cannot find the cause. After all, in my desperation, I added the struts.jar and the exception disappears. Have you a idea?
Now I see LoginBody in hosted mode, thats a small progress for me.
I get lost in konakart gwt, the advantage of all these is that I have now an small overview about these things konakarts have done for the gwt frontend. I understand nothing, but I think it's really good, and I will use all your groundwork.
The communication seems to work. Now I will start with the Welcome page, so I build the page with panels and widgets in the manner of konakart, add the required rpc calls and extend the controller. Is this a good way? Have I to note something special because this app is not father embedded in struts?
Having taken a closer look at your exception, it is the initialization of com.konakart.al.KKAppEng that is looking for Struts. In theory you could develop a GWT front end that connects just to the server engine KKEng (similar to the way that the Admin App works).
Since in the application we are using the GWT code just for the checkout, it made a lot more sense to use KKAppEng since this is being used by the Struts application and it contains some session state.
Hi julie,
do you think that the connection to the KKEng ist clearer than to the KKAppEng? In this case, KKGWTServiceImp have to instatiate a KKEng engine. This could be configured in the properties files and have to changed in the sourcecode of KKGWTServiceImp? Too heavy stuff for me! I will stay in KKAppEng altough perhaps KKEng is clearer.
regards, rula
If you want some really loose coupling, you could even use the SOAP interface :)
Hi julie,
I can't get debug logs from KKGWTServiceImpl in hosted mode to the eclipse consol.
I always get: Should only see this message in debug mode.
Settings in the property files of konakart,konakartadmin and in the classpath of the eclipse project.
# Konakart classes
log4j.logger.com.konakart = DEBUG
log4j.logger.com.konakartadmin = DEBUG
# KonaKart Client Logging
log4j.logger.com.konakart.clientlogging = DEBUG
I need log infos from serverside too. Can you give me a tip? regards, rula
Sorry julie,
there could be another problem, i have to check it first, you don't have to answer at the moment.
regards, rula
Hi julie,
hm, I can't recognize the cause, one tip would be fine. regards, rula
Hi Konakarts,
what is wrong with this rpc? Only somtimes I get a result?
1. public GWT_Category[] getCats() throws KKGWTException;
2. public void getCats(AsyncCallback callback);
3. public GWT_Category[] getCats() throws KKGWTException
{
if(log.isDebugEnabled()){
log.debug("getCats");
}
try
{
KKAppEng appEng = getAppEng();
appEng.getCategoryMgr().reset();
CategoryIf[] serverCats = appEng.getCategoryMgr().getCats();
//CategoryIf[] serverCats = appEng.getEng().getCategoryTree(-1, true);
if (serverCats == null)
{
return null;
}
GWT_Category[] clientCats = new GWT_Category[serverCats.length];
for (int i = 0; i < serverCats.length; i++)
{
CategoryIf serverCat = serverCats[i];
GWT_Category clientCat = helper.getGWT_Category(serverCat);
clientCats[i] = clientCat;
}
return clientCats;
} catch (Exception e)
{
throw new KKGWTException(getExceptionMessage(e));
}
}
4. getKK().getMyKKGWTService().getCats(getCatsCallback);
regards, rula
Hi julie,
I think I have found my failure.
In onModuleLoad before login I can only get data from the serverEngine and not from the clientEngine.
This have nothing to do with the callbacks. I have made the same mistake in struts at the beginning;-(
Tell me if I am wrong, otherwise it's okay. Regards, rula.
Hi KonaKarts,
thanks for your fine severside untility classes KKBeanCopierBase, KKBeanCopier and KKGWTServiceImpl!
My gwt app throws exception: java.lang.StackOverflowError
in methode getCategoryTree of class KKGWTServiceImpl.
public GWT_Category[] getCategoryTree() throws KKGWTException
{
try
{
KKAppEng appEng = getAppEng();
CategoryIf[] serverCategorys = appEng.getEng().getCategoryTree(-1, true);
if (serverCategorys == null)
{
return null;
}
GWT_Category[] clientCategorys = new GWT_Category[serverCategorys.length];
for (int i = 0; i < serverCategorys.length; i++)
{
CategoryIf serverCategory = serverCategorys[i];
GWT_Category clientCategory = helper.getGWT_Category(serverCategory);
clientCategorys[i] = clientCategory;
}
return clientCategorys;
} catch (KKException e)
{
throw new KKGWTException(getExceptionMessage(e));
}
}
If I comment
client.setParent(getGWT_Category(server.getParent()));
server.setParent(getCategoryIf(client.getParent()));
there is no exception.
What's my mistake in the use of the helper methode getGWT_Category? Regards, rula.
[WARN] StandardContext[]Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.konakart.client.app.GWT_Category[] com.konakart.client.KKGWTServiceIf.getCategoryTree() throws com.konakart.client.util.KKGWTException' threw an unexpected exception: java.lang.StackOverflowError
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:360)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:546)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:163)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:290)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
Caused by: java.lang.StackOverflowError: null
at com.konakart.server.KKBeanCopier.getGWT_Category(KKBeanCopier.java:347)
at com.konakart.server.KKBeanCopier.getGWT_Category(KKBeanCopier.java:337)
The categories from getcategoryTree() are returned as a tree structure and so you should use recursion to traverse the tree. This is what our helper method looks like :
protected GWT_AdminCategory getClientCategory(AdminCategory serverCat)
throws IllegalAccessException, InvocationTargetException
{
if (serverCat == null)
{
return null;
}
GWT_AdminCategory clientCat = new GWT_AdminCategory();
// Recurse the children
if (serverCat.getChildren() != null)
{
GWT_AdminCategory[] clientChildren = new GWT_AdminCategory[serverCat.getChildren().length];
for (int i = 0; i < serverCat.getChildren().length; i++)
{
AdminCategory serverChild = serverCat.getChildren();
clientChildren = getClientCategory(serverChild);
}
clientCat.setChildren(clientChildren);
}
// Get the descriptions
if (serverCat.getDescriptions() != null)
{
GWT_AdminCategoryDescription[] clientCatDescs = new GWT_AdminCategoryDescription[serverCat
.getDescriptions().length];
for (int i = 0; i < serverCat.getDescriptions().length; i++)
{
AdminCategoryDescription serverCatDesc = serverCat.getDescriptions();
clientCatDescs = getClientCategoryDescription(serverCatDesc);
}
clientCat.setDescriptions(clientCatDescs);
} else
{
clientCat.setDescriptions(null);
}
clientCat.setId(serverCat.getId());
clientCat.setImage(serverCat.getImage());
clientCat.setName(serverCat.getName());
clientCat.setNumberOfProducts(serverCat.getNumberOfProducts());
clientCat.setParentId(serverCat.getParentId());
clientCat.setSortOrder(serverCat.getSortOrder());
clientCat.setCustom1(serverCat.getCustom1());
clientCat.setCustom2(serverCat.getCustom2());
clientCat.setCustom3(serverCat.getCustom3());
return clientCat;
}
Hi KonaKarts,
my konakart gwt app should use imageBundles, in hosted mode all seems ok, but in web mode in IE the images are not displayed, in firefox there is no problem. In IE I see nothing (only clear.cache.gif in the place of the expected image). O.K., onePageCheckout not works with imageBundles, but perhaps adminApp. Could this be a caching problem in the gwt tomcat or the IE? Regards, rula
Hi KonaKarts,
now localized imageBundles are displayed correct in IE7 with default security settings. ;)
Sorry, regards rula.
Thanks for the update. I looked but couldn't see any problem...
--Brian
Hi KonaKarts,
how can I fill member variables with callback results?
In WelcomeBody I have:
private GWT_Product[] products;
/**
* Get the products
*/
AsyncCallback getAllProductsCallback2 = new KKCallback(this)
{
@Override
public void onSuccess(Object result) {
GWT.log("getAllProductsCallback2Succeeded.1", null);
allProducts2 = (GWT_Products) result;
if (allProducts2 != null){
GWT.log("allProducts2.getTotalNumProducts.1: " + allProducts2.getTotalNumProducts(), null);
products = allProducts2.getProductArray(); ...
Hi KonaKarts,
second warm-up ;),
how can I fill member variables with callback results?
In WelcomeBody I have:
private GWT_Product[] products;
/**
* Get the products
*/
AsyncCallback getAllProductsCallback2 = new KKCallback(this)
{
@Override
public void onSuccess(Object result) {
GWT.log("getAllProductsCallback2Succeeded.1", null);
allProducts2 = (GWT_Products) result;
if (allProducts2 != null){
GWT.log("allProducts2.getTotalNumProducts.1: " + allProducts2.getTotalNumProducts(), null);
products = allProducts2.getProductArray(); ...
Here products is filled
getKK().getMyKKGWTService().getAllProducts(getAllProductsCallback2);
GWT.log("products: " + products, null);
Here products isn't filled
If I fill widgets with the results all seems to be o.k. but if I use member variables the values get lost. Please, where is my problem?
Regards, rula
I don't understand your problem - because it doesn't make any sense to me. Are you sure your variables are in scope when you check them? Have you investigated this by stepping through the debugger?
--Brian
Hi Brian,
Quote
I don't understand your problem - because it doesn't make any sense to me.
Ups, I will only navigate through the products array with first, previous, next, last buttons and process the array in seperate methods. First I return the array with one single callback, and then I view the selected products according the navigation buttons. How and where would you do this?
Quote
Are you sure your variables are in scope when you check them? Have you investigated this by stepping through the debugger?
I have debugged and inside of the callback methode the products variable is correct filled by the result and after the callback it is null.
Regards, rula
Hi Brian,
it seems to work if I do all these things direct in the onSuccess methode of the callback object. Regards, rula
Hi KonaKarts,
here the welcome page of my konakart gwt frontend.
http://www.ruladev.de/konakart1gwt/Konakart.html (http://www.ruladev.de/konakart1gwt/Konakart.html)
Thanks all KonaKardians for the good groundwork in onePageCheckout. ;)
Regards, rula
Well done Rula... It's coming along very nicely.
--Brian