A portlet's mode can be changed manually by clicking the corresponding
icons on the title bar of the portlet. However, if you want the portlet mode
to change based on the performance of a Faces action, you can call an appropriate
portlet API method in the Faces action to trigger the mode change.
For example,
you could cause a portlet in edit mode to revert to view mode by clicking
a submit button in the edit mode page:
- JSR 168 portlet API example
ActionResponse response = (ActionResponse)facesContext.getExternalContext().getResponse();
try {
response.setPortletMode(PortletMode.VIEW);
} catch (PortletModeException e) {
// Your exception handling code here
}
- IBM® portlet
API example
PortletRequest request = (PortletRequest)facesContext.getExternalContext().getRequest();
try {
request.setModeModifier(Portlet.ModeModifier.PREVIOUS);
} catch (AccessDeniedException e) {
// Your exception handling code here
}