com.ibm.portal.struts.plugins
Interface IErrorResponseFormatter

All Known Implementing Classes:
DefaultErrorResponseFormatter

public interface IErrorResponseFormatter

IErrorResponseFormatter is the interface for formatting an ErrorResponse. A custom IErrorResponseFormatter can be written by extending this interface, and then registering the formatter through a Struts plugin. The formatter will use the ErrorResponseInfo object to obtain the error information, and then write the information to the response object. A simple formatter may just print out the message in red.

public void formatError(ErrorResponseInfo errorInfo, PrintWriter outWriter)
{
  outWriter.println("<h2 color=\"red\">");
  outWriter.println("Error Info from ExampleResponseFormatter");
  outWriter.println("</h2>");
  outWriter.println("<h3>");
  outWriter.print(errorInfo.getErrorCode());
  if(errorInfo.getErrorText() != null)
  {
    outWriter.print(' ');
    outWriter.print(errorInfo.getErrorText());
  }
  outWriter.println(" ");
  outWriter.println("</h3>");
}

See the samples for an example of how to create a custom formatter.

Since:
5.1

Method Summary
 void formatError(ErrorResponseInfo errorInfo, PortletRequest request, PortletResponse response, ViewCommandExecutionContext executionContext)
          Format the error information, using all the execution information available.
 void formatError(ErrorResponseInfo errorInfo, java.io.PrintWriter outWriter)
          Format the error information en the request and response objects
 

Method Detail

formatError

void formatError(ErrorResponseInfo errorInfo,
                 PortletRequest request,
                 PortletResponse response,
                 ViewCommandExecutionContext executionContext)
Format the error information, using all the execution information available. The normal approach would be to get the PrintWriter from the PortletResponse and simply call the other formatError method passing the errorInfo and PrintWriter.

Parameters:
errorInfo - the ErrorResponseInfo object
request - The request object
response - The response object
executionContext - the execution context object

formatError

void formatError(ErrorResponseInfo errorInfo,
                 java.io.PrintWriter outWriter)
Format the error information en the request and response objects

Parameters:
errorInfo - the ErrorResponseInfo object
outWriter - the PrintWriter to write to