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

Bridge prevents developers from using ActionResonse.sendRedirect(String)

    Details

      Description

      There are several ways in JSF that a developer can use to cause a redirect, each of which is supported transparently by Liferay Faces Bridge:

      1. By adding faces-redirect=true during JSF implicit navigation. For example:

      <h:commandLink action="/views/confirmation.xhtml?faces-redirect=true" />
      

      2. By adding <redirect /> in a navigation-rule. For example:

      <faces-config ...>
      	<navigation-rule>
      		<from-view-id>/views/portletViewMode.xhtml</from-view-id>
      		<navigation-case>
      			<from-outcome>success</from-outcome>
      			<to-view-id>/views/confirmation.xhtml</to-view-id>
      			<redirect />
      		</navigation-case>
      	</navigation-rule>
      </faces-config>
      

      3. By calling ExternalContext.redirect(String) from Java. For example:

      public void submit() {
          FacesContext facesContext = FacesContext.getCurrentInstance();
          ExternalContext externalContext = facesContext.getExternalContext();
          externalContext.redirect("/views/confirmation.xhtml");
      }
      

      However, Liferay Faces Bridge has a bug that prevents the JSF developer from using the Portlet API directly. For example, the following will result in an IllegalStateException:

      public void submit() {
          FacesContext facesContext = FacesContext.getCurrentInstance();
          ExternalContext externalContext = facesContext.getExternalContext();
          ActionResponse actionResponse = (ActionResponse) externalContext.getResponse();
          actionResponse.sendRedirect("http://localhost:8080/web/guest/home");
      }
      

      This problem can be solved by utilizing the new PortletResponseFactory developed in FACES-2088. In addition, this problem is related to FACES-2091.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Packages

                  Version Package
                  liferay-faces-2.1.5-ga6
                  liferay-faces-2.2.5-ga6
                  liferay-faces-3.0.5-legacy-ga6
                  liferay-faces-3.0.5-ga6
                  liferay-faces-3.1.5-ga6
                  liferay-faces-3.2.5-ga6
                  liferay-faces-4.2.5-ga6