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

Add BridgeStatusErrorException to allow custom JSF ExceptionHandlers to handle different HTTP error status code



      In JSF 2.0, a method was added to ExternalContext to handle HTTP error status codes: responseSendError(). Portlets do not have the ability to set the HTTP status code for a response (except during the Resource Phase). During any phase (besides the Resource Phase), this method should throw a FacesException with information about the error status code so that JSF portlet developers can catch the exception in a custom ExceptionHandler and handle the error appropriately.

      This task involves:

      • Adding requirements to Section 6.1.3: ExternalContext Methods of the Bridge Spec for responseSendError().
      • Adding a test to the TCK Tests section of the Bridge Spec.
      • Add the following class to the Bridge API:
          public class BridgeStatusErrorException extends BridgeException {
              // serialVersionUID
              private static final long serialVersionUID = 6836710625809465305L;
              // Private Final Data Members
              private final int httpStatusCode;
              public BridgeStatusErrorException(int httpStatusCode) {
                  super(getMessage(httpStatusCode, null));
                  this.httpStatusCode = httpStatusCode;
              public BridgeStatusErrorException(int httpStatusCode, String message) {
                  super(getMessage(httpStatusCode, message));
                  this.httpStatusCode = httpStatusCode;
              public BridgeStatusErrorException(int httpStatusCode, Throwable cause) {
                  super(getMessage(httpStatusCode, null), cause);
                  this.httpStatusCode = httpStatusCode;
              public BridgeStatusErrorException(int httpStatusCode, String message, Throwable cause) {
                  super(getMessage(httpStatusCode, message), cause);
                  this.httpStatusCode = httpStatusCode;
              private static String getMessage(int httpStatusCode, String message) {
                  StringBuilder messageBuilder = new StringBuilder();
                  messageBuilder.append("Status code ");
                  if (message != null) {
                      messageBuilder.append(": ");
                  return messageBuilder.toString();
              public int getHttpStatusCode() {
                  return httpStatusCode;


          Issue Links



              • Assignee:
                kyle.stiemann Kyle Stiemann
                kyle.stiemann Kyle Stiemann
                Participants of an Issue:
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: