Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-3041

Support detection of portlet mode changes when JSF portlet developers call ActionResponse.setPortletMode(PortletMode)

    Details

      Description

      The FacesBridge Spec needs to contain explicit requirements to ensure that the bridge supports detection of portlet mode changes when JSF portlet developers call ActionResponse.setPortletMode(PortletMode).

      For example, consider the following backing bean method that gets called in EDIT_MODE:

      PortletPreferencesBackingBean.java
      public void reset() {
      
      	FacesContext facesContext = FacesContext.getCurrentInstance();
      	ExternalContext externalContext = facesContext.getExternalContext();
      	PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
      	PortletPreferences portletPreferences = portletRequest.getPreferences();
      
      	try {
      		Enumeration<String> preferenceNames = portletPreferences.getNames();
      
      		while (preferenceNames.hasMoreElements()) {
      			String preferenceName = preferenceNames.nextElement();
      			portletPreferences.reset(preferenceName);
      		}
      
      		portletPreferences.store();
      
      		// Switch the portlet mode back to VIEW.
      		ActionResponse actionResponse = (ActionResponse) externalContext.getResponse();
      		actionResponse.setPortletMode(PortletMode.VIEW);
      	}
      	catch (Exception e) {
      		FacesContextHelperUtil.addGlobalUnexpectedErrorMessage();
      	}
      
      }
      

      Since the portlet mode has changed, the FacesBridge implementation must not maintain the bridge request scope in order to be in accordance with Section 5.1.2.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Packages

                  Version Package
                  facesbridge-tck-5.0.0
                  facesbridge-spec-5.0.0
                  bridge-impl-5.0.0