• Welcome to KonaKart Community Forum. Please login or sign up.
 

Integration with GWT front-end

Started by haaking, May 07, 2008, 04:17:41 pm

Previous topic - Next topic

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

rula

Hi julie,
hm, I can't recognize the cause, one tip would be fine. regards, rula

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


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.

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)

pete

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;
    }

rula

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

rula

Hi KonaKarts,
now localized imageBundles are displayed correct in IE7 with default security settings. ;)
Sorry, regards rula.

Brian

Thanks for the update.   I looked but couldn't see any problem...
--Brian

rula

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(); ...



rula

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

Brian

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

rula

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

rula

Hi Brian,

it seems to work if I do all these things direct in the onSuccess methode of the callback object. Regards, rula

rula

Hi KonaKarts,

here the welcome page of my konakart gwt frontend.
http://www.ruladev.de/konakart1gwt/Konakart.html
Thanks all KonaKardians for the good groundwork in onePageCheckout. ;)

Regards, rula