Differences between revisions 26 and 27
Revision 26 as of 2006-06-19 07:01:56
Size: 12142
Comment:
Revision 27 as of 2009-09-20 23:46:26
Size: 12121
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[TableOfContents(4)]] <<TableOfContents(4)>>
Line 5: Line 5:
 * [wiki:/DevelopingJetspeedPlatform Getting Started Developing the Jetspeed 2 Platform]
 * [wiki:/DevelopingJetspeedPlatformJ2ArchitectureWalkthrough Jetspeed 2 Platform Architecture Walkthrough]
 * [wiki:/DevelopingJetsppedPlatoformJ2EngineOverview Jetspeed 2 Engine Overview]
 * [wiki:/DevelopingJetspeedPlatformJ2EngineComponents Jetspeed 2 Engine Components]
 * [wiki:/DevelopingJetspeedPlatformJ2ExternalDependencies Jetspeed 2 APIs and Dependencies ]
 * [[/DevelopingJetspeedPlatform|Getting Started Developing the Jetspeed 2 Platform]]
 * [[/DevelopingJetspeedPlatformJ2ArchitectureWalkthrough|Jetspeed 2 Platform Architecture Walkthrough]]
 * [[/DevelopingJetsppedPlatoformJ2EngineOverview|Jetspeed 2 Engine Overview]]
 * [[/DevelopingJetspeedPlatformJ2EngineComponents|Jetspeed 2 Engine Components]]
 * [[/DevelopingJetspeedPlatformJ2ExternalDependencies|Jetspeed 2 APIs and Dependencies ]]
Line 17: Line 17:
 * [wiki:/DevelopingCustomPortlets How to develop your own custom portlets]
 * [wiki:/DeployingCustomPortlets How to deploy your own custom portlets]
 * [[/DevelopingCustomPortlets|How to develop your own custom portlets]]
 * [[/DeployingCustomPortlets|How to deploy your own custom portlets]]

Developing the Jetspeed framework

Developing portals based on the Jetspeed framework

Developing components for Portal servers (platform independent)

Portlet Development: developing a JSR 168 Portlet platform independent

Developing components that are Jetspeed portal dependent

Developing a JSR 168 Portlet that are Jetspeed 2 dependent

First you should create a new Project for the Portlet i.e. "FirstPortlet". Next you have to create a source folder "src/java" with a package "de.oio.portlets" for your first portlet. Additionally there is even a simple JSP integrated in this portlet. This JSP can be found in "src/webapp/jsp/firstportlet.jsp". There are two inital descriptors needed for a portlet First the web.xml as in other projects and second the portlet.xml. These files have to be created in the "src/webapp/WEB-INF" folder. After finishing these inital steps you have to create a new Java class in your created package "FirstPortlet.java". The code of your first portlet could look like:

firstportlet.jsp

<HTML>
        <HEAD>
                <TITLE>Orientation in Objects GmbH</TITLE>
        </HEAD>
        <BODY>
        <H3>Welcome !</H3>
                

                
                
        
</BODY>
</HTML>

FirstPortlet.java

package de.oio.portlets;

import java.io.IOException;
import java.io.Writer;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

/**
 * @author bbratkus
 *
 * 
 */
public class FirstPortlet extends GenericPortlet{

        Writer writer;
        
        /* (non-Javadoc)
         * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
         */
        protected void doView(RenderRequest renderRequest, RenderResponse renderResponse)
                        throws PortletException, IOException {
                renderResponse.setContentType("text/html");
                writer = renderResponse.getWriter();
                writer.write("Hello I am a portlet and I am trapped in a Portal!");
                String jspName = "/jsp/firstportlet.jsp";
                //writer.write(renderResponse.encodeURL(renderRequest.getContextPath()));
                writer.write("<IMG SRC="+renderResponse.encodeURL(renderRequest.getContextPath()+"/pics/oio.gif")+">");
                PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
                                jspName);
                rd.include(renderRequest, renderResponse);
                writer.write("Der momentan angemeldete Benutzer : "+renderRequest.getRemoteUser());
                writer.write("Die Rolle des angemeldeten Benutzers : "+renderRequest.isUserInRole("plutoTestRole"));
        }
        
        /* (non-Javadoc)
         * @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
         */
        protected void doHelp(RenderRequest request, RenderResponse response)
                        throws PortletException, IOException {
                response.setContentType("text/html");
                writer = response.getWriter();
                response.setTitle("Helpsite of "+super.getTitle(request));
                writer.write("Hier kann man Informationen über die Benutzung des Portlets hinterlgen.");
        }
        
        
        /* (non-Javadoc)
         * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
         */
        protected void doEdit(RenderRequest request, RenderResponse response)
                        throws PortletException, IOException {
                response.setContentType("text/html");
                writer = response.getWriter();
                writer.write("Hier können Eigenschaften die -modifiable- sind von den Benutzern geändert werden");
                writer.write("Man hat beispielsweise die Möglichkeit den Title zu ändern, neben der Möglichkeit in der portlet.xml ");
                writer.write("Das "+super.getTitle(request)+" war der alte Titel");
                response.setTitle("Edit of "+super.getTitle(request));
        }
        
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <display-name>FirstPortlet</display-name>
</web-app>

portlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" 
        version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
        <portlet>
                <portlet-name>FirstPortlet</portlet-name>
                <portlet-class>de.oio.portlets.FirstPortlet</portlet-class>

                <expiration-cache>30</expiration-cache>
                <supports>
                        <mime-type>text/html</mime-type>
                        <portlet-mode>view</portlet-mode>
                        <portlet-mode>edit</portlet-mode>
                        <portlet-mode>help</portlet-mode>
                </supports>
                <supported-locale>de-DE</supported-locale>
                <portlet-info>
                        <title>FirstPortlet</title>
                        <short-title>First</short-title>
                        <keywords>example</keywords>
                </portlet-info>
                
        </portlet>
</portlet-app>

Creating the war - web archive

After finishing the coding of the portlet and the jsp and descriptors you have to create a war archive out of it. Therefore you should use Maven or Ant. Of course you have to add some jar archives to your project for the portlets, servlets, xdoclet or even more. But if you are using Maven, these jars can be found in your maven repository. So you have to learn the work with Maven or you use Ant. In this example Maven is used. Here is another example for the maven.xml in your project root folder: maven.xml

<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" default="war">
  <preGoal name="java:compile">
    <mkdir dir="${maven.build.dir}/xdoclet/webdoclet/WEB-INF" />
        <attainGoal name="xdoclet:webdoclet" />
  </preGoal>
</project>

Even some properties have to be definded. These properties can be found in the "project.properties" file in your root folder too. project.properties

maven.xdoc.date=left
maven.war.webapp.dir=${maven.build.dir}/xdoclet/webdoclet
maven.xdoclet.webdoclet.0=true
maven.xdoclet.webdoclet.0.destDir=${maven.build.dir}/xdoclet/webdoclet/WEB-INF
maven.xdoclet.webdoclet.0.mergeDir=src/merge
maven.xdoclet.webdoclet.deploymentdescriptor.0.destDir=${maven.build.dir}/xdoclet/webdoclet/WEB-INF
maven.xdoclet.webdoclet.deploymentdescriptor.0.mergeDir=src/merge
de.oio.portlets.project.name.app=FirstPortlet

And last the "project.xml" even this file is in your project root folder.

<project>
        <pomVersion>1</pomVersion>
        <id>FirstPortlet</id>
        <groupId>portlet</groupId>
        <name>portletExample</name>
        <currentVersion>1.0</currentVersion>
        <organization>
                <name>Orientation in Objects GmbH</name>
                <url>http://www.oio.de/</url>
                <logo>http://oio.de/i/h.jpg</logo>
        </organization>
        <inceptionYear>2005</inceptionYear>
        <package>de.oio.portlets</package>
        <logo/>
        <description>An example project for porlet development</description>
        <shortDescription>An example project for porlet development</shortDescription>
        <url/>
        <issueTrackingUrl/>
        <siteAddress/>
        <siteDirector/>
        <distributionDirectory/>
        <mailingLists/>
        <!-- who the developers are for the project -->
        <developers>
  </developers>
        <!-- jar files the project is dependent on -->
        <dependencies>
                <dependency>
                        <groupId>servletapi</groupId>
                        <artifactId>servlet-api</artifactId>
                        <version>2.4-20040521</version>
                        <type>jar</type>
                </dependency>
                <dependency>
                        <groupId>portlet-api</groupId>
                        <artifactId>portlet-api</artifactId>
                        <version>1.0</version>
                        <type>jar</type>
                        <properties>
                                <war.bundle>false</war.bundle>
                        </properties>
                </dependency>
                <!-- XDoclet dependencies -->
                <dependency>
                        <id>xdoclet</id>
                        <version>1.2</version>
                </dependency>
                <dependency>
                        <groupId>xdoclet</groupId>
                        <artifactId>xdoclet-web-module</artifactId>
                        <version>1.2</version>
                        <url>http://xdoclet.sf.net/</url>
                </dependency>
                <dependency>
                        <groupId>xdoclet</groupId>
                        <artifactId>xjavadoc</artifactId>
                        <version>1.0.2</version>
                        <url>http://xdoclet.sf.net/</url>
                </dependency>
                <dependency>
                        <groupId>xdoclet</groupId>
                        <artifactId>maven-xdoclet-plugin</artifactId>
                        <version>1.2</version>
                        <type>plugin</type>
                        <url>http://xdoclet.sf.net/</url>
                </dependency>
        </dependencies>
        <build>
                <sourceDirectory>src/java</sourceDirectory>
                <unitTestSourceDirectory/>
                <resources>
                        <resource>
                                <directory>src/conf</directory>
                                <includes>
                                        <include>*.properties</include>
                                </includes>
                        </resource>
                </resources>
        </build>
</project>

Individualisation of the appearance

While customizing the CSS of one Layout you can easyly edit the default appearance of Jetspeed2. For example you can edit the layout-decorator and the portlet-decorator of the tigris layout.

===== Example ====

<!-- jetspeed\WEB-INF\decorations\layout\html\tigris\decorator-top.vm -->
<!-- Banner -->
      <div id="banner">
        <table border="0" cellspacing="0" cellpadding="8" width="100%">
          <tr>
            <td>
              <h1><img src="content/images/oio.gif" alt="Orientation in Objects Logo" border="0"/></h1>
            </td>
            <td>
              <div align="right" id="login">
                &nbsp;
              </div>
            </td>
          </tr>
        </table>
      </div>

And an example fragment of the CSS file.

Example

a:hover {
    color: #f5a83d !important; /*default: #f30 - here you can edit the color of the tabs when the mouse hovers above */
}

Additionally there is the posibility to customize single pages via the different Jetspeed2-Layouts i.e. "VelocityOneColumn" in difference to the start page which uses the „VelocityTwoColumn“. Therefore you have to edit the following data:

the rss.psml

This is an example for a jetspeed2 portal site, which includes only one portlet. So this site should completly filled out with the portlet. Therefore you can use the "VelocityOneColumn" - Layout.

Example

<page id="rss">
<defaults skin="orange“ layout-decorator="tigris“ portlet- decorator="tigris"/>
<title>RSS Example</title>
<fragment id="rss-1" type="layout" name="jetspeed-layouts::VelocityOneColumn">
<!-- The Layout Portlet above-named -->
         <fragment id="rss-10" type="portlet" name="OioRss::RssPortlet">
<!-- the rss portlet -->
         <property name="row" value="0" layout="OneColumn"/>
         <property name="column" value="0" layout="OneColumn"/>     
         </fragment>
 </fragment>

<security-constraints>
    <security-constraints-ref>public-edit</security-constraints-ref>
  </security-constraints>
</page>

Developing components using the Bridges

The Struts Bridge

Look at these pointers:

And take a look at the JPetstore demo application implementation (there is no real documentation for this one, but it use all of the struts-bridge features listed above):

Note: this example is by default deployed in the demo installation of Jetspeed-2, so you probably already have seen/used it :)

Jetspeed2/DevelopersDocumentation (last edited 2009-09-20 23:46:26 by localhost)