GWT Portlets on Liferay

458 views
Skip to first unread message

cleanfamilyboy

unread,
Dec 6, 2007, 2:12:55 AM12/6/07
to Google Web Toolkit
Hi all;

I want to develop portlets on GWT and integrate them into Liferay.

I cannot find a tutorial that explains the steps to develop a simple
portlet in GWT and run on Liferey.
I also searched the messages in this group but I cannot find enough
clues.

This site "www.xxxxx.com" has the demo project that I want. What a
pity, they don't give source code and no explenations about
development.

If you have a "hello word" sample that was developed on GWT as portlet
and runs when it is deployed on Liferay.
Also I want to solve its logic so I need a tutorial that describes how
to develop GWT portlets for Liferay.

Thank you to people that I took their worthy time for reading this
message...

cleanfamilyboy

unread,
Dec 6, 2007, 2:15:16 AM12/6/07
to Google Web Toolkit

On 6 Aralık, 09:12, cleanfamilyboy <emresu...@gmail.com> wrote:
> Hi all;
>
> I want to develop portlets on GWT and integrate them into Liferay.
>
> I cannot find a tutorial that explains the steps to develop a simple
> portlet in GWT and run on Liferey.
> I also searched the messages in this group but I cannot find enough
> clues.
>
> This site "www.xxxxx.com" has the demo project that I want. What a

This site "www.xxxxx.com" is http://biancashouse.com :)

cleanfamilyboy

unread,
Dec 6, 2007, 10:56:05 AM12/6/07
to Google Web Toolkit
Is there a helpful developer in here?
Please give a hand?

I am very tired and have an headache.

mooreds

unread,
Dec 6, 2007, 11:14:31 AM12/6/07
to Google Web Toolkit
Hi,

Complaining about not getting help when people are giving you
information for free is not very polite. I'm sure you could post an
offer to hire someone to write a tutorial for you, or help you with
your project, and you'd get a better response.

However, you're tired, so I'll cut you some slack.

I visited biancashouse.com, but wasn't able to view their tutorial.

I have just examined the tutorial here http://wiki.liferay.com/index.php/How_to_create_a_simple_portlet
and it seems like it would be possible to comple the GWT code
separately, and then place it into the war file mentioned in step 9.
To access it, you'd put the html that called the nocache.js into what
is written out in step 3.

I'm not sure how RPC would work, but that's how I'd do a 'hello world'
with GWT in Liferay.

Good luck.
Dan

cleanfamilyboy

unread,
Dec 7, 2007, 3:38:46 AM12/7/07
to Google Web Toolkit
Firstly I want to thank to you for your answer,

I think I cannot explain my problem.

I have already done these things...
They also put a sample in this place :
http://kent.dl.sourceforge.net/sourceforge/lportal/sample-jsp-portlet-4.3.3.1.war
I am using this portlet.

I also create a sample GWT application with these commands;
applicationCreator com.mycompany.client.MyApplication
applicationCreator -eclipse MyProject
com.mycompany.client.MyApplication

Now I have two application.
My GWT application produces a hello.html
My Liferay has a view.jsp

I want to combine these two project.
I drag & drop my GWT application to sample-jsp-portlet application.

So the question is this;
How to call hello.html in view.jsp?

I try this...
I wrote these line to view.jsp
<%@ include file="/www/com.cs.sample/hello.html" %>

My view.jsp appears like
-------------------------------------
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ include file="/www/com.cs.selam/selam.html" %>

And I take .war of these combined project and deploy to Liferay.
When I run Liferay on server, it shows a portlet and not shows
hello.html in it without giving an error message.


On 6 Aralık, 18:14, mooreds <moor...@gmail.com> wrote:
> Hi,
>
> Complaining about not getting help when people are giving you
> information for free is not very polite. I'm sure you could post an
> offer to hire someone to write a tutorial for you, or help you with
> your project, and you'd get a better response.
>
> However, you're tired, so I'll cut you some slack.
>
> I visited biancashouse.com, but wasn't able to view their tutorial.
>
> I have just examined the tutorial herehttp://wiki.liferay.com/index.php/How_to_create_a_simple_portlet

gregor

unread,
Dec 7, 2007, 9:03:22 AM12/7/07
to Google Web Toolkit
Check out a couple of links about this:

http://xantorohara.blogspot.com/2007/07/portlets-and-gwt.html
http://ddwiki.di.uoa.gr/mediawiki/index.php/Developing_Portlets_with_GWT

The basic principle is:

1) you add the necessary GWT tags to your portlet jsp file - look at
any of the GWT sample html files to see what these are
2) you create a unique tag in the portlet JSP into which your GWT main
application widget will be inserted
3) in onModuleLoad() call RootPanel.get(the unique tag).add(your GWT
app widget)

bear in mind that your GWT apps may not easily access things like
current user and session data from the portal, and that you may run
into screen sizing issues. Liferay is really a product as opposed to a
development platform, so you may find it easier to do this with
something like the JBoss portal, unless particular Liferay features
are important to you in which case good luck.

Regards
Gregor



On Dec 7, 8:38 am, cleanfamilyboy <emresu...@gmail.com> wrote:
> Firstly I want to thank to you for your answer,
>
> I think I cannot explain my problem.
>
> I have already done these things...
> They also put a sample in this place :http://kent.dl.sourceforge.net/sourceforge/lportal/sample-jsp-portlet...

cleanfamilyboy

unread,
Dec 8, 2007, 12:28:41 PM12/8/07
to Google Web Toolkit
Hi gregor;

Before opening this topic I made a deeply search in google.
In this link :
http://groups.google.com/group/Google-Web-Toolkit/browse_frm/thread/9314594efa78a71a/a7c750e337291ff3?lnk=gst&q=xantorohara#a7c750e337291ff3
a member of the group had gave http://xantorohara.blogspot.com/2007/07/portlets-and-gwt.html
as link, and the other some topics n this group the link had been
given, namely it is very popular. So I had read these article before.
It helped a little to me.

I had also read http://ddwiki.di.uoa.gr/mediawiki/index.php/Developing_Portlets_with_GWT

And I take care to your warnings about the principle. There is no
problem about it.

My GWT application produces a html file, it is below;

Hello.html
------------------------
<html>
<head>

<title>Wrapper HTML for Hello</title>

<style>
body,td,a,div,.p{font-family:arial,sans-serif}
div,td{color:#000000}
a:link,.w,.w a:link{color:#0000cc}
a:visited{color:#551a8b}
a:active{color:#ff0000}
</style>

<script language='javascript' src='com.cs.app.Hello.nocache.js'></
script>
</head>

<body>

<iframe src="javascript:''" id="__gwt_historyFrame" style="width:
0;height:0;border:0"></iframe>

<h1>Hello</h1>

<table align=center>
// Im my application slot1 and slot2 is
defined as "the unique tag" that you mentioned above
<tr>
<td id="slot1"></td><td id="slot2"></td>
</tr>
</table>
</body>
</html>

In my application there is a view.jsp file because of the Lİferay.

view.jsp
-------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-9"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

<!-- This line appears on Liferay -->
Hello <b>Liferay</b>.

<!-- This file is not appears on Liferay -->
<%@ include file="Hello.html" %>


****************************

Can you see, if there is nonsense things in these two file content?

I can deploy the application without a problem. But Hello.html that is
produced by GWT is not appears on Liferay. There is any error appears
on my console.

gregor

unread,
Dec 8, 2007, 11:13:54 PM12/8/07
to Google Web Toolkit
if the include statement found Hello.html should it not show
<title>Wrapper HTML for Hello</title> at least even if it didn't
manage to run the GWT app? If not it would suggest it is not being
found when the portlet view jsp is either being compiled or deployed.
I think a clue might be in the magic lines in the Xantothara example:

writer.println("<script language='javascript' src='" +
renderRequest.getContextPath() + "/xqx.web.xlam.XLam.nocache.js'></
script>"
writer.println("<div id='uid'></div>"); // in your case slot1, slot2
etc

I think what he's done here is to bypass the normal GWT html entry
file ( he marks that as dummy) and code the GWT js injection directly
into the portlet servlet, so maybe you can adapt this approach and
edit your view.jsp with these statements. In that case the trick would
be to find out what Liferay thought renderRequest.getContextPath()
was so you could make sure your js files etc are put in the right
place when you build your WAR.




On Dec 8, 5:28 pm, cleanfamilyboy <emresu...@gmail.com> wrote:
> Hi gregor;
>
> Before opening this topic I made a deeply search in google.
> In this link :http://groups.google.com/group/Google-Web-Toolkit/browse_frm/thread/9...
> a member of the group had gavehttp://xantorohara.blogspot.com/2007/07/portlets-and-gwt.html
> as link, and the other some topics n this group the link had been
> given, namely it is very popular. So I had read these article before.
> It helped a little to me.
>
> I had also readhttp://ddwiki.di.uoa.gr/mediawiki/index.php/Developing_Portlets_with_GWT

cleanfamilyboy

unread,
Dec 9, 2007, 9:57:34 AM12/9/07
to Google Web Toolkit
Hi greagor;

Now you are the first person that understands my problem.
Before I ask my main question I want to congratulate you.

Yes, you're right.
I have, the magic lines at Xantothara page. I sent my old sources in
my previous post.
The src path must be relative to the context path.
Namely the part of the code have must been like;

<script language='javascript' src='<%=request.getContextPath()%>/
com.cs.app.Hello.nocache.js'></script>

My problem is;

When the above line processing, firebug gives an error for the first
line of <%=request.getContextPath()%>/com.cs.app.Hello.nocache.js

Some part of the <%=request.getContextPath()%>/
com.cs.app.Hello.nocache.js is;

Line 1 : function com_cs_app_Hello(){var l=window,k=document, ....

The given error by the firebug : com_cs_app_Hello() is not defined.

com.cs.app.Hello.nocache.js generated by GWT. And com_cs_app_Hello()
repeats many times in com.cs.app.Hello.nocache.js.

Is there a contex problem in here? Or what the problem is?

NOTE :
<title>Wrapper HTML for Hello</title> appears on the liferay. There is
no path problem for this.

cleanfamilyboy

unread,
Dec 9, 2007, 9:59:09 AM12/9/07
to Google Web Toolkit
Hi greagor;

Now you are the first person that understands my problem.
Before I ask my main question I want to congratulate you.

Yes, you're right.
I have, the magic lines at Xantothara page. I sent my old sources in
my previous post.
The src path must be relative to the context path.
Namely the part of the code have must been like;

<script language='javascript' src='<%=request.getContextPath()%>/
com.cs.app.Hello.nocache.js'></script>

My problem is;

When the above line processing, firebug gives an error for the first
line of <%=request.getContextPath()%>/com.cs.app.Hello.nocache.js

Some part of the <%=request.getContextPath()%>/
com.cs.app.Hello.nocache.js is below;

Line 1 : function com_cs_app_Hello(){var l=window,k=document, ....

The given error by the firebug : com_cs_app_Hello() is not defined.

com.cs.app.Hello.nocache.js generated by GWT. And com_cs_app_Hello()
repeats many times in com.cs.app.Hello.nocache.js.
Is there a contex problem in here? What the problem is?

gregor

unread,
Dec 10, 2007, 8:12:50 AM12/10/07
to Google Web Toolkit
can I just check my understanding of this:

>
> Line 1 : function com_cs_app_Hello(){var l=window,k=document, ....
>
> The given error by the firebug : com_cs_app_Hello() is not defined.
>


1) com_cs_app_Hello() is defined in com.cs.app.Hello.nocache.js (and
nowhere else?)
2) firebug reports com_cs_app_Hello() doesn't exist (when obviously
it does in com.cs.app.Hello.nocache.js)

So your question is "Since my browser must have loaded
com.cs.app.Hello.nocache.js in order to know about com_cs_app_Hello()
in the first place, why does it now say it doesn't exist?" Is this
right?

Are you still using both liferay jsp and GWT HTML? If so can you paste
them in.

cleanfamilyboy

unread,
Dec 10, 2007, 10:09:37 AM12/10/07
to Google Web Toolkit


gregor yazdı:
> can I just check my understanding of this:
>
> >
> > Line 1 : function com_cs_app_Hello(){var l=window,k=document, ....
> >
> > The given error by the firebug : com_cs_app_Hello() is not defined.
> >
>
>
> 1) com_cs_app_Hello() is defined in com.cs.app.Hello.nocache.js (and
> nowhere else?)

and also in com.cs.app.Hello-xs.nocache.js

> 2) firebug reports com_cs_app_Hello() doesn't exist (when obviously
> it does in com.cs.app.Hello.nocache.js)
>

firebug says "com_cs_app_Hello() is not defined."

> So your question is "Since my browser must have loaded
> com.cs.app.Hello.nocache.js in order to know about com_cs_app_Hello()
> in the first place, why does it now say it doesn't exist?" Is this
> right?

Firebug says : "com_cs_app_Hello() is not defined."

> Are you still using both liferay jsp and GWT HTML? If so can you paste
> them in.

Yes...

my view.jsp file...
-----------------------

<%@ page language="java" contentType="text/html; charset=ISO-8859-9"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

<html>
<head>

<title>Wrapper HTML for Hello</title>

<style>
body,td,a,div,.p{font-family:arial,sans-serif}
div,td{color:#000000}
a:link,.w,.w a:link{color:#0000cc}
a:visited{color:#551a8b}
a:active{color:#ff0000}
</style>

<script language='javascript' src='<%=request.getContextPath()%>/
com.cs.app.Hello.nocache.js'></script>

</head>

<body>

<iframe src="javascript:''" id="__gwt_historyFrame" style="width:
0;height:0;border:0"></iframe>

<h1>Hello</h1>

<table align=center>

gregor

unread,
Dec 10, 2007, 4:07:28 PM12/10/07
to Google Web Toolkit
I think the problem may be that the portlet engine is doing things
with the JSP under the hood that invalidate or confuse the GWT paths
you've put in i.e. it may not be producing HTML the way it looks in
view.jsp in reality. Note that a JSP gets compiled into a sevlet, and
a portlet is also a servlet so how does that work?. I'm not sure how
this is handled but there looks to be plenty of scope for problems to
creep in GWT-wise.

Have you tried using the Liferay "Hello world" portlet template in
exactly the same way Xantothara did, e.g.:

import com.liferay.portal.util.Constants;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

/**
* <a href="HelloWorldPortlet.java.html"><b><i>View Source</i></b></
a>
*
* @author Brian Wing Shun Chan
*
*/
public class YourGWTPortlet extends GenericPortlet {

public void processAction(ActionRequest req, ActionResponse res)
throws IOException, PortletException {
}

public void doView(RenderRequest req, RenderResponse res)
throws IOException, PortletException {

renderResponse.setContentType("text/html");
PrintWriter writer = renderResponse.getWriter();
writer.println("<script language='javascript' src='<
%=request.getContextPath()%>/com.cs.app.Hello.nocache.js'></
script>");
writer.println("Hello GWT:");
writer.println("<tr><td id="slot1"></td><td id="slot2"></td> </
tr> ");
writer.close();
}
}

I can't see why that would not work so long as
com.cs.app.Hello.nocache.js is in the right place. Note the XML
definition for this portlet does not have the

<init-param>
<name>view-jsp</name>
<value>/portlet/calendar/view.jsp</value>
</init-param>

tag in it, and I think this may solve your problem.

<portlet>
<portlet-name>47</portlet-name>
<display-name>Hello World</display-name>
<portlet-class>
com.foo.YouGWTPortlet <<<< put your portlet java class
here
</portlet-class>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>Hello World</title>
<short-title>Hello World</short-title>
<keywords>Hello World</keywords>
</portlet-info>
<security-role-ref>
<role-name>Power User</role-name>
</security-role-ref>
<security-role-ref>
<role-name>User</role-name>
</security-role-ref>
</portlet>

If it does work it looks like you could copy all the liferay
navigation/decoration stuff from the IFrame example if you need it:

http://content.liferay.com/4.0.0/docs/developers/ch08s01.html#d0e6445

Regards
Gregor

cleanfamilyboy

unread,
Dec 11, 2007, 3:47:15 AM12/11/07
to Google Web Toolkit


gregor yazdı:
> I think the problem may be that the portlet engine is doing things
> with the JSP under the hood that invalidate or confuse the GWT paths
> you've put in i.e. it may not be producing HTML the way it looks in
> view.jsp in reality. Note that a JSP gets compiled into a sevlet, and
> a portlet is also a servlet so how does that work?. I'm not sure how
> this is handled but there looks to be plenty of scope for problems to
> creep in GWT-wise.


> Have you tried using the Liferay "Hello world" portlet template in
> exactly the same way Xantothara did, e.g.:

Yes. I tried. It works without a problem. It does not give any error
message such as com_cs_app_Hello().
These blocks of code works fine. No problem.

> I can't see why that would not work so long as
> com.cs.app.Hello.nocache.js is in the right place.

It is certainly in the right place. If not, firebug says :
"com.cs.app.Hello.nocache.js is not found".
But now it says com_cs_app_Hello() is not defined. (com_cs_app_Hello()
is defined in com.cs.app.Hello.nocache.js in reality)
It does not work. The same problem occurs.

> Regards
> Gregor

My aim is;

I develop UI in GWT. I develop pages that has buttons, menus, tab
panels etc.
I write java in GWT, as you know, it produces me htmls.

I want to use these produced htmls (by GWT) in Liferay.
I don't want to write it like Xantothara because he does this hard -
coded. He does not uses GWT outputs (htmls).

I suppose you understant what I want.

Thanks.

gregor

unread,
Dec 11, 2007, 7:20:09 AM12/11/07
to Google Web Toolkit

Hi there,

I don't have a portal engine up so I can't test any of this, but I
think the JSP/function undefined problem can be explained roughly as
follows (please excuse me if the precise details are not quite right):

Normally a GWT app gets fired up by hooking the javascript into the
HMTL entry page and accessing the page's frame window (this.frameWnd).
In a portal situation the portlet JSP is running inside the main
portal so when the GWT module javascript code calls this.frameWnd() in
onLoad() it's either 1) getting the main portal frame (which doesn't
have access to the GWT app javascript file) or 2) its getting null
from the portlet JSP (because the portlet JSP doesn't actually have a
frame of its own) - I'm not sure which way round it is. Whichever, the
root of the problem is that the main portal page needs access to the
GWT files becasue it is ultimately in control of rendering the overall
portal page and it can't find the GWT js resources. GWT obviously
isn't included in JSR 168 to specify picking this stuff up
automatically from the portlets yet. I hope this makes some sense to
you.

Looking back at the http://ddwiki.di.uoa.gr/mediawiki/index.php/Developing_Portlets_with_GWT
page, comment 2 now makes more sense:

"Modifying Tomcat

1. Replace $CATALINA_HOME/webapps/gridsphere/WEB-INF/CustomPortal/
layouts/TemplateLayout.xml with the corresponding one found here.
2. Include gwt.js and script.html files found here in
$CATALINA_HOME/webapps/gridsphere/html directory.

Therefore, the gwt.js script will exist in all portal pages. In
particular, it will be always located after all the <meta> headers
that define gwt-modules. This is desired, because this script
processes the meta-headers and creates a handler per module in order
to instanciate and load the module."

So, for gridsphere read Liferay, and as to whether they mean you move
the GWT resources to or keep a copy of them in the main portal html
directory (or the Liferay equivelent) as well as the portlet
subdirectory I don't know - I guess you'll have to try it and see.

Regards
Gregor

galel

unread,
Jan 21, 2008, 4:49:57 AM1/21/08
to Google Web Toolkit
I have the same problem as you; have you already found a solution?

Thanks

Gaël

tong123123

unread,
Aug 19, 2012, 12:41:16 PM8/19/12
to google-we...@googlegroups.com, Google Web Toolkit
after 4 year, I face the same problem, seems no any website to taught about GWT and Liferay protal integration,
what I can found is the wiki from liferay which is no help
http://www.liferay.com/community/wiki/-/wiki/Main/Build+a+GWT+Portlet
it seems I really get into trouble this time.
Reply all
Reply to author
Forward
0 new messages