Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.xwork2.validator.validators
Class RepopulateConversionErrorFieldValidatorSupport

    java.lang.Object
      com.opensymphony.xwork2.validator.validators.ValidatorSupport
          com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
              com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport

All Implemented Interfaces:
  FieldValidator, ShortCircuitableValidator, Validator

Direct Known Subclasses:
  ConversionErrorFieldValidator

    public abstract class RepopulateConversionErrorFieldValidatorSupport

extends FieldValidatorSupport

An abstract base class that adds in the capability to populate the stack with a fake parameter map when a conversion error has occurred and the 'repopulateField' property is set to "true".

The capability of auto-repopulating the stack with a fake parameter map when a conversion error has occurred can be done with 'repopulateField' property set to "true".

This is typically usefull when one wants to repopulate the field with the original value when a conversion error occurred. Eg. with a textfield that only allows an Integer (the action class have an Integer field declared), upon conversion error, the incorrectly entered integer (maybe a text 'one') will not appear when dispatched back. With 'repopulateField' porperty set to true, it will, meaning the textfield will have 'one' as its value upon conversion error.

     <!-- myJspPage.jsp -->
     <ww:form action="someAction" method="POST">
       ....
       <ww:textfield
           label="My Integer Field"
           name="myIntegerField" />
       ....
       <ww:submit />
     </ww:form>

     <!-- xwork.xml -->
     <xwork>
     <include file="xwork-default.xml" />
     ....
     <package name="myPackage" extends="xwork-default">
       ....
       <action name="someAction" class="example.MyActionSupport.java">
          <result name="input">myJspPage.jsp</result>
          <result>success.jsp</result>
       </action>
       ....
     </package>
     ....
     </xwork>

     <!-- MyActionSupport.java -->
     public class MyActionSupport extends ActionSupport {
        private Integer myIntegerField;

        public Integer getMyIntegerField() { return this.myIntegerField; }
        public void setMyIntegerField(Integer myIntegerField) {
           this.myIntegerField = myIntegerField;
        }
     }

     <!-- MyActionSupport-someAction-validation.xml -->
     <validators>
       ...
       <field name="myIntegerField">
          <field-validator type="conversion">
             <param name="repopulateField">true</param>
             <message>Conversion Error (Integer Wanted)</message>
          </field-validator>
       </field>
       ...
     </validators>

Version:
  $Date: 2006-10-27 07:48:38 +0200 (Fr, 27 Okt 2006) $ $Id: RepopulateConversionErrorFieldValidatorSupport.java 1177 2006-10-27 05:48:38Z mrdon $
Author:
  tm_jee

Field Summary
`private static Log` | `_log`
`private boolean` | `repopulateFieldAsBoolean`
`private String` | `repopulateFieldAsString`

Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
`defaultMessage, log, messageKey`

Constructor Summary
`RepopulateConversionErrorFieldValidatorSupport()`

Method Summary
`protected abstract void` | `doValidate(Object object)`
`String` | `getRepopulateField()`
`void` | `repopulateField(Object object)`
`void` | `setRepopulateField(String repopulateField)`
`void` | `validate(Object object)` The validation implementation must guarantee that setValidatorContext will be called with a non-null ValidatorContext before validate is called.

Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
`getFieldName, getValidatorType, setFieldName, setValidatorType`

Methods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
`addActionError, addFieldError, conditionalParse, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getParse, getValidatorContext, isShortCircuit, setDefaultMessage, setMessageKey, setParse, setShortCircuit, setValidatorContext`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.opensymphony.xwork2.validator.Validator
`getDefaultMessage, getMessage, getMessageKey, getValidatorContext, setDefaultMessage, setMessageKey, setValidatorContext`

Field Detail

### _log

    private static final Log _log

### repopulateFieldAsString

    private String repopulateFieldAsString

### repopulateFieldAsBoolean

    private boolean repopulateFieldAsBoolean

Constructor Detail

### RepopulateConversionErrorFieldValidatorSupport

    public RepopulateConversionErrorFieldValidatorSupport()

Method Detail

### getRepopulateField

    public String getRepopulateField()

### setRepopulateField

    public void setRepopulateField(String repopulateField)

### validate

    public void validate(Object object)
                  throws ValidationException

  Description copied from interface: `Validator`
  The validation implementation must guarantee that setValidatorContext will be called with a non-null ValidatorContext before validate is called.

  Throws:
    `ValidationException`

### repopulateField

    public void repopulateField(Object object)
                         throws ValidationException

  Throws:
    `ValidationException`

### doValidate

    protected abstract void doValidate(Object object)
                                throws ValidationException

  Throws:
    `ValidationException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.