OpenCms Days 2012 - OpenCms 8 as a JSR-286 compliant portlet server
Post on 08-May-2015
1381 Views
Preview:
Transcript
(c) 2012 eonas GmbH
Portals in OpenCms Building JSF and portlet applications in openCms
Presented by: Dipl.-Ing. Helmut Manck
OpenCms conference 2012
25. September 2012
(c) 2012 eonas GmbH
Agenda
What are Portals good for?
• Scenarios, Market Players
• Common Architectural Issues
Portals in OpenCms
• How to build a portal
JSF and Portlets
• How to build a portlet
(c) 2012 eonas GmbH
Scenario: Company Intranet Typically a mix of content and web applications
Content
Process
Content
Navigation
(c) 2012 eonas GmbH
Architectural approaches
• Method I: Don't use a CMS = All programmatic
• Editors hand over articles to programmers
• Programmers integrate, test and release
• Good for Programmers, Bad for Editors
• Method II: Separate CMS and Applications
• Two independent parts: one CMS-driven, one programmatic driven.
• Clean and sweet until navigation and deep links are an issue.
(c) 2012 eonas GmbH
Architectural approaches
• Method III: Develop within CMS
• Each piece of code is a formatter, JSP-fragment, Template or similar
• Development within (Open)CMS
• Pro: Single location of code
• Con: IDE support, independent testing, technological freedom
• Or you use Portals...
(c) 2012 eonas GmbH
Method IV: Portals
Content Portlet
Content
Portlet
Portlet
Navigation
(c) 2012 eonas GmbH
POST /cms/test HTTP/1.1
Host: server
select=7
Portal Issues
• There are 3 Portlets on the Page. Who handles this POST-Request?
• Portals must provide:
• Name spacing
• Link Generation
• (with in HTML-Space and the generated URLs)
(c) 2012 eonas GmbH
Java Portlets: JSR-286
• Portlets are like Servlets
• own J2EE-Webapp (.war)
• own data source, jars, configuration, version
• plus a portlet.xml
• Portlets extend GenericPortlet
• “render”: Deliver HTML-Snippet
• “action”: Process POST
• “resource”: Deliver CSS, JS, Ajax
(c) 2012 eonas GmbH
Portlet example
- Build recipe based on maven
- Additional Libs
- J2EE-Configuration plus Portlet-Config
- The Portlet plus some logic classes
- Some JSPs to render the HTML-Snipplets
- Can be developed, tested, debugged locally with full IDE support (e.g. hot code replace)
(c) 2012 eonas GmbH
Example: Request Flow
1. A HTML-Snippet generates a POST-URL:
<p:actionURL var="target" name="choosemode"/>
<form name="form" action="${target}“ method="post">
2. Form-Submit triggers URL, then redirect to
processAction(request, response)
3. New HTML-Snipplet is rendered.
render(request,response)
(c) 2012 eonas GmbH
Market View
redhat
(c) 2012 eonas GmbH
OpenCms as Portal Server
OpenCms 7/8 Pluto Portal
(Reference implementation for JSR286)
OpenCms Portal - Maven Overlay
Portal Driver (glue logic)
(c) 2012 eonas GmbH
Anatomy of the Portal
- Maven overlays the base wars, builds the final war, Pluto requires a certain Spring version.
- web.xml must be heavily modified, spring support is required by pluto, add some filters - the driver ( = glue logic ) is referenced here
- context.xml: the portal needs enhanced privileges
- Storage location of the base wars
(c) 2012 eonas GmbH
PortletTag tag = new PortletTag();
tag.setPortletId(id);
tag.setPageContext(copy);
tag.doStartTag();
Using the Portlet Support
1. Create an opencmsportal.war
• Usual Setup-Process necessary
• Portlet support enabled, but no templates, formatters or
document types contained.
2. Create an OpenCms Module
• Define Look & Feel, CSS etc.
3. The selected portlet is rendered using API-Calls within the
formatter (usually)
(c) 2012 eonas GmbH
Creating the Portlet Module
- Maven Pom to build the Module
- Document Type Definition for a Portlet
- Formatter for a Portlet
OpenCms 8 Module
- Rest of the Module not affected
(c) 2012 eonas GmbH
JSF and Rich Client Widgets
• Several JSF Libraries provide nice, easy to use widgets
• Primefaces, Richfaces, ICEfaces
• Lots of widgets, mostly easy to use
• Ajax support “built in”, Partial updates, Push-Support
• E.g. Primefaces Datatable
• JSF is gaining traction
• Application development gets much faster
• Applications get a “rich client” look & feel
• How to integrate into a portlet?
(c) 2012 eonas GmbH
JSR 301 and JSR329
• JSR301 and JSR329:
• Transparent bridge between JSF and Portals
• A JSF Application can be made Portlet just by adding a few Jars and
some configuration (portlet.xml)
• Portal vendors are pushing this technology
• RedHat (Jboss)
• Liferay
• The Liferay-JSF-Bridge can be used with OpenCms/Pluto!
(c) 2012 eonas GmbH
Component Overview
Portlet B Webapp
Primefaces
Portlet A Webapp
Plain Portlet
OpenCms Portal
Pluto with Portal Driver
dispatch() - Render or Action
HTTP GET
JSF Bridge
Tomcat 6
(c) 2012 eonas GmbH
Real world example
Example: A simple voting portlet
• Backend: Spring/Hibernate/AOP
• Frontend: Primefaces
(c) 2012 eonas GmbH
Fragen?
Dipl. Ing. Helmut Manck
Geschäftsführer
eonas IT-Beratung und Entwicklung GmbH
Pascalstr. 10A
10587 Berlin
Germany
helmut.manck@eonas.de
Telefon +49-30-3980 522 – 10
20
top related