org.makumba.forms.responder
Class Responder

java.lang.Object
  extended by org.makumba.forms.responder.Responder
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FormResponder

public abstract class Responder
extends Object
implements Serializable

A responder is created for each form and stored internally, to respond when the form is submitted. To reduce memory space, identical responders are stored only once

See Also:
Serialized Form

Field Summary
protected  String addField
          the field on which the add operation is made
protected  String afterHandler
          the business logic after handler, for all types of forms
static String basePointerName
          the name of the CGI parameter that passes the base pointer, see basePointerType, "__makumba__base__"
protected  String basePointerType
          edit, add and delete makumba operations have a special pointer called the base pointer
protected  String clientSideValidation
          Stores whether we shall do client-side validation, i.e. with javascript for a FormResponder
protected  Object controller
          the controller object, on which the handler method that performs the operation is invoked
protected  String controllerClassname
          store the name of the controller class
protected  String database
          the database in which the operation takes place
protected  HashMap<String,String> defaultMatchModes
           
static String defaultMessageSearchForm
          the default response message for search forms, "Search done!"
protected  ResponderFactory factory
           
protected static String FORM_RESULTS
           
protected  String formId
          HTML ID of the form
protected  String formName
          the name of the form we operate on (only needed for search forms).
protected  ArrayList<String> formOrder
          order of the forms in the page *
protected static String formSessionName
          prevents multiple submission of the same form (bug #190), computes as responder+sessionID, "__makumba__formSession__"
(package private)  int groupCounter
          the form counter, 0 for the root form, one increment for each subform of this form
protected  String handler
          the business logic handler, for all types of forms
protected  int identity
          the responder key, as computed from the other fields
protected  String message
          a response message to be shown in the response page
protected  String multipleSubmitErrorMsg
          a response message to be shown when multiple submit occur
protected  String newType
          the type where the new operation is made
protected  ResponderOperation op
          the operation handler, computed from the operation
protected  String operation
          the operation name: add, edit, delete, new, simple
protected  String originatingPageName
           
protected  boolean reloadFormOnError
          Stores whether we shall reload this form on a validation error or not.
static String responderName
          the name of the CGI parameter that passes the responder key, so the responder can be retrieved from the cache, "__makumba__responder__"
protected  String resultAttribute
          new and add responders set their result to a result attribute
protected  String resultLabel
          the name of the resultLabel used in the resultList of a search form
protected  String searchType
          the type where the search operation is made
protected  String storedParentSuffix
           
protected  String storedSuffix
          the form suffix, "" for the root form, _+increment for subforms
protected static char suffixSeparator
           
protected  String triggerEvent
          the event to be fired when the responder responds
 
Constructor Summary
Responder()
           
 
Method Summary
 void addMultiFieldSearchMapping(String name, String[] allFieldNames)
           
static String errorMessage(Throwable t)
          formats an error message
static String errorMessageFormatter(String message)
          formats an error message
 String getAddField()
           
 String getAfterHandler()
           
 String getBasePointerType()
           
 Object getController()
           
 String getDatabase()
           
 String getDefaultMatchMode(String inputName)
           
 ResponderFactory getFactory()
           
 String getFormName()
           
 ArrayList<String> getFormOrder()
           
 String getHandler()
           
 Pointer getHttpBasePointer(HttpServletRequest req, String suffix)
          reads the HTTP base pointer
abstract  Dictionary<String,Object> getHttpData(HttpServletRequest req, String suffix)
          Reads the data needed for the logic operation, from the http request.
 String[] getMultiFieldSearchCriterion(String name)
           
 String getNewType()
           
 String getOriginatingPageName()
           
 int getPrototype()
          get the integer key of this form, and register it if not already registered
 boolean getReloadFormOnError()
           
 String getResultLabel()
           
 String getSearchType()
           
 boolean getShowFormAnnotated()
           
 String getSuffix()
           
 String getTriggerEvent()
           
abstract  ArrayList<InvalidValueException> getUnassignedExceptions(CompositeValidationException e, ArrayList<InvalidValueException> unassignedExceptions, String suffix)
           
protected abstract  void postDeserializaton()
           
 String responderKey()
          a key that should identify this responder among all
 void saveResponderToDisc()
          Save this responder instance as a binary object to the disc; persist it so it can be read from the disc into the cache on a server reload / restart.
 void setAddField(String s)
          pass the field to which the add operation is made
 void setAfterHandler(String afterHandler)
          pass the response afterHandler, if other than the default one
 void setBasePointerType(String basePointerType)
          pass the base pointer type, needed for the response
 void setClientSideValidation(String clientSideValidation)
           
 void setDefaultMatchMode(String inputName, String matchMode)
           
 void setFactory(ResponderFactory factory)
           
 void setFormId(String id)
          passes the HTML ID of the form, either generated or provided by the user, enriched with form iteration
 void setFormName(String formName)
           
 void setHandler(String handler)
          pass the response handler, if other than the default one
 void setHttpRequest(HttpServletRequest req)
          pass the http request, so the responder computes its default controller and database
 void setMessage(String message)
          pass the form response message
 void setMultipleSubmitErrorMsg(String multipleSubmitErrorMsg)
          pass the multiple submit response message
 void setNewType(DataDefinition dd)
          pass the type on which the new operation is made
 void setOperation(String operation, ResponderOperation op)
          pass the operation *
 void setOriginatingPageName(String originatingPageName)
           
 void setParentResponder(Responder resp, Responder root)
          pass the parent responder
 void setReloadFormOnError(boolean reloadFormOnError)
           
 void setResponderOrder(ArrayList<String> formOrder)
           
 void setResultAttribute(String resultAttribute)
          pass the name of the result attribute
 void setResultLabel(String resultLabel)
          set the name of the resultLabel used in the resultList of a search form
 void setSearchType(DataDefinition dd)
          pass the type on which the new operation is made
 void setShowFormAnnotated(boolean showFormAnnotated)
           
 void setTriggerEvent(String e)
          pass the event to be fired after form submission
static String successFulMessageFormatter(String message)
          formats a successful message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

responderName

public static final String responderName
the name of the CGI parameter that passes the responder key, so the responder can be retrieved from the cache, "__makumba__responder__"

See Also:
Constant Field Values

formSessionName

protected static final String formSessionName
prevents multiple submission of the same form (bug #190), computes as responder+sessionID, "__makumba__formSession__"

See Also:
Constant Field Values

FORM_RESULTS

protected static final String FORM_RESULTS
See Also:
Constant Field Values

defaultMessageSearchForm

public static final String defaultMessageSearchForm
the default response message for search forms, "Search done!"

See Also:
Constant Field Values

basePointerName

public static final String basePointerName
the name of the CGI parameter that passes the base pointer, see basePointerType, "__makumba__base__"

See Also:
Constant Field Values

factory

protected transient ResponderFactory factory

identity

protected int identity
the responder key, as computed from the other fields


controller

protected transient Object controller
the controller object, on which the handler method that performs the operation is invoked


controllerClassname

protected String controllerClassname
store the name of the controller class


database

protected String database
the database in which the operation takes place


message

protected String message
a response message to be shown in the response page


multipleSubmitErrorMsg

protected String multipleSubmitErrorMsg
a response message to be shown when multiple submit occur


clientSideValidation

protected String clientSideValidation
Stores whether we shall do client-side validation, i.e. with javascript for a FormResponder


reloadFormOnError

protected boolean reloadFormOnError
Stores whether we shall reload this form on a validation error or not. Used by ControllerFilter to decide on the action.


originatingPageName

protected String originatingPageName

resultAttribute

protected String resultAttribute
new and add responders set their result to a result attribute


resultLabel

protected String resultLabel
the name of the resultLabel used in the resultList of a search form


formId

protected String formId
HTML ID of the form


handler

protected String handler
the business logic handler, for all types of forms


afterHandler

protected String afterHandler
the business logic after handler, for all types of forms


basePointerType

protected String basePointerType
edit, add and delete makumba operations have a special pointer called the base pointer


searchType

protected String searchType
the type where the search operation is made


formName

protected String formName
the name of the form we operate on (only needed for search forms).


newType

protected String newType
the type where the new operation is made


addField

protected String addField
the field on which the add operation is made


operation

protected String operation
the operation name: add, edit, delete, new, simple


triggerEvent

protected String triggerEvent
the event to be fired when the responder responds


op

protected ResponderOperation op
the operation handler, computed from the operation


formOrder

protected ArrayList<String> formOrder
order of the forms in the page *


defaultMatchModes

protected HashMap<String,String> defaultMatchModes

groupCounter

transient int groupCounter
the form counter, 0 for the root form, one increment for each subform of this form


storedSuffix

protected transient String storedSuffix
the form suffix, "" for the root form, _+increment for subforms


storedParentSuffix

protected transient String storedParentSuffix

suffixSeparator

protected static final char suffixSeparator
See Also:
Constant Field Values
Constructor Detail

Responder

public Responder()
Method Detail

getDefaultMatchMode

public String getDefaultMatchMode(String inputName)

setDefaultMatchMode

public void setDefaultMatchMode(String inputName,
                                String matchMode)

getHandler

public String getHandler()

getAfterHandler

public String getAfterHandler()

getAddField

public String getAddField()

getBasePointerType

public String getBasePointerType()

getController

public Object getController()

getDatabase

public String getDatabase()

getNewType

public String getNewType()

getSearchType

public String getSearchType()

getResultLabel

public String getResultLabel()

getFormName

public String getFormName()

getFormOrder

public ArrayList<String> getFormOrder()

setHttpRequest

public void setHttpRequest(HttpServletRequest req)
                    throws LogicException
pass the http request, so the responder computes its default controller and database

Throws:
LogicException

setOperation

public void setOperation(String operation,
                         ResponderOperation op)
pass the operation *


setMessage

public void setMessage(String message)
pass the form response message


setTriggerEvent

public void setTriggerEvent(String e)
pass the event to be fired after form submission


setMultipleSubmitErrorMsg

public void setMultipleSubmitErrorMsg(String multipleSubmitErrorMsg)
pass the multiple submit response message


setReloadFormOnError

public void setReloadFormOnError(boolean reloadFormOnError)

getReloadFormOnError

public boolean getReloadFormOnError()

setOriginatingPageName

public void setOriginatingPageName(String originatingPageName)

getOriginatingPageName

public String getOriginatingPageName()

setShowFormAnnotated

public void setShowFormAnnotated(boolean showFormAnnotated)

getShowFormAnnotated

public boolean getShowFormAnnotated()

getTriggerEvent

public String getTriggerEvent()

setClientSideValidation

public void setClientSideValidation(String clientSideValidation)

setHandler

public void setHandler(String handler)
pass the response handler, if other than the default one


setAfterHandler

public void setAfterHandler(String afterHandler)
pass the response afterHandler, if other than the default one


setBasePointerType

public void setBasePointerType(String basePointerType)
pass the base pointer type, needed for the response


setResultAttribute

public void setResultAttribute(String resultAttribute)
pass the name of the result attribute


setResultLabel

public void setResultLabel(String resultLabel)
set the name of the resultLabel used in the resultList of a search form


setFormId

public void setFormId(String id)
passes the HTML ID of the form, either generated or provided by the user, enriched with form iteration


setAddField

public void setAddField(String s)
pass the field to which the add operation is made


setNewType

public void setNewType(DataDefinition dd)
pass the type on which the new operation is made


setSearchType

public void setSearchType(DataDefinition dd)
pass the type on which the new operation is made


setFormName

public void setFormName(String formName)

setResponderOrder

public void setResponderOrder(ArrayList<String> formOrder)

postDeserializaton

protected abstract void postDeserializaton()

responderKey

public String responderKey()
a key that should identify this responder among all


getPrototype

public int getPrototype()
get the integer key of this form, and register it if not already registered


setParentResponder

public void setParentResponder(Responder resp,
                               Responder root)
pass the parent responder


getSuffix

public String getSuffix()

errorMessage

public static String errorMessage(Throwable t)
formats an error message


errorMessageFormatter

public static String errorMessageFormatter(String message)
formats an error message


successFulMessageFormatter

public static String successFulMessageFormatter(String message)
formats a successful message


getHttpBasePointer

public Pointer getHttpBasePointer(HttpServletRequest req,
                                  String suffix)
reads the HTTP base pointer


getHttpData

public abstract Dictionary<String,Object> getHttpData(HttpServletRequest req,
                                                      String suffix)
Reads the data needed for the logic operation, from the http request. FormResponder provides an implementation

Parameters:
req - the request corresponding to the current page
suffix - the responder / form suffix
Returns:
a Dictionary holding the data read by the logic

getUnassignedExceptions

public abstract ArrayList<InvalidValueException> getUnassignedExceptions(CompositeValidationException e,
                                                                         ArrayList<InvalidValueException> unassignedExceptions,
                                                                         String suffix)

getFactory

public ResponderFactory getFactory()

setFactory

public void setFactory(ResponderFactory factory)

addMultiFieldSearchMapping

public void addMultiFieldSearchMapping(String name,
                                       String[] allFieldNames)

getMultiFieldSearchCriterion

public String[] getMultiFieldSearchCriterion(String name)

saveResponderToDisc

public void saveResponderToDisc()
Save this responder instance as a binary object to the disc; persist it so it can be read from the disc into the cache on a server reload / restart.