Overview Install Manual Screenshots CVS Download Contribute Contact / Help

WebWork : WWPortlet Application Development QuickStart


  • Suppose you are familiar with WebWork & Velocity, we do not explain the detail syntax of both, and just list some sample codes about how to quick start using WWPortlet framework.
  • In order to keep your attention on how to use WWPortlet, we will keep the sample as simple as possible.

The sample include

  • two view files: hello.vm & helloResult.vm
  • one xwork file: xwork.xml
  • one java action file: HelloAction.java
  • one I18N resource file: HelloAction.properties
  • one porltet description file: portlet.xml

Here is the sample list

<head><title>Please input your information</title></head>
<p>Welcome to Use $!now
#bodytag (Form "action='/hello.action'" "method='post'")
<input type="text" name="userName" value="" />
<INPUT name="Submit" type="submit" value="Submit"/>

<!-- h1>$action.getText('heading')</h1 -->
<p>$action.getText('greeting') $now

#bodytag (Form "action='/hello.action'" "method='post'")
<input type="text" name="userName" value="" />
<INPUT name="Submit" type="submit" value="Submit"/>

webwork-default.xml code snippet
<package name="webwork-default">
<result-type name="dispatcher" class="com.opensymphony.webwork.portlet.result.PortletDispatcherResult"/>
<result-type name="velocity" class="com.opensymphony.webwork.portlet.result.PortletDispatcherResult" default="true"/>

xwork.xml code snippet
<include file="webwork-default.xml"/>

<package name="default" extends="webwork-default">
<interceptor-stack name="standard-interceptors">
<interceptor-ref name="static-params"/>
<interceptor-ref name="params"/>
<interceptor-ref name="conversionError"/>
<!-- Business Function Services -->
<action name="hello" class="com.test.HelloAction">
<result name="success">
<param name="location">/helloResult.vm</param>

package com.test;
import java.util.Date;
import com.opensymphony.xwork.ActionSupport;

public class HelloAction extends ActionSupport { 
private String _userName; 
public void setUserName(String name) { 
_userName = name; 

public String getUserName() { 
return _userName; 

public Date getNow() {
return new Date(System.currentTimeMillis());

public String execute() throws Exception { 
return SUCCESS; 



From above codes, we can see WWPortlet Framework do not change any WebWork development principle. You can test this sample codes in the standard Web Container, of course this sample based on WWPortlet will run smoothly in JSR168 Portal Container as portlet.

But there are a few key points you should know:
  • Change the webwork-default.xml (or in your xwork.xml) the result-type velocity to class "com.opensymphony.webwork.portlet.result.PortletDispatcherResult", also make result-type "velocity as the default view.
  • Now the presentation technology only support velocity. Cause I like velocity and hate JSP. Maybe the next version release, we will add the JSP presentation tech support.
  • In Velocity HTML Form only support to use #bodytag (Form "action='/hello.action'" "method='post'") .... #end, in order to run post in Portal we must follow the portal action & link name rules. We automatically change the action name at WWPortlet Framework layer.
  • If you like to use HTML link to access other resource, you should use such code <a href="$actionURL?wwLink=/index.vm">Home</a> to access index.vm, the key is "$actionURL?wwLink=".
  • If you want to use HTML link to access WebWork action resource, you must use code: <A class=nav href="$!actionXURL./login.action">Login</A>, the key is "$!actionXURL."
  • Any static resource refered in presentation page, must use code as: <IMG height=31 hspace=10 src="$req.contextPath/images/_bullet.gif" width=19 align=absMiddle>, the key is ""$req.contextPath"

WebWork Portlet Framework development guide

To be written....