liferay / portlet development

OogyWaWa

Senior member
Jan 20, 2009
623
0
71
i've been digging through what is likely the worst documentation for any project, ever. so frustrating. i've read jsr-168 and gone through every wiki and literally hundreds of forum posts, but i can't even figure out how to get my pages to move around inside the portlet. anyone here have any exp. with this and willing to give me some tips?

thanks :)
 

Tea Bag

Golden Member
Sep 11, 2004
1,575
3
0
Well, I haven't used Liferay but I've used a few other Portal vendors and to say documentation is spotty at best, regardless of the Vendor is a friendly statement. It seems to be getting a bit better though. I kinda quit doing Portlet development when JSR-286 was underway before Vendor implementation and now it looks like Liferay among others are built on the specification.

Unless you're locked on Liferay for sure you might want to look at some of the other Open Source vendors like JBoss Portal, eXo or JetSpeed. (I'm not endorsing one over the other becuase we don't use any of those but here's a list: http://en.wikipedia.org/wiki/E...rprise_Portal_Vendors).

If you're sticking with Liferay the best advice I can give you is just set one up on a development box or your local environment and tinker with it as much as possible. Most of the vendors have admin account mode that allow you to configure your content in the form of Pages, which allow you to place Portlets on the Pages. In this administration mode you allow your end-users to move the Portlets around on the page, which is what I think you're referring to when you say "move pages inside the Portlet" - that's all usually done (or allows it to be done) by the administration console. The options on the outside of the Portlet 'chrome' - like minimize, maximize and edit functions are built into the Portlet when it's developed and is part of the JSR-168/286 spec.

Some of the things you have to do to get Portlets installed and configured are a pain the first couple times but once the setup is done it's a bit more intuitive. Just skimming their site it looks like they have a few docs out there, one about "Liferay control panel" that might be of assistance. The reason I suggest looking at some other Vendor's offerings is just to see how the Portlets act in different containers if you're stuck - they should all do it fairly similar. Just remember if you do that and you have custom Portlets you want to deploy they're not compatible and you'll have to rebuild them.
 

OogyWaWa

Senior member
Jan 20, 2009
623
0
71
thanks for the help. but, what i meant by move around was going from page to page inside my portlet.

lets say i have page: login.jsp, and once you click submit it takes you to page result.jsp . Obviously if you direct link it, it will take the entire website to result.jsp instead of just the frame inside the portlet. I'm having a bitch of a time trying to figure out how shit is rendered inside the portlet itself >_<
 

Tea Bag

Golden Member
Sep 11, 2004
1,575
3
0
Ahh, OK. That makes more sense.

What you need to do with links or actions on the page is create a portlet actionURL that your Portlet submits and is handled by a ActionRequest serverside. The way to do that is to use the porlet taglib on your JSP page, like so - (this is stolen from here. FYI - there's no space in that portlet: Param tag, that's becuase of the emots)

----
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

<portlet:defineObjects/>

<div align="center">
This is a simple HelloWorld JSP Portlet. Type in a name and it will dispatch to the view2.jsp to print out your name.
<br/>

<form action="<portlet:actionURL><portlet: Param name="page" value="mainview"/></portlet:actionURL>"
method="POST">
Name:<br/>
<input type="text" name="yourname"/>
</form>
<br/>
You can also link to other pages, using a renderURL, like <a
href="<portlet:renderURL><portlet: Param name="yourname" value="Roy Russo"></portlet: Param></portlet:renderURL>">this</a>.
</div>
----

with the bolded part being the action url. The JSP Porlet tag library uses that to generate an actionURL that is specific for that portlet, which directs to an ActionRequest on the server.

The class that handles that just extends the GenericPorlet class and overrides the processAction() method which is similar to a doGet() or doPost() if you're in the Servlet world. After that action request is completed - some logic can be preformed in there and based on the input and your expected output you use the following line in the processAction() method to direct to your next view state by doing the following:

---
PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");
prd.include(rRequest, rResponse);
--

the portletRequestDispatcher says what the view to transition to should be. There are other ways to do it, you can create a renderUrl using the <portlet:renderUrl> tag as well that just uses the doView() method which is helpful for link transitions.

It takes a bit to get used to the way the portlets do their thing - this is a good helloWorldPortlet example. BTW - you should only have to tweak this minimally to get it to work in another container, like Liferay becuase this is JSR-168 stuff. The one thing you'll have to probably change is the way the portlet.xml is set up in the project to get it to deploy.

** I'm not posting in your other thread about suppressing java errors for building a sample project, but I'll put my two cents in here. The short answer is NO, you cannot compile your java files without all the required libraries or dependencies. Depending on the compilation method you're using (command line vs IDE, you can specify the libraries you need using the classpath argument or in eclipse and just add the libraries to your project.) It actually sounds like you're doing it on the command line, which is fine - but for this example you'll need ANT (http://www.axint.net/apache/an...che-ant-1.7.1-bin.zip)) to build this becuase it links in your dependencies and creates the deployable WAR file.

I suggest you Download this sample portlet and compile it get it to deploy on Liferay. It says "Any JSR 168 compliant portlet WAR will work" and this is, but you might have to look around for a better sample than this JBoss one, I just didn't feel like rewriting what I did for Liferay :p **



 

isocial

Junior Member
Mar 22, 2010
3
0
0
www.isocial.in
The LifeRay open source software can be considered as a Framework about which your website is created. Although LifeRay has a number of ready made 'portlets' which add additional functionality to the site, they may not be tailored and suited to your needs.

a proven track record developing portlets for LifeRay, as well as customizing existing ones.
For example, i have created an Activity Feed portlet for one of our clients which shows the activity of all the members in your team. It's built with access control so it will only show activity from your own team, and you can't see what's going on with other teams unless this is specifically enabled.