portlet 的方式可通过单击 portlet 标题栏上的对应图标来手工更改。但是,如果想要根据
Faces 操作的性能来更改 portlet 方式,则可以调用 Faces 操作中的适当
portlet API 方法来触发方式更改。
例如,可通过单击编辑方式页中的提交按钮来使编辑方式下的 portlet 转换为查看方式:
- JSR 168 portlet API 示例
ActionResponse response = (ActionResponse)facesContext.getExternalContext().getResponse();
try {
response.setPortletMode(PortletMode.VIEW);
} catch (PortletModeException e) {
// Your exception handling code here
}
- IBM® portlet API 示例
PortletRequest request = (PortletRequest)facesContext.getExternalContext().getRequest();
try {
request.setModeModifier(Portlet.ModeModifier.PREVIOUS);
} catch (AccessDeniedException e) {
// Your exception handling code here
}