com.ibm.wps.portlets.struts
Class ErrorResponseInfo

java.lang.Object
  extended by com.ibm.wps.portlets.struts.ErrorResponseInfo

public class ErrorResponseInfo
extends java.lang.Object

The ErrorResponseInfo class is used to support sendError in the Struts Portlet Framework. Instances of this class will store the error code and error text from the sendError call.

If an error is detected when creating or executing IViewCommands, then a WpsStrutsViewErrorCommand object is created to display the error. A class that extends IErrorResponseFormatter is used to format the display of the error.

Since:
4.1

Constructor Summary
ErrorResponseInfo(int errorCode)
          Constructs an ErrorResponseInfo object with only the error code (that is, no text).
ErrorResponseInfo(int errorCode, java.lang.String errorText)
          Constructs an ErrorResponseInfo object with error code and text.
 
Method Summary
static void clearErrorResponse(HttpServletRequest request)
          Removes error information.
 int getErrorCode()
          Returns the error code.
static ErrorResponseInfo getErrorResponse(HttpServletRequest request)
          Returns the ErrorResponseInfo object from session if one can be found.
 java.lang.String getErrorText()
          Returns the error text.
static void setErrorResponse(HttpServletRequest request, int errorCode)
          Sets an error code.
static void setErrorResponse(HttpServletRequest request, int errorCode, java.lang.String errorText)
          Sets an error code and error text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorResponseInfo

public ErrorResponseInfo(int errorCode)
Constructs an ErrorResponseInfo object with only the error code (that is, no text).

Parameters:
errorCode - the int error code

ErrorResponseInfo

public ErrorResponseInfo(int errorCode,
                         java.lang.String errorText)
Constructs an ErrorResponseInfo object with error code and text.

Parameters:
errorCode - the int error code
errorText - the error text
Method Detail

getErrorCode

public int getErrorCode()
Returns the error code.

Returns:
returns the error code

getErrorText

public java.lang.String getErrorText()
Returns the error text.

Returns:
returns the error text, can be null if not set

getErrorResponse

public static ErrorResponseInfo getErrorResponse(HttpServletRequest request)
Returns the ErrorResponseInfo object from session if one can be found. If null is returned then the processing did not result in a call to sendError.

Parameters:
request - the request object
Returns:
returns the ErrorResponseInfo object if present or null otherwise

setErrorResponse

public static void setErrorResponse(HttpServletRequest request,
                                    int errorCode)
Sets an error code. The error code can be retrieved when the IViewCommands are created. If an error has been detected then a WpsStrutsViewErrorCommand will be created.

Parameters:
request - the request object
errorCode - the error status code

setErrorResponse

public static void setErrorResponse(HttpServletRequest request,
                                    int errorCode,
                                    java.lang.String errorText)
Sets an error code and error text. The error code and text can be retrieved when the IViewCommands are created. If an error has been detected then a WpsStrutsViewErrorCommand object will be created.

Parameters:
request - the request object
errorCode - the error status code
errorText - the error status text

clearErrorResponse

public static void clearErrorResponse(HttpServletRequest request)
Removes error information. Once the appropriate WpsStrutsViewCommand has been created for this error, the error information should be removed.

Parameters:
request - the request object