jp.terasoluna.fw.web.struts.plugins
Class ResetterPlugIn

java.lang.Object
  extended by jp.terasoluna.fw.web.struts.plugins.ResetterPlugIn
All Implemented Interfaces:
org.apache.struts.action.PlugIn

public class ResetterPlugIn
extends java.lang.Object
implements org.apache.struts.action.PlugIn

Plugin that loads the reset settings of form. At the time of initializing the servlet, PlugIn function loads the settings of form reset function and stores it in the servlet.

Configuration information of form reset definition file (reset.xml) is stored in servlet context as the instance of ResetterResources.
At the time of execution, any Resetter implementation is called from FormEx#reset() method and reset process is performed according to the configuration information which is stored in ResetterResources.
Class that delegates the reset process is any class in which Resetter is implemented.


How to use
To use this function, perform the following settings in Struts configuration file (struts-config.xml).
resetter is the implementation class that performs reset process. (* resetter can be omitted. When it is omitted, use default. Default="jp.terasoluna.fw.web.struts.reset.ResetterImpl") Specify form reset definition file (reset.xml) in resources and form reset rule definition file (reset-rules.xml) in digesterRules. (digesterRules can be omitted.)
 <plug-in className="jp.terasoluna.fw.web.struts.plugins.ResetterPlugIn">
   <set-property
     property="resetter"
     value="jp.terasoluna.fw.web.struts.reset.ResetterImpl"/>
   <set-property
     property="resources"
     value="/WEB-INF/reset.xml"/>
   <set-property
     property="digesterRules"
     value="/WEB-INF/reset-rules.xml"/>
 </plug-in>
 

In form reset definition file (reset.xml), set reset target field for each action.
To use the reset function for specified range, set the "select" attribute to true. (For details, refer to Resetter )
 <reset>
   <action path="/resetAction">
     <property-reset name="field1" />
     <property-reset name="field2" select="true" />
   </action>
   ...
 </reset>
 

To change the public identifier and DTD URL,
override getPublicIdentifier() and getDtdUrl().

See Also:
ActionReset, FieldReset, Resetter, ResetterResources, FormEx, DynaValidatorActionFormEx, ValidatorActionFormEx

Field Summary
private static java.lang.String DEFAULT_RESETTER
          Fully-qualified class name of default resetter class
private static org.apache.commons.digester.Digester digester
          For the information related to the form reset rule definition file (reset-rules.xml), refer to Digester instance which is already set.
private static java.lang.String DIGESTER_RULES_PATH
          This is the path of default form reset definition file (reset.xml).
private  java.lang.String digesterRules
          This is the path of form reset rule definition file (reset-rules.xml).
private  java.lang.String dtdUrl
          DTD path.
private static org.apache.commons.logging.Log log
          Log class.
private  java.lang.String publicIdentifier
          DTD public identifier.
private  java.lang.String resetter
          Fully-qualified class name of resetter class.
private  java.lang.String resourcesPath
          Path of form reset definition file(reset.xml).
 
Constructor Summary
ResetterPlugIn()
           
  .
Method Summary
 void destroy()
          Process at the time of termination.
 java.lang.String getDtdUrl()
          Returns DTD URL. To change DTD URL, override this method.
 java.lang.String getPublicIdentifier()
          Returns public identifier. To change the public identifier, override this method.
 void init(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ModuleConfig config)
          Process at the time of initialization.
protected  void initResetter(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ModuleConfig config)
          Initialization process of reset process class. Fetches the reset process class which is set in Struts configuration file (struts-config.xml). When it is not set, fetches the default reset process class.
protected  void initResources(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ModuleConfig config)
          Reset initialization process. Uses form reset definition file (reset.xml) and form reset rule definition file (reset-rules.xml) and loads the configuration information to ResetterResources
 void setDigesterRules(java.lang.String digesterRules)
          Sets form reset rule definition file (reset-rules.xml).
 void setDtdUrl(java.lang.String dtdUrl)
          Sets DTD URL.
 void setPublicIdentifier(java.lang.String publicIdentifier)
          Sets public identifier.
 void setResetter(java.lang.String string)
          Sets fully-qualified name of resetter which is set in Struts configuration file (struts-config.xml).
 void setResources(java.lang.String string)
          Sets path name of form reset definition file (reset.xml).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log class.


DIGESTER_RULES_PATH

private static final java.lang.String DIGESTER_RULES_PATH
Path of default form reset definition file (reset.xml).

See Also:
Constant Field Values

digester

private static org.apache.commons.digester.Digester digester
For the information related to the form reset rule definition file (reset-rules.xml), refer to the Digester instance which is already set.


DEFAULT_RESETTER

private static final java.lang.String DEFAULT_RESETTER
Fully-qualified class name of default resetter class.


publicIdentifier

private java.lang.String publicIdentifier
DTD public identifier.


dtdUrl

private java.lang.String dtdUrl
DTD path.


resetter

private java.lang.String resetter
Fully-qualified class name of resetter class.P>

resourcesPath

private java.lang.String resourcesPath
Path of form reset definition file (reset.xml).


digesterRules

private java.lang.String digesterRules
Path of form reset rule definition file (reset-rules.xml).

Constructor Detail

ResetterPlugIn

public ResetterPlugIn()
Method Detail

destroy

public void destroy()
Process at the time of termination.

Specified by:
destroy in interface org.apache.struts.action.PlugIn

init

public void init(org.apache.struts.action.ActionServlet servlet,
                 org.apache.struts.config.ModuleConfig config)
          throws javax.servlet.ServletException
Process at the time of initialization.

Specified by:
init in interface org.apache.struts.action.PlugIn
Parameters:
servlet - ActionServlet that has invoked this PlugIn.
config - ModuleConfig of this PlugIn.
Throws:
javax.servlet.ServletException - Exception that wraps the another exception which is generated at the time of initialization.

initResetter

protected void initResetter(org.apache.struts.action.ActionServlet servlet,
                            org.apache.struts.config.ModuleConfig config)
                     throws javax.servlet.ServletException
Initialization process of reset process class. Fetches the reset process class which is set in Struts configuration file (struts-config.xml). When it is not set, fetches default reset process class.

Parameters:
servlet - Servlet which invoked this plugin.
config -Module configuration
Throws:
javax.servlet.ServletException - Exception that occurs during the initialization process of reset process class.

initResources

protected void initResources(org.apache.struts.action.ActionServlet servlet,
                             org.apache.struts.config.ModuleConfig config)
                      throws javax.servlet.ServletException
Reset initialization process. Use form reset definition file (reset.xml) and form reset rule definition file (reset-rules.xml) and loads the configuration file to ResetterResources.

Parameters:
servlet - Servlet which invoked this plugin.
config - Module configuration
Throws:
javax.servlet.ServletException - Exception which occurs when resource file is not found

getPublicIdentifier

public java.lang.String getPublicIdentifier()
Returns public identifier. To change the public identifier, override this method.

Returns:
Public identifier

getDtdUrl

public java.lang.String getDtdUrl()
Returns DTD URL. To change the DTD URL, override this method.

Returns:
DTD URL

setResetter

public void setResetter(java.lang.String string)
Sets fully-qualified name of resetter which is set in Struts configuration file (struts-config.xml).

Parameters:
string - Fully-qualified name of resetter

setResources

public void setResources(java.lang.String string)
Sets path name of form reset definition file (reset.xml).

Parameters:
string - Path name of form reset definition file (reset.xml)

setDigesterRules

public void setDigesterRules(java.lang.String digesterRules)
Sets form reset rule definition file (reset-rules.xml).

Parameters:
digesterRules - Path name of form reset rule definition file (reset-rules.xml)

setPublicIdentifier

public void setPublicIdentifier(java.lang.String publicIdentifier)
Sets public identifier.

Parameters:
publicIdentifier - Public identifier

setDtdUrl

public void setDtdUrl(java.lang.String dtdUrl)
Sets DTD URL.

Parameters:
dtdUrl - DTD URL