這是最簡單
缺點當然就是所有事情都要自己去做
這種方式比較適合自己開發Portlet框架
public class NativePortlet implements Portlet {
private Logger logger = LoggerFactory
private PortletConfig config;
@Override
public void init(PortletConfig portletConfig) throws PortletException {
(
nfig = portletConfig;
}
@Override
public void processAction(ActionRequest actionRequest
(
(
}
@Override
public void render(RenderRequest renderRequest
(
WindowState state = renderRequest
if (state
return;
}
// doDispatch();
PortletMode mode = renderRequest
if (PortletMode
// doView();
String normalPage = config
if (WindowState
this
} else {
this
}
} else if (PortletMode
// doEdit();
} else if (PortletMode
// doHelp();
} else {
throw new PortletException(
}
}
@Override
public void destroy() {
(
}
private void include(RenderRequest request
response
PortletContext context = config
PortletRequestDispatcher requestDispatcher = context
requestDispatcher
}
}
可以看到
諸如此類的各種細節都需要我們自己去制定規則
Portlet規范也提供了注解的方式來開發Portlet
也能比較方便的開發Portlet
public class AnnotatedPortlet extends GenericPortlet {
private Logger logger = LoggerFactory
/**
* 進入主頁面(View模式)
* @param request
* @param response
* @throws Exception
*/
@RenderMode(name =
public void toIndexPage(RenderRequest request
getPortletContext()
getRequestDispatcher(getInitParameter(
include(request
}
/**
* 保存用戶名
* @param request
* @param response
*/
@ProcessAction(name =
public void saveUsername(ActionRequest request
String userName = request
(
}
/**
* 保存電子郵件地址
* @param request
* @param response
*/
@ProcessAction(name =
public void saveEmail(ActionRequest request
String email = request
(
}
}
使用@RenderMode注解定義不同模式下
直接將請求交給標有注解的方法去處理
附
頁面代碼如下
<%@ page language=
pageEncoding=
<%@ taglib uri=
<%@ taglib uri=
<%@ taglib uri=
<%@ taglib uri=
<portlet:defineObjects />
<h
<!
<form action=
<tr>
<td>用戶名
<td><input name=
</tr>
<tr>
<td><input type=
</tr>
</form>
<!
<td>Email:</td>
<td><input id=
<input id=
$(
var email = $(
jQuery
type:
async: true
url:
dataType:
data: {
}
success: function (data) {
alert(data)
}
error: function (data
alert(e)
}
beforeSend: function () {
}
complete: function () {
}
})
})
</script>
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26248.html