org.sandev.tools.HTTP
Class AbstractXHTMLFormAdaptor

java.lang.Object
  extended byorg.sandev.tools.HTTP.AbstractXHTMLFormAdaptor
All Implemented Interfaces:
org.sandev.basics.util.UIFormAdaptor
Direct Known Subclasses:
THD_XHTMLFormAdaptor

public abstract class AbstractXHTMLFormAdaptor
extends java.lang.Object
implements org.sandev.basics.util.UIFormAdaptor

A base class for converting a UIFormContext into an XHTML form, and reconstructing it from the posted form data. This class holds general framework methods which don't need to be generated from the structs.

Metatypes are supported through the title field available with most XHTML tags. In the absence of a metatype declaration for a field, a default metatype is sometimes generated to allow for easier trapping of certain situations. These types are:

The following metatypes are also supported:

Representational conventions:

The output generated here has the following general format:

There are default breaks and other information added for default formatting. To see the raw output, uncomment the line in XSLTransformer.tranform that dumps the generated source to the log.


Field Summary
protected  boolean[] actionSupportMap
          A map of UIFormContext ACTION constants to boolean flags.
protected  java.lang.String[] actionTextMap
          A map of UIFormContext ACTION constants to text values.
static int CSVARRAY_LENGTHMAX
          If we are displaying an array as a CSV string, then use this value as the LENGTHMAX.
static int CSVARRAY_LENGTHNORM
          If we are displaying an array as a CSV string, then use this value as the LENGTHNORM.
static java.lang.String CURRINSTPRFX
          A prefix used to distinguish data for the currInst data member of the UIFormContext.
static java.lang.String DEFAULTFORMNAME
          If no form name is specified, then presumably we are just dealing with a single form.
static java.lang.String DELIMITER
          A delimiter for field actions, which have multiple component values.
static int DUMPMODE_EDIT
          Indicates that the message should be dumped out for context save purposes and the fields should be editable by the user.
static int DUMPMODE_FIND
          Indicates that the message should be dumped out for context save purposes and the fields should support entry of match expressions by the user.
static int DUMPMODE_HIDDEN
          Indicates that the message or field should be dumped out for context save purposes only and should not be visible in the rendered form display.
static int DUMPMODE_NODUMP
          Indicates the field should not be dumped out since there is no access to it.
static int DUMPMODE_READONLY
          Indicates that the message should be dumped out for context save purposes and be visible to the user, but not be editable.
static java.lang.String FIELD_ACTION
          A prefix to identify buttons for specific fields in the form.
static java.lang.String FIELDLINEBREAK
          We need to have an XHTML line break after each field display so that a generated UI is at least vaguely readable without any XSL templates applied.
static java.lang.String FINDCOLLPRFX
          A prefix used to distinguish data for the findCollection data member of the UIFormContext.
static java.lang.String FINDQUERYPRFX
          A prefix used to distinguish data for the findQuery data member of the UIFormContext.
static java.lang.String FORM_ACTION
          A prefix to identify the main buttons for the form.
protected  java.lang.String hiddenFieldValue
          The value to use when the field value cannot be displayed for security or other filtering reasons.
static java.lang.String RADIOPRFX
          A prefix used for radio button selection within a form.
protected  boolean readOnlyOverride
          Whether read only data should displayed or not.
static java.lang.String ROOTMSGPRFX
          A prefix used to distinguish data for the rootMsg data member of the UIFormContext.
protected static java.text.DateFormat staticDateFormat
          Retrieving a DateFormat object multiple times is wasteful and potentially very inneficient.
protected static int SUBINSTCREATE_ANY
           
protected static int SUBINSTCREATE_CONTAINED_ONLY
           
protected static int SUBINSTCREATE_UNDEFINED
           
static int TEXTBOX_THRESHOLD
          Any string whose normal length is longer than this value will be displayed as a textbox.
static java.lang.String TEXTENCODED
          Indicator text used when a parameter value has been encoded to preserve formatting.
static java.lang.String UIQUERYPRFX
          A prefix to distinguish data for the userQuery data member of the UIFormContext
static java.lang.String UPDATESPRFX
          A prefix used to distinguish data for the updates data member of the UIFormContext.
 
Fields inherited from interface org.sandev.basics.util.UIFormAdaptor
SANDUILINK_REGEXP
 
Constructor Summary
AbstractXHTMLFormAdaptor()
          Default ctor calls init
 
Method Summary
protected  int accessForClass(org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, java.lang.String classname)
          Returns the access the user has for the specified class.
protected  int accessForInstance(org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, org.sandev.basics.structs.SandMessage msg)
          Returns the access the user has for the specified instance.
 boolean actionSupportMapValid(boolean[] map)
          Do a quick check of the given map to make sure it seems reasonable.
 boolean actionTextMapValid(java.lang.String[] map)
          Do a quick check of the given map to make sure it seems reasonable.
 java.lang.String actionToText(int action)
          Given a UIFormContext ACTION constant, return the associated text value for it given our current action map.
 boolean allowEditReadOnly()
          accessor for readOnlyOverride
protected  int computeFieldDumpMode(int dumpMode, org.sandev.basics.structs.SandMessage msg, java.lang.String fieldname, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, boolean isTransientField, boolean isReadOnlyField, boolean overrideReadOnly)
          Return the dump mode for this field based on the given mode and the authorization.
protected  java.lang.String convertMultiSelect(java.lang.String value, java.lang.String classname, java.lang.String fieldname, java.lang.String printname, java.lang.String[] declTextVals, java.lang.String[] constNames, java.lang.String[] actualVals)
          Undo the conversion of the dumpMultiSelect* methods, so that the result is the declared text value.
protected  java.lang.String convertSandUILinks(java.lang.String value)
          Convert links within a SandUI as specified in the UIFormAdaptor conventions.
protected  void debug(java.lang.String text)
          Dump out the debug text.
protected  void decodeFieldAction(java.lang.String context, org.sandev.basics.util.UIFormContext uifc, java.util.Map params)
          Decode the given context and update the uifc accordingly.
protected  java.lang.String decodeSelection(java.lang.String loc, java.lang.String formName, java.util.Map params)
          Find the corresponding radio button for this array field action, and return an updated field location if a radio button was selected.
protected  void disableUnauthorizedActions(org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter)
          If the user is not authorized for an action that would otherwise be enabled, then disable it.
protected  void doFieldAdd(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for field add action.
protected  void doFieldDelete(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for field delete action.
protected  void doFieldDeref(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for the field deref action.
protected  void doFieldDrilldown(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for the field drilldown action.
protected  void doFieldFind(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for field find action.
protected  void doFieldMove(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for field MOVEUP or MOVEDOWN action.
protected  void doFieldRemove(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for field remove action.
protected  void doFieldSelect(java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Set up for field select action.
protected  void dumpActionButtons(java.io.PrintWriter out, java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.UIFormAdaptorCallback callback, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter)
          Dump out buttons for the top level actions.
protected  void dumpArrayAssociation(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, org.sandev.basics.util.ArrayAssociation choices)
          dump out the ArrayAssociation so it can be reconstructed on read.
protected  void dumpBinaryInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String value)
          Override for implementations that require support for specific data encodings.
protected  void dumpBinaryOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, int dumpMode, java.lang.String value)
          Override for implementations that require support for specific data encodings.
protected  void dumpComment(java.io.PrintWriter out, java.lang.String text)
          Dumps out comment text.
protected  void dumpComputedStringOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String name, java.lang.String value)
          A utility method for dumping out an attribute value which is used for display purposes.
protected  void dumpDateInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.util.Date value, java.lang.String range)
          Dump out an editable representation of a Date value.
protected  void dumpDateOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, int dumpMode, java.util.Date value)
          Dump out a read only representation of a Date value.
protected  void dumpDecimalInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, double value, int decimals, java.lang.String range)
          Creates an input field for a decimal value.
protected  void dumpDecimalOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, int dumpMode, double value, int decimals)
          Creates a read only representation of a decimal value.
protected  void dumpFakeFields(java.io.PrintWriter out, org.sandev.basics.util.UIFormContext uifc, java.lang.String prefix)
          Some things are worth dumping out for informational purposes even though they aren't really form fields.
protected  java.lang.String dumpFormContext(java.io.PrintWriter out, java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.UIFormAdaptorCallback callback, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter)
          Render the form in XHTML.
protected  java.lang.String dumpFormContext(java.io.PrintWriter out, java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.UIFormAdaptorCallback callback, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, boolean allowMultiLevelEdit)
          Workhorse method for the dumpFormContext method wihtout the boolean override.
 void dumpFormOutput(org.sandev.basics.util.UIRenderOutput uiro, java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.UIFormAdaptorCallback callback, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter)
          Given a form context, write it out as HTML with enough hidden parameters that we can reconstruct it on return.
protected  void dumpHiddenParam(java.io.PrintWriter out, java.lang.String param, java.lang.String val)
          Dumps out a hidden parameter value pair.
protected  void dumpHiddenParamWithID(java.io.PrintWriter out, java.lang.String param, java.lang.String val)
          Same as standard dumpHiddenParam but adds the name as the id.
protected  void dumpIntegerInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, long value, java.lang.String range)
          Creates an editable representation of an integer value.
protected  void dumpIntegerOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, int dumpMode, long value)
          Creates a read only representation of an integer value.
protected  void dumpMatchInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String val)
          Creates a free text input field with associated label.
protected abstract  java.lang.String dumpMessage(java.io.PrintWriter out, java.lang.String prefix, org.sandev.basics.structs.SandMessage msg, int dumpMode, org.sandev.basics.util.UIFormAdaptorCallback callback, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, boolean overrideReadOnly, java.lang.String selectionField, org.sandev.basics.structs.SandUpdateMessage[] outstandingUpdates, int subCreate)
          Given an output writer and a prefix used to uniquely identify the data members for this message, dump the message in the output form specified, in accordance with the authorization visibility.
protected  void dumpMessageArrayInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String selection, java.lang.String msgclass, org.sandev.basics.structs.SandMessage[] msgs, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, boolean isReference, int subCreate, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Like dumpMessageInput but for an array.
protected  void dumpMessageArrayOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String classname, int dumpMode, org.sandev.basics.structs.SandMessage[] msgs, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, int action, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Like dumpMessageOutput, but for an array of elements.
protected  void dumpMessageInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String msgclass, org.sandev.basics.structs.SandMessage msg, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, boolean isReference, int subCreate, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Dumps out an editing representation of a contained or referenced message for display purposes.
protected  void dumpMessageInputHeader(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String relpos, java.lang.String msgclass, int[] actions)
          Dump the first part of a message input
protected  void dumpMessageItem(java.io.PrintWriter out, java.lang.String formName, int action, java.lang.String className, java.lang.String relpos, org.sandev.basics.structs.SandMessage msg, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Worker method for dumpMessageOutput and dumpMessageArrayOutput
protected  void dumpMessageOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, int dumpMode, java.lang.String fieldtype, org.sandev.basics.structs.SandMessage msg, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, int action, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Dumps out a read only representation of a contained or referenced message for display purposes.
protected  void dumpMultiSelectInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String declaredTextValue, java.lang.String[] declTextVals, java.lang.String[] constNames, java.lang.String[] actualVals)
          Like dumpMultiSelectOutput, but with the arrays needed to generate dropdown selection lists.
protected  void dumpMultiSelectOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, int dumpMode, java.lang.String declaredTextValue, java.lang.String constantName, java.lang.String actualValue)
          Creates a read only representation of an enumerated type value.
static void dumpOutputText(java.io.PrintWriter out, java.lang.String text)
          The UIFormContext contains output text, which is typically an informational message to the user.
 void dumpPageFooter(org.sandev.basics.util.UIRenderOutput uiro, java.lang.String closure)
          dump the HTML footer
 void dumpPageHeader(org.sandev.basics.util.UIRenderOutput uiro, java.lang.String title)
          dump the HTML header
protected  void dumpQuickFindHeader(java.io.PrintWriter out, java.lang.String formName)
          Write out an explanatory header for our find form.
protected  void dumpScriptFunctions(java.io.PrintWriter out)
          Dump out any script functions we need for the form.
protected  void dumpSelectionItem(java.io.PrintWriter out, java.lang.String prefix, org.sandev.basics.structs.SandInstanceMessage msg, int index, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Creates a selection item.
protected  void dumpStringInput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, java.lang.String value, int lengthnorm, int lengthmax, boolean noecho)
          Dump out an editable representation of a String value.
protected  void dumpStringOutput(java.io.PrintWriter out, java.lang.String prefix, java.lang.String fieldname, java.lang.String printname, java.lang.String metatype, int dumpMode, java.lang.String value, int lengthnorm, int lengthmax, boolean noecho, boolean autoconvert, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Dump out a read only representation of a String value.
protected  void dumpTextButton(java.io.PrintWriter out, java.lang.String classname, java.lang.String name, java.lang.String value)
          Creates a button with the given name and value.
protected  void dumpUserQuery(java.io.PrintWriter out, java.lang.String pre, org.sandev.basics.sandmessages.UIFormQuery uiq, org.sandev.basics.util.UIFormAdaptorCallback callback, org.sandev.basics.util.AuthUser user)
          Dump the UIFormQuery if we have one.
protected  void errout(java.lang.StringBuffer outText, java.lang.String text)
          Append the given output text to the given string buffer and write it out to the log also.
protected  int fieldAccess(org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, org.sandev.basics.structs.SandMessage msg, java.lang.String fieldname)
          Return the field level access of this user for this field.
protected  java.lang.String genDescription(org.sandev.basics.structs.SandMessage msg, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Given a SandMessage, generate a single line description for it.
 boolean[] getActionSupportMap()
          Accessor for actionSupportMap
 java.lang.String[] getActionTextMap()
          Accessor for actionTextMap
protected  java.text.DateFormat getDateFormat()
          Initializing accessor for staticDateFormat
 boolean[] getDefaultActionSupportMap()
          Return a default action mapping array
 java.lang.String[] getDefaultActionTextMap()
          Return a default action mapping array.
 org.sandev.basics.util.UIFormContext getFormContext(org.sandev.basics.util.UIRenderInput uiri, java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.UIFormAdaptorCallback callback)
          See UIFormAdaptor interface specification.
 java.lang.String getHiddenFieldValue()
          Accessor for hiddenFieldValue, defaulted appropriately if null
abstract  org.sandev.basics.util.InstanceClassEnumerator getInstanceClassEnumerator()
          Return an InstanceClassEnumerator for the UIFormManager or other caller to use.
protected static java.lang.String getParam(java.util.Map params, java.lang.String key)
          Utility for retrieving single-valued string parameters.
protected static java.lang.String[] getParams(java.util.Map params, java.lang.String key)
          Like the singular getParam method, but returns all the matching values.
 org.sandev.basics.util.UIRenderInput getUIRenderInput()
          Returns a new ServletInput object.
 org.sandev.basics.util.UIRenderOutputDirect getUIRenderOutputDirect()
          Returns null.
 org.sandev.basics.util.UIRenderOutputStream getUIRenderOutputStream()
          Returns a new ServletOutput object.
 org.sandev.basics.util.UIRenderOutputString getUIRenderOutputString()
          Returns a new ServletOutputString object.
protected  int getUpdateAuth(org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, int action)
          Figure out what the authorization is for this action type and return it.
protected  org.sandev.basics.structs.SandUpdateMessage getUpdateMessageInstance(java.lang.String classname)
          Given the name of a SandUpdateMessage, return an instance of it.
protected  java.lang.String getValForAttr(java.lang.String attr, org.sandev.basics.structs.SandAttrVal[] attrvals)
          Looks up the specified attr in the attrvals and returns the val.
protected  void init()
          Set our action map to the default map.
protected  org.sandev.basics.util.ArrayAssociation loadArrayAssociation(java.lang.String prefix, java.util.Map params, java.lang.String fieldname)
          reconstruct the ArrayAssociation.
protected  void loadFormContext(java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, java.util.Map params, org.sandev.basics.util.UIFormAdaptorCallback callback)
          Load the given form context from the parameters given.
protected abstract  org.sandev.basics.structs.SandMessage loadMessage(java.lang.String prefix, java.util.Map params, java.lang.StringBuffer outText)
          Given a prefix used to uniquely identify the data members for this message, and a parameter map, reconstruct the message and return it.
protected  org.sandev.basics.sandmessages.UIFormQuery loadUserQuery(java.lang.String pre, java.util.Map params, java.lang.StringBuffer outText)
          Load the UIFormQuery if we had one.
abstract  org.sandev.basics.structs.SandInstanceMessage newInstanceMessage(java.lang.String classtype)
          Given the short class name of a SandInstanceMessage, return a new object instance of that class.
protected  org.sandev.basics.structs.SandMessage resolveUpdate(org.sandev.basics.structs.SandMessage msg, long refID, org.sandev.basics.structs.SandUpdateMessage[] updates)
          Return the pending update version of this message if there is one, otherwise return what was given.
protected  org.sandev.basics.structs.SandMessage[] resolveUpdates(org.sandev.basics.structs.SandMessage[] msgs, long[] refs, org.sandev.basics.structs.SandUpdateMessage[] updates)
          Overwrite the information in the msgs array with the more recent information from the outstanding updates.
 void setActionSupportMap(boolean[] actionFlags)
          Mutator for actionSupportMap
 void setActionTextMap(java.lang.String[] actionNames)
          Mutator for actionTextMap
 void setAllowEditReadOnly(boolean val)
          mutator for readOnlyOverride
 void setHiddenFieldValue(java.lang.String val)
          Mutator for hiddenFieldValue
protected  void setupAction(java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, java.util.Map params)
          Find what button the user pressed and update the uifc accordingly to setup for action processing.
protected  void setupFieldAction(int action, java.lang.String classtype, java.lang.String subpos, org.sandev.basics.util.UIFormContext uifc)
          Given an action to be applied to a field within the current form, update the UIFormContext appropriately.
protected  void setupFieldAction(java.lang.String formName, org.sandev.basics.util.UIFormContext uifc, java.util.Map params)
          Checks if a field action button by searching the parameter map for anything starting with FIELD_ACTION.
protected  int supportsSubInstanceCreation(org.sandev.basics.util.UIFormContext uifc)
          Return SUBINSTCREATE_UNDEFINED if we are editing a new instance that is contained within another instance that we are already editing.
 int textToAction(java.lang.String text)
          Given the text value of an action, return the associated UIFormContext ACTION constant for it.
protected static java.lang.String trapLinksFormat(java.lang.String input)
          This is text string output formatting.
protected  int valueAccess(org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, org.sandev.basics.structs.SandMessage msg, java.lang.String fieldname)
          Return the value level access for this user for this field.
protected  void verifyClassAccess(org.sandev.basics.util.AuthUser user, org.sandev.basics.util.AuthFilter filter, java.lang.String classname)
          Throw an exception if this user is not allowed to see the given class type.
protected  java.lang.String verifyDefaultAction(java.lang.String currAction, org.sandev.basics.util.UIFormContext uifc, java.lang.String formName, java.util.Map params)
          If the action was initiated by the user pressing the enter key, then return the default action for the form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRINSTPRFX

public static final java.lang.String CURRINSTPRFX
A prefix used to distinguish data for the currInst data member of the UIFormContext.

See Also:
Constant Field Values

FINDCOLLPRFX

public static final java.lang.String FINDCOLLPRFX
A prefix used to distinguish data for the findCollection data member of the UIFormContext.

See Also:
Constant Field Values

FINDQUERYPRFX

public static final java.lang.String FINDQUERYPRFX
A prefix used to distinguish data for the findQuery data member of the UIFormContext.

See Also:
Constant Field Values

ROOTMSGPRFX

public static final java.lang.String ROOTMSGPRFX
A prefix used to distinguish data for the rootMsg data member of the UIFormContext.

See Also:
Constant Field Values

UPDATESPRFX

public static final java.lang.String UPDATESPRFX
A prefix used to distinguish data for the updates data member of the UIFormContext.

See Also:
Constant Field Values

UIQUERYPRFX

public static final java.lang.String UIQUERYPRFX
A prefix to distinguish data for the userQuery data member of the UIFormContext

See Also:
Constant Field Values

FORM_ACTION

public static final java.lang.String FORM_ACTION
A prefix to identify the main buttons for the form.

See Also:
Constant Field Values

FIELD_ACTION

public static final java.lang.String FIELD_ACTION
A prefix to identify buttons for specific fields in the form.

See Also:
Constant Field Values

DELIMITER

public static final java.lang.String DELIMITER
A delimiter for field actions, which have multiple component values.

See Also:
Constant Field Values

RADIOPRFX

public static final java.lang.String RADIOPRFX
A prefix used for radio button selection within a form.

See Also:
Constant Field Values

DUMPMODE_NODUMP

public static final int DUMPMODE_NODUMP
Indicates the field should not be dumped out since there is no access to it.

See Also:
Constant Field Values

DUMPMODE_HIDDEN

public static final int DUMPMODE_HIDDEN
Indicates that the message or field should be dumped out for context save purposes only and should not be visible in the rendered form display.

See Also:
Constant Field Values

DUMPMODE_READONLY

public static final int DUMPMODE_READONLY
Indicates that the message should be dumped out for context save purposes and be visible to the user, but not be editable.

See Also:
Constant Field Values

DUMPMODE_EDIT

public static final int DUMPMODE_EDIT
Indicates that the message should be dumped out for context save purposes and the fields should be editable by the user.

See Also:
Constant Field Values

DUMPMODE_FIND

public static final int DUMPMODE_FIND
Indicates that the message should be dumped out for context save purposes and the fields should support entry of match expressions by the user.

See Also:
Constant Field Values

TEXTBOX_THRESHOLD

public static final int TEXTBOX_THRESHOLD
Any string whose normal length is longer than this value will be displayed as a textbox.

See Also:
Constant Field Values

CSVARRAY_LENGTHNORM

public static final int CSVARRAY_LENGTHNORM
If we are displaying an array as a CSV string, then use this value as the LENGTHNORM.

See Also:
Constant Field Values

CSVARRAY_LENGTHMAX

public static final int CSVARRAY_LENGTHMAX
If we are displaying an array as a CSV string, then use this value as the LENGTHMAX.

See Also:
Constant Field Values

DEFAULTFORMNAME

public static final java.lang.String DEFAULTFORMNAME
If no form name is specified, then presumably we are just dealing with a single form. But we still want to have a name for the form to avoid special-case parsing of parameter values. This is the default name used in that case.

See Also:
Constant Field Values

TEXTENCODED

public static final java.lang.String TEXTENCODED
Indicator text used when a parameter value has been encoded to preserve formatting.

See Also:
Constant Field Values

FIELDLINEBREAK

public static final java.lang.String FIELDLINEBREAK
We need to have an XHTML line break after each field display so that a generated UI is at least vaguely readable without any XSL templates applied. But this also needs to be easily identified so formatting templates can pull it if they need to. So it has its own class.

See Also:
Constant Field Values

hiddenFieldValue

protected java.lang.String hiddenFieldValue
The value to use when the field value cannot be displayed for security or other filtering reasons.


readOnlyOverride

protected boolean readOnlyOverride
Whether read only data should displayed or not.


staticDateFormat

protected static java.text.DateFormat staticDateFormat
Retrieving a DateFormat object multiple times is wasteful and potentially very inneficient.


actionTextMap

protected java.lang.String[] actionTextMap
A map of UIFormContext ACTION constants to text values.


actionSupportMap

protected boolean[] actionSupportMap
A map of UIFormContext ACTION constants to boolean flags.


SUBINSTCREATE_UNDEFINED

protected static final int SUBINSTCREATE_UNDEFINED
See Also:
Constant Field Values

SUBINSTCREATE_CONTAINED_ONLY

protected static final int SUBINSTCREATE_CONTAINED_ONLY
See Also:
Constant Field Values

SUBINSTCREATE_ANY

protected static final int SUBINSTCREATE_ANY
See Also:
Constant Field Values
Constructor Detail

AbstractXHTMLFormAdaptor

public AbstractXHTMLFormAdaptor()
Default ctor calls init

Method Detail

getHiddenFieldValue

public java.lang.String getHiddenFieldValue()
Accessor for hiddenFieldValue, defaulted appropriately if null

Specified by:
getHiddenFieldValue in interface org.sandev.basics.util.UIFormAdaptor

setHiddenFieldValue

public void setHiddenFieldValue(java.lang.String val)
Mutator for hiddenFieldValue

Specified by:
setHiddenFieldValue in interface org.sandev.basics.util.UIFormAdaptor

allowEditReadOnly

public boolean allowEditReadOnly()
accessor for readOnlyOverride

Specified by:
allowEditReadOnly in interface org.sandev.basics.util.UIFormAdaptor

setAllowEditReadOnly

public void setAllowEditReadOnly(boolean val)
mutator for readOnlyOverride

Specified by:
setAllowEditReadOnly in interface org.sandev.basics.util.UIFormAdaptor

getDateFormat

protected java.text.DateFormat getDateFormat()
Initializing accessor for staticDateFormat


getActionTextMap

public java.lang.String[] getActionTextMap()
Accessor for actionTextMap

Specified by:
getActionTextMap in interface org.sandev.basics.util.UIFormAdaptor

setActionTextMap

public void setActionTextMap(java.lang.String[] actionNames)
                      throws org.sandev.basics.util.UIFormAdaptorException
Mutator for actionTextMap

Specified by:
setActionTextMap in interface org.sandev.basics.util.UIFormAdaptor
Throws:
org.sandev.basics.util.UIFormAdaptorException

getDefaultActionTextMap

public java.lang.String[] getDefaultActionTextMap()
Return a default action mapping array.

Specified by:
getDefaultActionTextMap in interface org.sandev.basics.util.UIFormAdaptor

actionTextMapValid

public boolean actionTextMapValid(java.lang.String[] map)
Do a quick check of the given map to make sure it seems reasonable.


actionToText

public java.lang.String actionToText(int action)
Given a UIFormContext ACTION constant, return the associated text value for it given our current action map.


textToAction

public int textToAction(java.lang.String text)
Given the text value of an action, return the associated UIFormContext ACTION constant for it. This does a linear search through the array, indexing for a dozen items isn't necessary.


getActionSupportMap

public boolean[] getActionSupportMap()
Accessor for actionSupportMap

Specified by:
getActionSupportMap in interface org.sandev.basics.util.UIFormAdaptor

setActionSupportMap

public void setActionSupportMap(boolean[] actionFlags)
                         throws org.sandev.basics.util.UIFormAdaptorException
Mutator for actionSupportMap

Specified by:
setActionSupportMap in interface org.sandev.basics.util.UIFormAdaptor
Throws:
org.sandev.basics.util.UIFormAdaptorException

getDefaultActionSupportMap

public boolean[] getDefaultActionSupportMap()
Return a default action mapping array

Specified by:
getDefaultActionSupportMap in interface org.sandev.basics.util.UIFormAdaptor

actionSupportMapValid

public boolean actionSupportMapValid(boolean[] map)
Do a quick check of the given map to make sure it seems reasonable.


init

protected void init()
Set our action map to the default map.


getUIRenderInput

public org.sandev.basics.util.UIRenderInput getUIRenderInput()
Returns a new ServletInput object.

Specified by:
getUIRenderInput in interface org.sandev.basics.util.UIFormAdaptor

getUIRenderOutputDirect

public org.sandev.basics.util.UIRenderOutputDirect getUIRenderOutputDirect()
Returns null.

Specified by:
getUIRenderOutputDirect in interface org.sandev.basics.util.UIFormAdaptor

getUIRenderOutputStream

public org.sandev.basics.util.UIRenderOutputStream getUIRenderOutputStream()
Returns a new ServletOutput object.

Specified by:
getUIRenderOutputStream in interface org.sandev.basics.util.UIFormAdaptor

getUIRenderOutputString

public org.sandev.basics.util.UIRenderOutputString getUIRenderOutputString()
Returns a new ServletOutputString object.

Specified by:
getUIRenderOutputString in interface org.sandev.basics.util.UIFormAdaptor

getFormContext

public org.sandev.basics.util.UIFormContext getFormContext(org.sandev.basics.util.UIRenderInput uiri,
                                                           java.lang.String formName,
                                                           org.sandev.basics.util.UIFormContext uifc,
                                                           org.sandev.basics.util.UIFormAdaptorCallback callback)
                                                    throws org.sandev.basics.util.UIFormAdaptorException
See UIFormAdaptor interface specification.

Specified by:
getFormContext in interface org.sandev.basics.util.UIFormAdaptor
Throws:
org.sandev.basics.util.UIFormAdaptorException

dumpFormOutput

public void dumpFormOutput(org.sandev.basics.util.UIRenderOutput uiro,
                           java.lang.String formName,
                           org.sandev.basics.util.UIFormContext uifc,
                           org.sandev.basics.util.UIFormAdaptorCallback callback,
                           org.sandev.basics.util.AuthUser user,
                           org.sandev.basics.util.AuthFilter filter)
                    throws org.sandev.basics.util.UIFormAdaptorException
Given a form context, write it out as HTML with enough hidden parameters that we can reconstruct it on return. This method writes out the HTML header, FORM start/end tags, and HTML footer. These can be removed/altered via post-processing or by calling the submethods directly here.

This method is used only by direct form output displays like the config editor or UI editor (the normal SAND UI display processing is handled by XHTMLScreenAdaptor). It assumes that it is ok to edit messages within messages because the config editor initial data section is a special case. Sincet he other tools don't care, this just allows multi-level editing by default. If we need to switch this later then we change the sig of this method to provide the override flag as a parameter. Doesn't seem worth the effort until that's needed.

Specified by:
dumpFormOutput in interface org.sandev.basics.util.UIFormAdaptor
Throws:
org.sandev.basics.util.UIFormAdaptorException

dumpPageHeader

public void dumpPageHeader(org.sandev.basics.util.UIRenderOutput uiro,
                           java.lang.String title)
                    throws org.sandev.basics.util.UIFormAdaptorException
dump the HTML header

Specified by:
dumpPageHeader in interface org.sandev.basics.util.UIFormAdaptor
Throws:
org.sandev.basics.util.UIFormAdaptorException

dumpPageFooter

public void dumpPageFooter(org.sandev.basics.util.UIRenderOutput uiro,
                           java.lang.String closure)
                    throws org.sandev.basics.util.UIFormAdaptorException
dump the HTML footer

Specified by:
dumpPageFooter in interface org.sandev.basics.util.UIFormAdaptor
Throws:
org.sandev.basics.util.UIFormAdaptorException

loadFormContext

protected void loadFormContext(java.lang.String formName,
                               org.sandev.basics.util.UIFormContext uifc,
                               java.util.Map params,
                               org.sandev.basics.util.UIFormAdaptorCallback callback)
                        throws org.sandev.basics.util.UIFormAdaptorException
Load the given form context from the parameters given. The uifc is assumed to be initialized, so we are only overwriting what we have actually stored. This method only loads the current info, the uifc must be further altered to reflect the action taken.

Throws:
org.sandev.basics.util.UIFormAdaptorException

setupAction

protected void setupAction(java.lang.String formName,
                           org.sandev.basics.util.UIFormContext uifc,
                           java.util.Map params)
                    throws org.sandev.basics.util.UIFormAdaptorException
Find what button the user pressed and update the uifc accordingly to setup for action processing. At this point we have loaded the uifc, and the action is set to whatever was loaded from the params. The user may or may not have pressed a button in this form (it might have been another form or just a page reload). If they did press a button then this method figures out what is going on.

Main buttons for the form (like cancel, edit, ok etc) have only one instance per form, and can be uniquely identified by their text label. Since only one button will be pressed, we can give them all the same name (FORM_ACTION). By looking up the value for the FORM_ACTION parameter, we get back the button text (or null if no main button was pressed). The button text can be converted back into an action through via the action map.

If no FORM_ACTION button was found, then the user may have pressed one of the field buttons (drilldown, add/find, select etc). The field buttons have more context associated with them, and this context is encoded into the field name. All field button names begin with FIELD_ACTION, so to find which field button was pressed we walk the parameter list looking for anything that starts with FIELD_ACTION. When/if we find a field action button, we decode the context to update the uifc.

If neither a FORM_ACTION or FIELD_ACTION is found for this form then this method exits, leaving the uifc unchanged.

Throws:
org.sandev.basics.util.UIFormAdaptorException

verifyDefaultAction

protected java.lang.String verifyDefaultAction(java.lang.String currAction,
                                               org.sandev.basics.util.UIFormContext uifc,
                                               java.lang.String formName,
                                               java.util.Map params)
If the action was initiated by the user pressing the enter key, then return the default action for the form. Otherwise return whatever value we were given. This method prevents the default browser behavior of just executing the first button on the page.

FIND is the default action when FINDING. SAVE is the default action when ADDING or UPDATING. When we are LISTING an object, the default action is to call the init action, so we set the return value to null here.


setupFieldAction

protected void setupFieldAction(java.lang.String formName,
                                org.sandev.basics.util.UIFormContext uifc,
                                java.util.Map params)
                         throws org.sandev.basics.util.UIFormAdaptorException
Checks if a field action button by searching the parameter map for anything starting with FIELD_ACTION. Calls decodeFieldAction if anything was found. This is called from setupAction if no form-level action was taken.

Throws:
org.sandev.basics.util.UIFormAdaptorException

decodeFieldAction

protected void decodeFieldAction(java.lang.String context,
                                 org.sandev.basics.util.UIFormContext uifc,
                                 java.util.Map params)
                          throws org.sandev.basics.util.UIFormAdaptorException
Decode the given context and update the uifc accordingly.

The encoding for a field button is dot separated text with the following elements:

  1. the form name
  2. FIELD_ACTION constant value
  3. action text (as defined in the actionTextMap). So for example this might be one of:
    drill | deref | select | add | find | delete | remove
  4. field class. This is used to set the uifc.currClass.
  5. relative position. This is the field name + the array index (if applicable), to be appended to the uifc.position.

When we are dealing with an operation that is applied across an array field (add/find, delete/remove), then the element index defaults to -1 for the relative position. In the case of an add/find action, this means an array append operation. However the user may have specified where the new element should be inserted by selecting a radio button. In the delete/remove, the user must have selected an array element via radio button.

Throws:
org.sandev.basics.util.UIFormAdaptorException

decodeSelection

protected java.lang.String decodeSelection(java.lang.String loc,
                                           java.lang.String formName,
                                           java.util.Map params)
Find the corresponding radio button for this array field action, and return an updated field location if a radio button was selected. The radio button encoding is dot separated text with the following elements:
  1. the form name
  2. RADIOPRFX constant value
  3. field name + array index (eg elements[2])

This method is also called in response to an action on a non-array reference. In this case loc will not have any array indices, and there won't be an associated radio button either, so we just return the location directly.


setupFieldAction

protected void setupFieldAction(int action,
                                java.lang.String classtype,
                                java.lang.String subpos,
                                org.sandev.basics.util.UIFormContext uifc)
                         throws org.sandev.basics.util.UIFormAdaptorException
Given an action to be applied to a field within the current form, update the UIFormContext appropriately. These state of the uifc must match the preconditions specified for each action in the AbstractFormManager.

In the case where we are editing an existing instance with a password field, and we typo the password confirmation, and then we choose to ADD/DELETE/NEW/FIND/REMOVE a field, we should not continue since there is an error reconstructing the current object and the action won't complete. What happens is we end up changing the position, and then when the user fixes the password field and repeats their action, the position gets updated again. Things go downhill from there, so we trap this and quit immediately.

Throws:
org.sandev.basics.util.UIFormAdaptorException

doFieldDrilldown

protected void doFieldDrilldown(java.lang.String classtype,
                                java.lang.String subpos,
                                org.sandev.basics.util.UIFormContext uifc)
                         throws org.sandev.basics.util.UIFormAdaptorException
Set up for the field drilldown action. A drilldown is only possible when uifc.rootMsg is set, and one of the fields contains another object instance.

Preconditions:

Postconditions:

Throws:
org.sandev.basics.util.UIFormAdaptorException

doFieldDeref

protected void doFieldDeref(java.lang.String classtype,
                            java.lang.String subpos,
                            org.sandev.basics.util.UIFormContext uifc)
                     throws org.sandev.basics.util.UIFormAdaptorException
Set up for the field deref action. A dereference is only possible if we were displaying a reference off uifc.currInst.

Preconditions:

Postconditions:

Throws:
org.sandev.basics.util.UIFormAdaptorException

doFieldSelect

protected void doFieldSelect(java.lang.String classtype,
                             java.lang.String subpos,
                             org.sandev.basics.util.UIFormContext uifc)
                      throws org.sandev.basics.util.UIFormAdaptorException
Set up for field select action. Selection is only possible on a collection of found instances, so we are coming here from having displayed a collection. When we dumped out the collection, we set the relative position portion of the field button encoding to contain the index of the listed element.

Preconditions:

Postconditions:

Throws:
org.sandev.basics.util.UIFormAdaptorException

doFieldAdd

protected void doFieldAdd(java.lang.String classtype,
                          java.lang.String subpos,
                          org.sandev.basics.util.UIFormContext uifc)
                   throws org.sandev.basics.util.UIFormAdaptorException
Set up for field add action.

Preconditions:

Postconditions:

Throws:
org.sandev.basics.util.UIFormAdaptorException

doFieldFind

protected void doFieldFind(java.lang.String classtype,
                           java.lang.String subpos,
                           org.sandev.basics.util.UIFormContext uifc)
                    throws org.sandev.basics.util.UIFormAdaptorException
Set up for field find action. If the user pushed the find bu