Portals and portlets Sean C. Sullivan October 24, 2006 Portland Java Users Group Overview • Portals • Portal servers • Java Portlets • Portlet programming • Portlet deployment • Demo What is a portal? A portal is a web based application that [...] provides personalization, authentication, content aggregation from different sources and hosts the presentation layer of information systems source: Java Portlet 2.0 specification Portal servers • Liferay • IBM Websphere Portal • JBoss Portal • BEA WebLogic Portal • Apache JetSpeed 2 • Sun Portal Server • Apache Pluto • Oracle Portal • eXo platform • uPortal Portal server features • personalization • single sign-on • security: users, groups, roles • portlet admin: deploy, undeploy • page layout • pre-built portlets Liferay portal demo • http://demo.liferay.net/ Portlet fragments The content generated by a portlet is also called a fragment. A fragment is a piece of markup (e.g. HTML, XHTML, WML) adhering to certain rules and can be aggregated with other fragments to form a complete document. The content of a portlet is normally aggregated with the content of other portlets to form the portal page. source: Java Portlet 2.0 specification Java Portlet specifications • Portlet 1.0 – JSR-168 • Portlet 2.0 – JSR-286 Java Portlet API • javax.portlet.Portlet • javax.portlet.GenericPortlet • javax.portlet.ActionRequest • javax.portlet.ActionResponse • javax.portlet.RenderRequest • javax.portlet.RenderResponse javax.portlet.Portlet • public void destroy() • public void init(PortletConfig cfg) • public void processAction(ActionRequest, ActionResponse) • public void render(RenderRequest, RenderResponse) javax.portlet.GenericPortlet • protected void doView(...) • protected void doEdit(...) • protected void doHelp(...) • protected void processAction(...) Hello World Portlet public class HelloWorldPortlet extends javax.portlet.GenericPortlet { public void doView(RenderRequest req, RenderResponse resp) { resp.setContentType("text/html"); PrintWriter w = resp.getWriter(); w.println("Hello world"); } } JBoss Portal demo • http://portal.demo.jboss.com/ Portlet requests 1. Action requests 2. Render requests Portlet modes javax.portlet.PortletMode 1. EDIT 2. VIEW 3. HELP Portlet window states javax.portlet.WindowState 1. MAXIMIZED 2. MINIMIZED 3. NORMAL Portlet deployment • WAR • web.xml • portlet.xml What's new in Java Portlet 2.0? • Resource serving • Events • Portlet filters • alignment with WSRP 2.0 Additional topics • Caching • CSS • Internationalization • File upload • Inter-portlet communication • Wrapping existing applications • WSRP Resources • http://wiki.java.net/bin/view/Javapedia/Portal • http://wiki.java.net/bin/view/Javapedia/Portlet • http://www.jcp.org/en/jsr/detail?id=168 • http://www.jcp.org/en/jsr/detail?id=286