Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.forms.responder
Class ResponderFactory

    java.lang.Object
      org.makumba.forms.responder.ResponderFactory

    public class ResponderFactory

extends Object

This factory handles the creation, caching and retrieval of Responder objects.

Version:
  $Id: ResponderFactory.java,v 1.1 12.10.2007 13:17:45 Manuel Exp $
Author:
  Manuel Gay

Field Summary
`static String` | `MAKUMBA_SUCCESSFUL_RESPONSE`
`static String[]` | `RESPONSE_ATTRIBUTE_NAMES`
`static String` | `RESPONSE_FORMATTED_STRING_NAME`
`static String` | `RESPONSE_STRING_NAME`
`static String` | `resultNamePrefix`
`protected boolean` | `useDefaultResponseStyles`
`(package private) static Integer` | `ZERO`

Constructor Summary
`ResponderFactory()`

Method Summary
`FormResponder` | `createResponder()` Creates a new empty FormResponder, to be used at form computation time.
`Responder` | `getFirstResponder(ServletRequest req)` Returns the first responder object found fitting the request.
`static ResponderFactory` | `getInstance()`
`Iterator<String>` | `getOrderedResponderCodes(HttpServletRequest req)` Returns the responders in the page in a topological order
`Iterator<String>` | `getOrderedResponderCodes(Iterator<String> responderCodes)`
`Responder` | `getResponder(String code)` Returns a responder based on its code
`Iterator<String>` | `getResponderCodes(HttpServletRequest req)` Reads all responder codes from a request (all code_suffix values of __mak__responder__).
`Iterator<String>` | `getResponderCodes(Object o)`
`int` | `getResponderIdentity(Responder responder)` Based on its instance, returns the key of the responder
`Exception` | `getResponse(HttpServletRequest req, HttpServletResponse resp)` Should compute the `Response` based on all the responders of one page, but for now just computes an Exception.
`String[]` | `getSuffixes(String responderCode)` Given a responder code, extracts suffix and parentSuffix
`ArrayList<InvalidValueException>` | `getUnassignedExceptions(CompositeValidationException e, HttpServletRequest req)` For all the (nested) forms of a page, gives all the errors which have not been assigned to a specific field.
`void` | `printOrderedResponders(HttpServletRequest req)`
`void` | `setResponderWorkingDir(HttpServletRequest request)` Set the responder directory according from information taken from the `HttpServletRequest`
`void` | `setResponderWorkingDir(String tempDir, String contextPath)` Additional method to set a responder directory, used in the JUnit tests in `FormsOQLTest#beginFormResponderOrder`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### useDefaultResponseStyles

    protected boolean useDefaultResponseStyles

### ZERO

    static Integer ZERO

### RESPONSE_STRING_NAME

    public static final String RESPONSE_STRING_NAME

See Also:
  Constant Field Values

### RESPONSE_FORMATTED_STRING_NAME

    public static final String RESPONSE_FORMATTED_STRING_NAME

See Also:
  Constant Field Values

### MAKUMBA_SUCCESSFUL_RESPONSE

    public static final String MAKUMBA_SUCCESSFUL_RESPONSE

See Also:
  Constant Field Values

### RESPONSE_ATTRIBUTE_NAMES

    public static final String[] RESPONSE_ATTRIBUTE_NAMES

### resultNamePrefix

    public static final String resultNamePrefix

See Also:
  Constant Field Values

Constructor Detail

### ResponderFactory

    public ResponderFactory()

Method Detail

### getInstance

    public static ResponderFactory getInstance()

### getResponderCodes

    public Iterator<String> getResponderCodes(HttpServletRequest req)

  Reads all responder codes from a request (all code_suffix values of __mak__responder__).

  Parameters:
    `req` - the request in which we currently are
  Returns:
    the enumeration of responder codes

### getResponderCodes

    public Iterator<String> getResponderCodes(Object o)

### getOrderedResponderCodes

    public Iterator<String> getOrderedResponderCodes(HttpServletRequest req)

  Returns the responders in the page in a topological order

  Parameters:
    `req` - the request corresponding to the current page
  Returns:
    an Iterator iterating over a sorted array of responder codes

### getOrderedResponderCodes

    public Iterator<String> getOrderedResponderCodes(Iterator<String> responderCodes)

### printOrderedResponders

    public void printOrderedResponders(HttpServletRequest req)

### getSuffixes

    public String[] getSuffixes(String responderCode)

  Given a responder code, extracts suffix and parentSuffix

  Parameters:
    `responderCode` - the responder code
  Returns:
    a String[] containing the suffix as first element and the parentSuffix as second element FIXME maybe this goes just 2 levels, so forms in forms in forms aren't working?

### setResponderWorkingDir

    public void setResponderWorkingDir(HttpServletRequest request)

  Set the responder directory according from information taken from the `HttpServletRequest`

### setResponderWorkingDir

    public void setResponderWorkingDir(String tempDir,
                                       String contextPath)

  Additional method to set a responder directory, used in the JUnit tests in `FormsOQLTest#beginFormResponderOrder`.

### getResponder

    public Responder getResponder(String code)

  Returns a responder based on its code

  Parameters:
    `code` - the code that identifies one form in one page
  Returns:
    the `Responder` corresponding to the code, fetched from the cache

### getFirstResponder

    public Responder getFirstResponder(ServletRequest req)

  Returns the first responder object found fitting the request. It can be used to retrieve information about the form which is valid for all nested forms, and is used e.g. in `ControllerFilter` to find out the value of `#getReloadFormOnError()`.

  Parameters:
    `req` - the current request
  Returns:
    the first responder fitting the request.

### getUnassignedExceptions

    public ArrayList<InvalidValueException> getUnassignedExceptions(CompositeValidationException e,
                                                                    HttpServletRequest req)

  For all the (nested) forms of a page, gives all the errors which have not been assigned to a specific field.

  Parameters:
    `e` - the `CompositeValidationException` holding the errors
    `req` - the request corresponding to the current page
  Returns:
    an ArrayList containing all the unassigned exceptions

### createResponder

    public FormResponder createResponder()

  Creates a new empty FormResponder, to be used at form computation time.

  Returns:
    a new empty `FormResponder`

### getResponderIdentity

    public int getResponderIdentity(Responder responder)

  Based on its instance, returns the key of the responder

  Parameters:
    `responder` - the Responder object of which we want to get the key
  Returns:
    the unique key identifiying a specific instance of a Responder

### getResponse

    public Exception getResponse(HttpServletRequest req,
                                 HttpServletResponse resp)

  Should compute the `Response` based on all the responders of one page, but for now just computes an Exception.
  FIXME this code is not taking into account multiple forms: it iterates through all the responders of a page, but directly treats the exception of the first form responder, which means that errors in the nested forms are ignored. this should be fixed, in doing something like this:
  - iterate through all the forms, extract the form hierarchy and start processing forms in order of appearance
  - for each form responder, store the message, errors, request and response (containing modified attributes) into a Response object
  - generate a CompositeResponse object that holds all the errors, messages etc in the right order (or just pass an ArrayList of Response objects)
  - the controller should then treat the responses and exceptions starting by the inner forms (otherwise errors get ignored)

  Parameters:
    `req` - the `HttpServletRequest` corresponding to the current page
    `resp` - the `HttpServletRequest` corresponding to the current page
  Returns:
    a response object holding all necessary information for the `ControllerFilter`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20