Changing portlet modes using a Faces action
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 and JSR 286 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 }
Related concepts
Creating Faces portlets and projects
Related tasks
Adding and updating Faces portlet modes for existing IBM portlets
Adding and updating Faces portlet modes