ch.ralscha.extdirectspring.bean
Class ExtDirectResponseBuilder

java.lang.Object
  extended by ch.ralscha.extdirectspring.bean.ExtDirectResponseBuilder

public class ExtDirectResponseBuilder
extends Object

An utility class that helps building a ExtDirectResponse. A form handler must return an instance of such type.

Author:
Ralph Schaer

Constructor Summary
ExtDirectResponseBuilder(javax.servlet.http.HttpServletRequest request)
          Creates a builder that builds the response object needed for form handler and form upload handler methods.
 
Method Summary
 void addErrors(BindingResult bindingResult)
          Creates a errors property in the response if there are any errors in the bindingResult Sets the success flag to false if there are errors
 void addErrors(Locale locale, MessageSource messageSource, BindingResult bindingResult)
          Creates a errors property in the response if there are any errors in the bindingResult Sets the success flag to false if there are errors
 void addResultProperty(String key, Object value)
          Add additional property to the response
 ExtDirectResponse build()
          Builds the response object
 void buildAndWriteUploadResponse(javax.servlet.http.HttpServletResponse servletResponse)
          Builds and writes the response to the OutputStream of the response.
 void successful()
          Sets success flag to true
 void unsuccessful()
          Sets success flag to false
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtDirectResponseBuilder

public ExtDirectResponseBuilder(javax.servlet.http.HttpServletRequest request)
Creates a builder that builds the response object needed for form handler and form upload handler methods. Sets the successful flag to true, can be changed with the successful() and unsuccessful() methods

Parameters:
request - the current request
Method Detail

addErrors

public void addErrors(BindingResult bindingResult)
Creates a errors property in the response if there are any errors in the bindingResult Sets the success flag to false if there are errors

Parameters:
bindingResult -

addErrors

public void addErrors(Locale locale,
                      MessageSource messageSource,
                      BindingResult bindingResult)
Creates a errors property in the response if there are any errors in the bindingResult Sets the success flag to false if there are errors

Parameters:
locale -
messageSource -
bindingResult -

addResultProperty

public void addResultProperty(String key,
                              Object value)
Add additional property to the response

Parameters:
key - the key of the property
value - the value of this property

successful

public void successful()
Sets success flag to true


unsuccessful

public void unsuccessful()
Sets success flag to false


build

public ExtDirectResponse build()
Builds the response object

Returns:
the response object

buildAndWriteUploadResponse

public void buildAndWriteUploadResponse(javax.servlet.http.HttpServletResponse servletResponse)
                                 throws IOException
Builds and writes the response to the OutputStream of the response. This methods has to be called at the end of a form upload handler method.

Parameters:
servletResponse - current servlet response
Throws:
IOException
IOException


Copyright © 2010. All Rights Reserved.