Wednesday, March 18, 2009

WEMP development: Create portlet project

prerequisites: RAD 7.0 with portal tool and mobile portal toolkit; Websphere Portal 6.0 with mobile portal test enviroment(installed with mobile portal toolkit)
  1. Step 1 创建portlet项目

1.1 File->New->Portlet Project

1.2Specify the attributes(it's alright to set them as default) in the New Portlet Project wizard, take care of the following attributes

* target runtime: WebSphere Portal v6.0(if you don't see this runtime, click new to set one up.
* Portlet Type: Mobile Portlet

1.3 Specify the attributes at Portlet Setting page.
Note that ContentType->x-application/vnd.xdime+xml-> view should be checked if the portlet is going to deploy on mobile portal. Currently the mobile portlet only support view mode at default.
At this point, a new project has created. To change the project settings, we can modify the portlet.xml file located at \WebContent\Web-INF

2. The project structure


src: The java code is contained here. Initially there are 3 kinds of files: portlet, portlet session and language properties files.
At portlet file names like portlet.java we can handle the portlet request, redirect and action handling like a servlet file; It acts like controller of MVC pattern.
At portelt session file we can store some session attribute which both portlet file and jsp file can access. This file acts like model of MVC pattern.
Note that each portlet has its own portlet and portlet session file.

WebContent//jsp: HTML and xdime jsps can be found at this directory. HTML directory contains the jsps used at html chanel. xdime directory is more concerned for wemp developer. The jsps which is the presentation element for wemp apps are stored here. By default a sample jsp is created for a portlet. This acts like view of MVC pattern.

WebContent/mcs-policies: This directory stores the xdime component such as layout(mlyt), theme(mthm), image component(mimg) etc. The jsp file can acess them with path like "/sample.mimg" note that this component are xml files, we can view the xml source when open them with source view.

WebContent/WEB-INF: web.xml and portlet.xml lie here. They are all about the project configuration


3. Add portlet to existing portlet project


3.1 file->new->portlet
3.2 specify the attributes for portlet
portlet project: the exsiting portlet project
portlet type: mobile portlet
3.3 portlet setting page(do as 1.3)



No comments: