com.oroad.stxx.xform
Class AbstractXMLForm

java.lang.Object
  extended byorg.apache.struts.action.ActionForm
      extended bycom.oroad.stxx.xform.AbstractXMLForm
All Implemented Interfaces:
java.io.Serializable, XMLForm
Direct Known Subclasses:
DOMForm, JDOMForm

public abstract class AbstractXMLForm
extends org.apache.struts.action.ActionForm
implements XMLForm, java.io.Serializable

Abstract XMLForm that implements all methods not involving the actual XML library used to store the form. While this class extends the Struts action form, it can be used by containers that have nothing to do with servlets provided the getSchemaStream method is overridden (i.e. a SOAP container).

Author:
Don Brown
See Also:
Serialized Form

Field Summary
protected  java.lang.Object defaultXML
          The default xml document
protected  org.xmlform.Form form
          The underlying XMLForms form
protected  java.lang.String formPath
          The path to the form xml
protected  org.apache.commons.logging.Log log
          The logging instance
protected  java.lang.String name
          The name of the form
protected  java.lang.String phase
          The current validation phase
protected  java.io.InputStream schema
          The path to the schema
protected  java.lang.String schemaNS
          The namespace of the schema
protected  boolean vsEnabled
          If viewstate is enabled
protected  java.lang.Object xml
          The xml document
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
AbstractXMLForm()
          Initializes the log for the current class
 
Method Summary
 org.xmlform.Form getForm()
          Gets the underlying XMLForm form
 java.lang.String getFormPath()
          Gets the form path
protected  org.xmlform.validation.Validator getFormValidator()
          Determines the current validator using the schema namespace and sets the current phase if the validator supports multi-phase validation.
protected  org.apache.commons.logging.Log getLog()
           
 java.lang.String getName()
          Gets the name of the form
 java.lang.String getPhase()
          Gets the validation phase
 java.lang.String getSchemaNS()
          Gets the schema namespace
 java.lang.String getValue(java.lang.String xpath)
          Gets the value at the xpath path
 java.lang.String getValue(java.lang.String xpath, java.lang.String def)
          Gets the value at the xpath path
 boolean isInitialized()
          Determines if the form is initialized
 boolean isViewstateEnabled()
          Gets the validation phase
abstract  void loadState(java.io.InputStream in)
          Loads the XML from the inputstream
abstract  void outputXML(java.io.OutputStream out)
          Serializes the XML
 void prePopulate()
          Called before the form is populated
 void reset()
          Resets the form
 void reset(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
          Resets the form
 java.lang.String save()
          Saves the form and returns a String status code
abstract  void setDefaultXML(org.w3c.dom.Document doc)
          Sets the default xml
 void setForm(org.xmlform.Form form)
          Sets the underlying XMLForm form
 void setFormPath(java.lang.String path)
          Sets the form path
 void setName(java.lang.String name)
          Sets the name of the form
 void setPhase(java.lang.String phase)
          Sets the validation phase
 void setSchema(java.io.InputStream schema)
          Sets the schema path
 void setSchemaNS(java.lang.String schema)
          Sets the schema namespace
 void setValue(java.lang.String xpath, java.lang.Object val)
          Sets the value at the xpath path
 void setViewstateEnabled(boolean val)
          Sets the validation phase
abstract  void setXML(org.w3c.dom.Document doc)
          Sets the form xml
 java.util.List validate()
          Validates the form and generates a list of violations.
 org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
          Validates the form
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, setMultipartRequestHandler, setServlet, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected transient org.apache.commons.logging.Log log
The logging instance


xml

protected java.lang.Object xml
The xml document


defaultXML

protected java.lang.Object defaultXML
The default xml document


form

protected transient org.xmlform.Form form
The underlying XMLForms form


schema

protected java.io.InputStream schema
The path to the schema


schemaNS

protected java.lang.String schemaNS
The namespace of the schema


phase

protected java.lang.String phase
The current validation phase


name

protected java.lang.String name
The name of the form


formPath

protected java.lang.String formPath
The path to the form xml


vsEnabled

protected boolean vsEnabled
If viewstate is enabled

Constructor Detail

AbstractXMLForm

public AbstractXMLForm()
Initializes the log for the current class

Method Detail

getLog

protected org.apache.commons.logging.Log getLog()

loadState

public abstract void loadState(java.io.InputStream in)
Loads the XML from the inputstream

Specified by:
loadState in interface XMLForm
Parameters:
in - The inputstream

setDefaultXML

public abstract void setDefaultXML(org.w3c.dom.Document doc)
Sets the default xml

Specified by:
setDefaultXML in interface XMLForm
Parameters:
doc - The default XML

setXML

public abstract void setXML(org.w3c.dom.Document doc)
Sets the form xml

Specified by:
setXML in interface XMLForm
Parameters:
doc - The default XML

isInitialized

public boolean isInitialized()
Determines if the form is initialized

Specified by:
isInitialized in interface XMLForm
Returns:
True if the form has been initialized

save

public java.lang.String save()
Saves the form and returns a String status code

Specified by:
save in interface XMLForm
Returns:
The status code, null if not implemented

setSchema

public void setSchema(java.io.InputStream schema)
Sets the schema path

Specified by:
setSchema in interface XMLForm
Parameters:
schema - The new schema path

setName

public void setName(java.lang.String name)
Sets the name of the form

Specified by:
setName in interface XMLForm
Parameters:
name - The new name value

getName

public java.lang.String getName()
Gets the name of the form

Specified by:
getName in interface XMLForm
Returns:
The name value

getSchemaNS

public java.lang.String getSchemaNS()
Gets the schema namespace

Specified by:
getSchemaNS in interface XMLForm
Returns:
The schema namespace

setSchemaNS

public void setSchemaNS(java.lang.String schema)
Sets the schema namespace

Specified by:
setSchemaNS in interface XMLForm
Parameters:
schema - The new schema namespace

setFormPath

public void setFormPath(java.lang.String path)
Sets the form path

Specified by:
setFormPath in interface XMLForm
Parameters:
path - The new formPath value

getFormPath

public java.lang.String getFormPath()
Gets the form path

Specified by:
getFormPath in interface XMLForm
Returns:
The form value

isViewstateEnabled

public boolean isViewstateEnabled()
Gets the validation phase

Specified by:
isViewstateEnabled in interface XMLForm
Returns:
The phase value

setViewstateEnabled

public void setViewstateEnabled(boolean val)
Sets the validation phase

Specified by:
setViewstateEnabled in interface XMLForm
Parameters:
val - The new viewstateEnabled value

getPhase

public java.lang.String getPhase()
Gets the validation phase

Specified by:
getPhase in interface XMLForm
Returns:
The phase value

setPhase

public void setPhase(java.lang.String phase)
Sets the validation phase

Specified by:
setPhase in interface XMLForm
Parameters:
phase - The new phase value

setForm

public void setForm(org.xmlform.Form form)
Sets the underlying XMLForm form

Specified by:
setForm in interface XMLForm
Parameters:
form - The new form value

getForm

public org.xmlform.Form getForm()
Gets the underlying XMLForm form

Specified by:
getForm in interface XMLForm
Returns:
The form value

reset

public void reset(org.apache.struts.action.ActionMapping mapping,
                  javax.servlet.http.HttpServletRequest request)
Resets the form

Parameters:
mapping - Description of the Parameter
request - Description of the Parameter

reset

public void reset()
Resets the form

Specified by:
reset in interface XMLForm

outputXML

public abstract void outputXML(java.io.OutputStream out)
Serializes the XML

Specified by:
outputXML in interface XMLForm
Parameters:
out - The outputstream

validate

public java.util.List validate()
Validates the form and generates a list of violations.

Specified by:
validate in interface XMLForm
Returns:
A list of Violations

prePopulate

public void prePopulate()
Called before the form is populated

Specified by:
prePopulate in interface XMLForm

validate

public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
                                                      javax.servlet.http.HttpServletRequest request)
Validates the form

Parameters:
mapping - The action mapping
request - The http request
Returns:
Any errors found

getValue

public java.lang.String getValue(java.lang.String xpath)
Gets the value at the xpath path

Specified by:
getValue in interface XMLForm
Parameters:
xpath - The xpath path
Returns:
The value

getValue

public java.lang.String getValue(java.lang.String xpath,
                                 java.lang.String def)
Gets the value at the xpath path

Specified by:
getValue in interface XMLForm
Parameters:
xpath - The xpath path
def - The default value
Returns:
The value

setValue

public void setValue(java.lang.String xpath,
                     java.lang.Object val)
Sets the value at the xpath path

Specified by:
setValue in interface XMLForm
Parameters:
xpath - The xpath path
val - The value

getFormValidator

protected org.xmlform.validation.Validator getFormValidator()
Determines the current validator using the schema namespace and sets the current phase if the validator supports multi-phase validation.

Returns:
The validator