| java.lang.Object com.jcorporate.expresso.services.controller.ui.DefaultAutoElement
All known Subclasses: com.jcorporate.expresso.services.controller.ui.CacheAutoElement,
DefaultAutoElement | public class DefaultAutoElement implements AutoControllerElement(Code) | | Default implementation of the AutoController Element. Provides a default
unified method for rendering/parsing Inputs from DBObjects
author: Michael Rimov, portions from Adam Rossi, Michael Nash, Shash author: Chatterjee since: Expresso 5.0 |
Method Summary | |
public Block | createDBObjectBlock(ControllerRequest request, ControllerResponse response, DataObject dbobj) Creates a DBObject Block that contains all the non-secret fields for the
DBObject. | public Block | createDBObjectBlock(ControllerRequest request, ControllerResponse response, String title, DataObject dbobj) Creates a DBObject Block that contains all the non-secret fields for the
DBObject.
Parameters: response - The ControllerResponse object Parameters: request - The ControllerRequest Object Parameters: title - The title to give this block. | protected String | displayValue(DataFieldMetaData metaData, Date dt, Locale l) Same as display value but for Date/DateTime types. | protected String | displayValue(DataFieldMetaData metaData, String fieldValue, String fieldName, Locale l) Format a value for display in the HTML being returned to the client
Parameters: metaData - The Field Metadata Parameters: fieldValue - The value of the field Parameters: fieldName - the name of the field to render Parameters: l - The Locale to display the value for. | public static synchronized AutoControllerElement | getAutoControllerElement() Constructor. | public String | getErrorStyle() Returns the style to be used if the Input field has an error with it. | public String | getNormalStyle() | public String | getRequiredDecorator() Returns the string to append to a field label if it is required. | public String | getRequiredStyle() | public DataObject | parseBlock(ControllerRequest request, DataObject oneObject, ErrorCollection ec) Convienence method if you only expect one DBObject to be returned from a
particular form. | public DataObject[] | parseBlocks(ControllerRequest request, DataObject[] theObjects, ErrorCollection ec) Parses the appropriate DBObject from the block. | public DataObject | parseDBObject(ControllerRequest request, DataObject oneObject, ErrorCollection ec, boolean validate) Parses a dbobject
Parameters: request - The ControllerRequest that contains all the parametersfor parsing. Parameters: oneObject - The DBObject to populate. Parameters: ec - An error Collection to send in for any parsing errors to besaved to. Parameters: validate - Set to true if you want the DBObject validated.Sometimes, like for the DBMaint search form, this is not adesired feature. | public DataObject | parseDBObject(ControllerRequest request, DataObject oneObject, ErrorCollection ec) Convienence method if you only expect one DBObject to be returned from a
particular form, and unlike the ParseBlock, there is no DBOBject name
prefix attached to the parameter names. | public String | parseSingleInput(ControllerRequest request, DataObject dbobj, String fieldName, String parameterName, ErrorCollection ec) Takes the Controller Request and appropriately parses a string for a
particular field. | public Input | renderDBObjectField(ControllerResponse response, DataObject dbobj, String fieldName, String cachedValue, boolean readOnly) Renders a DBOBject Field as either an Input or an Output. | protected Input | renderReadOnlyInput(ControllerResponse response, Input oneField, DataObject dbobj, String fieldName, String oneFieldValue) Modifies an already instantiated Input to be a finished read only
control.
Parameters: response - The ControllerResponse object Parameters: oneField - The input to flesh out. Parameters: dbobj - The data source object Parameters: fieldName - The field name in the dbobj to render. Parameters: oneFieldValue - The value to add to the input control. | protected void | renderReadWriteBlob(ControllerResponse response, Input oneField, DataObject dbobj, String fieldName, String oneFieldValue, String oneFieldSize) Modifies an already instantiated Input to be a finished Input control
specifically for a blob field. | protected Input | renderReadWriteInput(ControllerResponse response, Input oneField, DataObject dbobj, String fieldName, String oneFieldValue, String oneFieldSize) Modifies an already instantiated Input to be a finished Input control
Parameters: response - The ControllerResponse object Parameters: oneField - The input to flesh out. Parameters: dbobj - The data source object Parameters: fieldName - The field name in the dbobj to render. Parameters: oneFieldValue - The value to add to the input control. Parameters: oneFieldSize - The size of the Input control when finished. | protected void | retrieveCachedValueInForm(ControllerResponse response, String oneFieldName, Input i) Used to set values in created db objects to the values found (if any)
in the form cache. |
CLASS_HANDLER_NAME | final public static String CLASS_HANDLER_NAME(Code) | | |
DBOBJECT_LABEL | final public static String DBOBJECT_LABEL(Code) | | |
DEFAULT_CLASS_HANDLER | final public static String DEFAULT_CLASS_HANDLER(Code) | | |
REQUIRED_STYLE | final public static String REQUIRED_STYLE(Code) | | |
log | protected static Logger log(Code) | | |
DefaultAutoElement | protected DefaultAutoElement()(Code) | | The constructor here is protected. Use getAutoControllerElement()
instead to get the instance of this class.
|
createDBObjectBlock | public Block createDBObjectBlock(ControllerRequest request, ControllerResponse response, DataObject dbobj) throws ControllerException(Code) | | Creates a DBObject Block that contains all the non-secret fields for the
DBObject. The Block will have a nested Output that matches DBObject's
description unless one is not supplied in which case the nested Output
will have the title "Untitled"
Parameters: response - The ControllerResponse object Parameters: request - The ControllerRequest Object Parameters: dbobj - The dbObject to automatically render. a rendered block throws: ControllerException - if there's an error rendering the DBObject |
createDBObjectBlock | public Block createDBObjectBlock(ControllerRequest request, ControllerResponse response, String title, DataObject dbobj) throws ControllerException(Code) | | Creates a DBObject Block that contains all the non-secret fields for the
DBObject.
Parameters: response - The ControllerResponse object Parameters: request - The ControllerRequest Object Parameters: title - The title to give this block. The system renders a nestedOutput called "block-title" for the block that contains thisdata. Parameters: dbobj - The dbObject to automatically render. a rendered Block object throws: ControllerException - if there's an error rendering the DBObject |
displayValue | protected String displayValue(DataFieldMetaData metaData, Date dt, Locale l)(Code) | | Same as display value but for Date/DateTime types. Formats things
appropriate to the user's locale
Parameters: metaData - the Data Field's metadata Parameters: dt - The date value to format Parameters: l - the User's Locale gathered from the ControllerResponse object a properly formatted date |
displayValue | protected String displayValue(DataFieldMetaData metaData, String fieldValue, String fieldName, Locale l) throws ControllerException(Code) | | Format a value for display in the HTML being returned to the client
Parameters: metaData - The Field Metadata Parameters: fieldValue - The value of the field Parameters: fieldName - the name of the field to render Parameters: l - The Locale to display the value for. String The formatted field throws: ControllerException - If the field format information could not bedetermined |
getAutoControllerElement | public static synchronized AutoControllerElement getAutoControllerElement() throws ControllerException(Code) | | Constructor. Allows for a classHandler to be used from the
expresso-config.xml if you really need something completely different.
an instantiated AutoControllerElement throws: ControllerException - upon error |
getErrorStyle | public String getErrorStyle()(Code) | | Returns the style to be used if the Input field has an error with it.
java.lang.String a Stylesheet class to render to |
getNormalStyle | public String getNormalStyle()(Code) | | Returns the style to be used if the input has normal non-required
characteristics
java.lang.String a Stylesheet class to render to |
getRequiredDecorator | public String getRequiredDecorator()(Code) | | Returns the string to append to a field label if it is required.
Default is an ""
java.lang.String a Stylesheet class to render to |
getRequiredStyle | public String getRequiredStyle()(Code) | | Returns the style to be used if the Input is required
java.lang.String a Stylesheet class to render to |
parseBlock | public DataObject parseBlock(ControllerRequest request, DataObject oneObject, ErrorCollection ec) throws ControllerException(Code) | | Convienence method if you only expect one DBObject to be returned from a
particular form.
Parameters: request - The ControllerRequest object handed down by the framework Parameters: oneObject - a single dbobject ro dumpt the parsed values into. Parameters: ec - An instantiated ErrorCollection that is filled in with anyerror a filled out DBObject throws: ControllerException - if there's an error parsing the block orcommunicating with the underlying DBObject |
parseBlocks | public DataObject[] parseBlocks(ControllerRequest request, DataObject[] theObjects, ErrorCollection ec) throws ControllerException(Code) | | Parses the appropriate DBObject from the block. Returns the fully
constructed DBOBject including any errors in the DBObject
Parameters: request - The ControllerRequest object handed down by the framework Parameters: theObjects - A pre-instantiated group of DBObjects in which youexpect to have the fields overwritten/filled. By usinginstantiated DBObjects, you can pre-fill any potentially blankfields and thus remove any Errors. Parameters: ec - An instantiated ErrorCollection that is filled in with anyerror An array of parsed DBObjects throws: ControllerException - if there's an error parsing the block orcommunicating with the underlying DBObject throws: IllegalArgumentException - if request, theObjects, or ec is null |
parseDBObject | public DataObject parseDBObject(ControllerRequest request, DataObject oneObject, ErrorCollection ec, boolean validate) throws ControllerException(Code) | | Parses a dbobject
Parameters: request - The ControllerRequest that contains all the parametersfor parsing. Parameters: oneObject - The DBObject to populate. Parameters: ec - An error Collection to send in for any parsing errors to besaved to. Parameters: validate - Set to true if you want the DBObject validated.Sometimes, like for the DBMaint search form, this is not adesired feature. The parsed DBObject [Although oneObject gets populated since noassignment takes place.] So you can ignore this return valueif you desire. throws: IllegalArgumentException - upon data exception. throws: ControllerException - upon controller-related error. |
parseDBObject | public DataObject parseDBObject(ControllerRequest request, DataObject oneObject, ErrorCollection ec) throws ControllerException(Code) | | Convienence method if you only expect one DBObject to be returned from a
particular form, and unlike the ParseBlock, there is no DBOBject name
prefix attached to the parameter names. This is similar to the
ControllerRequest validateDBObject functionality, but we're
consolodating things here.
Parameters: request - The ControllerRequest object handed down by the framework Parameters: oneObject - A DBObject to fill in. Parameters: ec - An instantiated ErrorCollection that is filled in with anyerror a parsed DBObject throws: ControllerException - if there's an error parsing the block orcommunicating with the underlying DBObject |
parseSingleInput | public String parseSingleInput(ControllerRequest request, DataObject dbobj, String fieldName, String parameterName, ErrorCollection ec) throws ControllerException(Code) | | Takes the Controller Request and appropriately parses a string for a
particular field. If the field is a Date, then it parses it as such,
if it is money, then it perses it as such. Etc.
As of Expresso 5.1, the system properly parses multi-part request data.
If a parameter is a file parameter, then it sets the following field
attributes that can be retrieved by:
DataObject.getFieldData(fieldName).getAttribute(attribName);
-
Attribute: fileName - The locally accessible file name to be used for
most likely saving to the database. Use
new
File(fileName) to actually access the uploaded file
-
Attribute: origFileName - The original file name (without path) that was
uploaded to the server through the web browser. This will be different
from the attribute fileName since Expresso will rename the local file
name to prevent naming collisions
-
Attribute: MimeType - The system will make a guess as to the mime type
of the file that was uploaded based upon the file name.
Finally, if the target dbobj is of type MediaDBObject the fields:
'fieldName + "_mimeType"' and 'fieldName +
"_fileName"' will be set with the corresponding mimeType and
origFileName values
Parameters: request - The ControllerRequest object Parameters: dbobj - The DBObject for which we're going to put the field to Parameters: fieldName - The name of the field to parse Parameters: parameterName - The name of the http paramter to parse May be nullin which case, the funciton will by default use the fieldName asthe parameter name. Parameters: ec - An instantiated ErrorCollection object that will be filledwith any parsing errors that may be encountered. java.lang.String for the value. throws: ControllerException - upon parsing error since: Expresso 5.0; Multipart Request Handling since Expresso 5.1 |
renderDBObjectField | public Input renderDBObjectField(ControllerResponse response, DataObject dbobj, String fieldName, String cachedValue, boolean readOnly) throws ControllerException(Code) | | Renders a DBOBject Field as either an Input or an Output. For example,
if we're talking updating, then all key fields are outputs and not
inputs. This function auto-detects whether we are dealing with a add()
or update() situation by checking the DBObject's status. If it's NEW,
then we treat this as an add form, if it is
Parameters: response - The ControllerResponse object Parameters: dbobj - The parameter to render Parameters: fieldName - The name of the field to render Parameters: cachedValue - Any cached form value to put in the field. Parameters: readOnly - - If set to true, then this is automatically a read-onlyfield... if set to false, this function might still render thefield as read-only if, for example, it's a key field. a created Input throws: ControllerException - if there's an error creating the Input Field |
renderReadOnlyInput | protected Input renderReadOnlyInput(ControllerResponse response, Input oneField, DataObject dbobj, String fieldName, String oneFieldValue) throws DBException, ControllerException(Code) | | Modifies an already instantiated Input to be a finished read only
control.
Parameters: response - The ControllerResponse object Parameters: oneField - The input to flesh out. Parameters: dbobj - The data source object Parameters: fieldName - The field name in the dbobj to render. Parameters: oneFieldValue - The value to add to the input control. a read only input throws: DBException - if there's an error communicating with the DBObject throws: ControllerException - if there's an error building the Inputfield. |
renderReadWriteBlob | protected void renderReadWriteBlob(ControllerResponse response, Input oneField, DataObject dbobj, String fieldName, String oneFieldValue, String oneFieldSize) throws DBException, ControllerException(Code) | | Modifies an already instantiated Input to be a finished Input control
specifically for a blob field. If the dbobject is a MediaObject, then
it adds the abilities to view the fields and creates an appropriate
icon.
Parameters: response - The ControllerResponse object Parameters: oneField - The input to flesh out. Parameters: dbobj - The data source object Parameters: fieldName - The field name in the dbobj to render. Parameters: oneFieldValue - The value to add to the input control. Parameters: oneFieldSize - The size of the Input control when finished. throws: DBException - if there's an error communicating with the DBObject throws: ControllerException - if there's an error building the Inputfield. |
renderReadWriteInput | protected Input renderReadWriteInput(ControllerResponse response, Input oneField, DataObject dbobj, String fieldName, String oneFieldValue, String oneFieldSize) throws DBException, ControllerException(Code) | | Modifies an already instantiated Input to be a finished Input control
Parameters: response - The ControllerResponse object Parameters: oneField - The input to flesh out. Parameters: dbobj - The data source object Parameters: fieldName - The field name in the dbobj to render. Parameters: oneFieldValue - The value to add to the input control. Parameters: oneFieldSize - The size of the Input control when finished. a rendered Read/Write Input throws: DBException - if there's an error communicating with the DBObject throws: ControllerException - if there's an error building the Inputfield. |
retrieveCachedValueInForm | protected void retrieveCachedValueInForm(ControllerResponse response, String oneFieldName, Input i) throws ControllerException(Code) | | Used to set values in created db objects to the values found (if any)
in the form cache. (the form cache is what people type into an HTML form,
and if there is an error, we cache those values in order to send back the
form (with error message) and have their typing preserved for the next try.)
Parameters: response - ? Parameters: oneFieldName - ? Parameters: i - The Input to retrieve. See Also: CacheAutoElement |
|
|