Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 5th Jun 2009, 06:33
bgoetzmann bgoetzmann is offline
Registered Developer
 
Join Date: Jun 2009
Posts: 29
Default SmartGWT in portlet

Hello,

I succeed to use a SmartGWT application in a JSR-286 portlet deployed in a JBoss Portal 2.7 instance.

This portlet simply displays a ListGrid with data fetched from a Grails backend application.
I just saw two problems related to CSS:

1. Using in others JQuery, JBoss Portal displays a login form that appeared under the grid; to resolve this I changed a JBoss JavaScript file that creates HTML elements with the z-index style property; now all works well.
2. The second problem I saw is related to the CSS style for HTML HR element used in the ListGrid contectual menu; it seems that the CSS styles used by JBoss Portal hides the HR separator.

I ask me if I can get other troubles with others UI controls; do other persons used Smarclient in a Portal environment? Or in situations where the GWT application is displayed in a part of an HTML page?

Thank you!

Bertrand.
Reply With Quote
  #2  
Old 17th Jun 2009, 01:11
bgoetzmann bgoetzmann is offline
Registered Developer
 
Join Date: Jun 2009
Posts: 29
Default

Hello,

I've done a lot progress on having portlet JSR-286 with SmartGWT as view technology, and also found a solution to have multiple instances of the same portlet on one web page under JBoss Portal.

But I ask me one thing about the loading of the GWT module; in case of multiple instances of the same portlet on the web page, I can have many "script" tag that load the same GWT module on the page.
For example, I can have 2 or 3 times:

<script language="javascript" src="portletCtx/com.lsy.clink.reports.Main/com.lsy.clink.reports.Main.nocache.js"></script>

I tested this on several web browser, and I see that the GWT module in loaded just one time.
So I search a confirmation to the fact there is some test on GWT module to authorize only one loading even there are multiple script tag for loading.

Any thought about this?

Cheers,

Bertrand.
Reply With Quote
  #3  
Old 17th Jun 2009, 06:44
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 38,398
Default

Not sure about an explicit check within GWT (that's more of a core GWT question than a SmartGWT question), but have you considered whther the browser is simplify caching the file and hence not downloading it again?

If you could share some of the steps and ideally some sample code for your portlet approach, it would definitely benefit others who are working on SmartGWT-based portlets.
Reply With Quote
  #4  
Old 17th Jan 2011, 10:11
labo labo is offline
Registered Developer
 
Join Date: Jan 2011
Posts: 2
Default

Hello,

I am currently evaluation the portlet development for a liferay portal (Version 6.0.5) and I like the functionality of smartGWT (2.2 or 2.4) but unfortunately I cannot get my portlet up and running. Is there an example or tutorial out there
(asking google without success) ? The portlet should be able to send a sql query to a database and display the result in a ListGrid.....

Thanks
Jörg
Reply With Quote
  #5  
Old 24th Jan 2011, 01:41
antoniodb antoniodb is offline
Registered Developer
 
Join Date: Jan 2011
Posts: 5
Default

Hello,

I've developed some portlet in liferay using SmartGWT, using a div-container as explained in

http://www.liferay.com/web/guest/com...let+in+Liferay.

To pass some information from the portlet to smartGWT (like actionURL, renderURL or resourceURL) I used a javascript Object in the portlet jsp:
Code:
<script type="text/javascript" language="javascript">
function getParamsPortlet()
{
        
        object=new Object();
        
        object.RUrl='<%=resUrl %>';
        object.AUrl='<%=actUrl %>';
        object.RendUrl='<%=rendUrl %>';
};
</script>
and in smartGWT I get the object
Code:
public class Params extends JavaScriptObject {
        protected Params() { }
        public final native String getRUrl()  /*-{ return this.RUrl;  }-*/;
        public final native String getRendUrl()  /*-{ return this.RendUrl;  }-*/;
        public final native String getAUrl()  /*-{ return this.AUrl;  }-*/;
        
}
Code:
public class MySmartGWTModule implements EntryPoint {
        
        private native static Params getParams() /*-{
                $wnd.getParams(); 
                return $wnd.object;
        }-*/;

        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
                
                final Params par=getParams();
...
        }
}
Everything worked fine with liferay 6 and smartGWT 2.1 and I was able to use different smartGWT portlets in the same page, but when I upgrade the smartGWT library to the 2.4, my portlet works only if there is no other smartGWT portlet on the page.
For example I put one smartGWT portlet in a page, the portlet loads and works fine; I put another smartGWT portlet in the same page and both are loaded and dispayed, but fetch operations don't work. I've got no errors in the developer console.
Can anybody help me, please?

Thanks

Antonio
Reply With Quote
  #6  
Old 24th Jan 2011, 10:29
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 38,398
Default

There's been no change that should have an effect like this.

Double checking everything about your upgrade, including that all .js files being delivered to the browser are from the new version and not mixed.

If that doesn't lead to a solution you will need to isolate it further (there's no a lot we can do with a report that fetch operations don't work).
Reply With Quote
  #7  
Old 26th Jan 2011, 02:00
antoniodb antoniodb is offline
Registered Developer
 
Join Date: Jan 2011
Posts: 5
Default

Thank you for your anwer,

I checked everything, I'm sure all files are from version 2.4.

I'll try to explain better my problem:
Every single portlet with a smartGWT module works well if it is alone in the page.

Let's say I put two portlets in the page;
Portlet n.1 has a textItem with a button and a listGrid. On button click, a request to a resourceURL is performed to fetch data for the listGrid;
Portlet n.2 has just one button doing nothing.

when I click on the button on portlet n.1 to fill the listGrid, I can see in firebug and in the developer console the request to my resourceURL and the response that I expect, but the listGrid continues to show "Loading data" and the page is blocked.

With Chrome I have a js error: "Class.js:1335 Uncaught RangeError: Maximum call stack size exceeded",

while in Opera I got

"Uncaught exception: RangeError: Maximum recursion depth exceeded
Error thrown at line 8, column 2956 in <anonymous function: $wnd.isc.RPCManager.fireReplyCallback>(b, c, d, e) in http://localhost:8080/Portlet/modulegwt/07A20FE63E416F169C25044AA5AF25A4.cache.html:
(e!=null&&$wnd.isc.isA.Number(e)||$wnd.isc.isA.Boolean(e))&&(e=d.data=$wnd.SmartGWT.convertToJavaType(e));
called from line 8, column 3062 in <anonymous function: $wnd.isc.RPCManager.fireReplyCallback>(b, c, d, e) in http://localhost:8080/Portlet/modulegwt/07A20FE63E416F169C25044AA5AF25A4.cache.html:
return this.__fireReplyCallback(b,c,d,e)"

Any idea?

Antonio
Reply With Quote
  #8  
Old 26th Jan 2011, 07:20
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 38,398
Default

You're still not putting us in a position to reproduce the error or really analyze it much - we don't know what DataSource type you're using or anything about the data being transferred.

All we can say right now is that this looks like it could be due to badly formatted data, or, you may have custom code that is going into an infinite loop as it tries to process the response.
Reply With Quote
  #9  
Old 27th Jan 2011, 00:26
antoniodb antoniodb is offline
Registered Developer
 
Join Date: Jan 2011
Posts: 5
Default

Ok, here is my code for both portlets and smartGWT modules:

portlet n.1
Code:
public class ZZZTest extends GenericPortlet {

        public void doView(RenderRequest request, RenderResponse response)
                        throws PortletException, IOException {

                String urlGWT=response.encodeURL(request.getContextPath()+"/zzzgwt/zzzgwt.nocache.js");
                request.setAttribute("urlGWT", urlGWT);
                String urlSmartGWT=response.encodeURL(request.getContextPath()+"/zzzgwt/sc/");
                request.setAttribute("urlSmartGWT", urlSmartGWT);
                
                PortletURL au=response.createActionURL();
                au.setParameter(ActionRequest.ACTION_NAME, "defName");
                String actUrl=au.toString();
                
                ResourceURL resUrl=response.createResourceURL();
                resUrl.setParameter("id", "defID");
                resUrl.setParameter("str", "defSTR");
                resUrl.setParameter("param1", "defParam1");
                String ru=resUrl.toString();
        
                PortletURL reu=response.createRenderURL();
                String rendUrl=reu.toString();
                
                request.setAttribute("actUrl",actUrl);
                request.setAttribute("resUrl",ru);
                request.setAttribute("rendUrl",rendUrl);
                
                response.setContentType("text/html");
                
            PortletRequestDispatcher dispatcher =getPortletContext().getRequestDispatcher("/WEB-INF/jsp/ZZZTest_view.jsp");
            dispatcher.include(request, response);
                
        }

        public void processAction(ActionRequest request, ActionResponse response)
                        throws PortletException, IOException {

        }
        public void serveResource(final ResourceRequest request, ResourceResponse response)
        throws PortletException, IOException {
                System.out.println("SERVE RESOURCE");
                response.setContentType("text/html");
                PrintWriter writer = response.getWriter();
                String list = "<response>" + "<status>0</status>"
                + "<startRow>0</startRow>" 
                + "<endRow>2</endRow>" 
                + "<totalRows>2</totalRows>" 
                + "<data>";
                list = list + "<record>";
                list = list + "<name>name1</name>";
                list = list + "<description>description1</description>";
                list = list + "</record>";
                list = list + "<record>";
                list = list + "<name>name2</name>";
                list = list + "<description>description2</description>";
                list = list + "</record>";
                list = list + "</data>" + "</response>";
                writer.println(list);
        }

}
and the jsp
Code:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%-- Uncomment below lines to add portlet taglibs to jsp--%>
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<portlet:defineObjects />
<%
        String gwtSource=(String) request.getAttribute("urlGWT");
        String urlSmartGWT=(String) request.getAttribute("urlSmartGWT");
        
        String resUrl=(String) request.getAttribute("resUrl");
        String actUrl=(String) request.getAttribute("actUrl");
        String rendUrl=(String) request.getAttribute("rendUrl");
        %>
<script type="text/javascript" language="javascript">
function getParamsP()
{
        
        object=new Object();
        
        object.RUrl='<%=resUrl %>';
        object.AUrl='<%=actUrl %>';
        object.RendUrl='<%=rendUrl %>';
        
};
</script>

<script type="text/javascript" language="javascript">var
isomorphicDir='<%=urlSmartGWT %>'</script>
<div id='id-port'></div>
<script type="text/javascript" language="javascript" src='<%=gwtSource %
>'><![CDATA[<!-- -->]]></script>
in smartGWT

Code:
public class ParamsP extends JavaScriptObject {
        protected ParamsP() { }
        
        public final native String getRUrl()  /*-{ return this.RUrl;  }-*/;
        public final native String getRendUrl()  /*-{ return this.RendUrl;  }-*/;
        public final native String getAUrl()  /*-{ return this.AUrl;  }-*/;
}
Code:
public class ZZZGWT implements EntryPoint {
        
        private native static ParamsP getParamsP() /*-{
        $wnd.getParamsP(); 
        return $wnd.object;
        }-*/;
        
        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
                final ParamsP par=getParamsP();
                VLayout layout=new VLayout();
                
                RestDataSource restDS=new RestDataSource();
                DataSourceTextField idField = new DataSourceTextField("id");  
                idField.setHidden(true);  
                idField.setPrimaryKey(true); 
                DataSourceTextField name=new DataSourceTextField("name", "name");
                DataSourceTextField description=new DataSourceTextField("description", "description");
                restDS.setFields(idField,name,description);
                
                final ListGrid lg=new ListGrid();
                ListGridField lgName=new ListGridField("name");
                ListGridField lgDescription=new ListGridField("description");
                lg.setFields(lgName,lgDescription);
                
                restDS.setDataURL(par.getRUrl());
                lg.setDataSource(restDS);
                
                IButton ok=new IButton("ok");
                ok.addClickHandler(new ClickHandler() {
                        
                        @Override
                        public void onClick(ClickEvent event) {
                                lg.fetchData();
                                
                        }
                });
                layout.addMember(lg);
                layout.addMember(ok);
                RootPanel.get("id-port").add(layout);
                
        }
}
Portlet n.2

Code:
public class YYYTest extends GenericPortlet {

        public void doView(RenderRequest request, RenderResponse response)
                        throws PortletException, IOException {

                String urlGWT=response.encodeURL(request.getContextPath()+"/yyygwt/yyygwt.nocache.js");
                request.setAttribute("urlGWT", urlGWT);
                String urlSmartGWT=response.encodeURL(request.getContextPath()+"/yyygwt/sc/");
                request.setAttribute("urlSmartGWT", urlSmartGWT);
                
                response.setContentType("text/html");
                
            PortletRequestDispatcher dispatcher =getPortletContext().getRequestDispatcher("/WEB-INF/jsp/YYYTest_view.jsp");
            dispatcher.include(request, response);
                
        }


        public void processAction(ActionRequest request, ActionResponse response)
                        throws PortletException, IOException {

        }
}
JSP:
Code:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%-- Uncomment below lines to add portlet taglibs to jsp--%>
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<portlet:defineObjects />
<%
        String gwtSource=(String) request.getAttribute("urlGWT");
        String urlSmartGWT=(String) request.getAttribute("urlSmartGWT");
%>

<script type="text/javascript" language="javascript">var
isomorphicDir='<%=urlSmartGWT %>'</script>
<div id='id-port2'></div>
<script type="text/javascript" language="javascript" src='<%=gwtSource %
>'><![CDATA[<!-- -->]]></script>
and the smartGWT module
Code:
/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class YYYGWT implements EntryPoint {
        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
                VLayout layout=new VLayout();
                IButton ok=new IButton("ok");
                ok.addClickHandler(new ClickHandler() {
                        
                        @Override
                        public void onClick(ClickEvent event) {
                                SC.say("OK");
                        }
                });
                layout.addMember(ok);
                RootPanel.get("id-port2").add(layout);
        }
}
SmartGWT modules are created using the GWT plugin for eclipse, then I add the smartgwt.jar version 2.4 to the project and
<inherits name="com.smartgwt.SmartGwt" />
in the xml.

My platform : Liferay 6.0.4 Bundled with tomcat 6.0.26, Smartgwt 2.4, Google Web Toolkit SDK 2.1.1 and Gwt plugin for eclipse3.5 v1.4.2 , Eclipse 3.5.

I hope it's more accurate and that you can find some explanation to help me.

Thanks.

Antonio
Reply With Quote
  #10  
Old 1st Feb 2011, 08:06
antoniodb antoniodb is offline
Registered Developer
 
Join Date: Jan 2011
Posts: 5
Default

Hi,
did anybody sort out my problem? Is there some problem in my code?
Or maybe you need some more information?

Thank you.

Antonio
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved