You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/03/11 21:55:35 UTC
svn commit: r385164 [24/32] - in /jakarta/tapestry/trunk: ./ .settings/
annotations/src/java/org/apache/tapestry/annotations/
annotations/src/test/org/apache/tapestry/annotations/ config/
contrib/src/documentation/content/xdocs/tapestry-contrib/Compone...
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/AbstractNumericValidator.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,28 +17,15 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * Base class for a number of implementations of
- * {@link org.apache.tapestry.valid.IValidator}, meant to replace the awkward
- * {@link org.apache.tapestry.valid.NumberValidator}.
+ * Base class for a number of implementations of {@link org.apache.tapestry.valid.IValidator},
+ * meant to replace the awkward {@link org.apache.tapestry.valid.NumberValidator}.
*
* @author Howard M. Lewis Ship
*/
-public abstract class AbstractNumericValidator extends BaseValidator {
-
+public abstract class AbstractNumericValidator extends BaseValidator
+{
private boolean _zeroIsNull;
- private String _scriptPath = getDefaultScriptPath();
-
- private String _invalidNumericFormatMessage;
-
- private String _invalidIntegerFormatMessage;
-
- private String _numberTooSmallMessage;
-
- private String _numberTooLargeMessage;
-
- private String _numberRangeMessage;
-
public AbstractNumericValidator()
{
super();
@@ -55,8 +42,8 @@
}
/**
- * If true, then when rendering, a zero is treated as a non-value, and null
- * is returned. If false, the default, then zero is rendered as zero.
+ * If true, then when rendering, a zero is treated as a non-value, and null is returned. If
+ * false, the default, then zero is rendered as zero.
*/
public boolean getZeroIsNull()
@@ -69,6 +56,20 @@
_zeroIsNull = zeroIsNull;
}
+ private String _scriptPath =
+ getDefaultScriptPath();
+
+
+ private String _invalidNumericFormatMessage;
+
+ private String _invalidIntegerFormatMessage;
+
+ private String _numberTooSmallMessage;
+
+ private String _numberTooLargeMessage;
+
+ private String _numberRangeMessage;
+
/**
* @since 2.2
*/
@@ -78,10 +79,9 @@
}
/**
- * Allows a developer to use the existing validation logic with a different
- * client-side script. This is often sufficient to allow
- * application-specific error presentation (perhaps by using DHTML to update
- * the content of a <span> tag, or to use a more sophisticated pop-up
+ * Allows a developer to use the existing validation logic with a different client-side script.
+ * This is often sufficient to allow application-specific error presentation (perhaps by using
+ * DHTML to update the content of a <span> tag, or to use a more sophisticated pop-up
* window than <code>window.alert()</code>).
*
* @since 2.2
@@ -122,8 +122,8 @@
}
/**
- * Overrides the <code>invalid-numeric-format</code> bundle key. Parameter
- * {0} is the display name of the field.
+ * Overrides the <code>invalid-numeric-format</code> bundle key. Parameter {0} is the display
+ * name of the field.
*
* @since 3.0
*/
@@ -133,8 +133,8 @@
}
/**
- * Overrides the <code>invalid-int-format</code> bundle key. Parameter {0}
- * is the display name of the field.
+ * Overrides the <code>invalid-int-format</code> bundle key. Parameter {0} is the display name
+ * of the field.
*
* @since 3.0
*/
@@ -144,9 +144,8 @@
}
/**
- * Overrides the <code>number-range</code> bundle key. Parameter [0} is
- * the display name of the field. Parameter {1} is the minimum value.
- * Parameter {2} is the maximum value.
+ * Overrides the <code>number-range</code> bundle key. Parameter [0} is the display name of
+ * the field. Parameter {1} is the minimum value. Parameter {2} is the maximum value.
*
* @since 3.0
*/
@@ -156,9 +155,8 @@
}
/**
- * Overrides the <code>number-too-large</code> bundle key. Parameter {0}
- * is the display name of the field. Parameter {1} is the maximum allowed
- * value.
+ * Overrides the <code>number-too-large</code> bundle key. Parameter {0} is the display name
+ * of the field. Parameter {1} is the maximum allowed value.
*
* @since 3.0
*/
@@ -168,9 +166,8 @@
}
/**
- * Overrides the <code>number-too-small</code> bundle key. Parameter {0}
- * is the display name of the field. Parameter {1} is the minimum allowed
- * value.
+ * Overrides the <code>number-too-small</code> bundle key. Parameter {0} is the display name
+ * of the field. Parameter {1} is the minimum allowed value.
*
* @since 3.0
*/
@@ -182,17 +179,18 @@
/** @since 3.0 */
protected String buildInvalidNumericFormatMessage(IFormComponent field)
{
- String pattern = getPattern(getInvalidNumericFormatMessage(),
- "invalid-numeric-format", field.getPage().getLocale());
+ String pattern = getPattern(
+ getInvalidNumericFormatMessage(),
+ "invalid-numeric-format",
+ field.getPage().getLocale());
return formatString(pattern, field.getDisplayName());
}
- protected String buildNumberTooSmallMessage(IFormComponent field,
- Number minimum)
+ protected String buildNumberTooSmallMessage(IFormComponent field, Number minimum)
{
- String pattern = getPattern(getNumberTooSmallMessage(),
- "number-too-small", field.getPage().getLocale());
+ String pattern = getPattern(getNumberTooSmallMessage(), "number-too-small", field.getPage()
+ .getLocale());
return formatString(pattern, field.getDisplayName(), minimum);
}
@@ -200,44 +198,42 @@
/** @since 3.0 */
protected String buildInvalidIntegerFormatMessage(IFormComponent field)
{
- String pattern = getPattern(getInvalidIntegerFormatMessage(),
- "invalid-int-format", field.getPage().getLocale());
-
+ String pattern = getPattern(getInvalidIntegerFormatMessage(), "invalid-int-format", field
+ .getPage().getLocale());
+
return formatString(pattern, field.getDisplayName());
}
/**
* @since 3.0
*/
- protected String buildNumberTooLargeMessage(IFormComponent field,
- Number maximum)
+ protected String buildNumberTooLargeMessage(IFormComponent field, Number maximum)
{
- String pattern = getPattern(getNumberTooLargeMessage(),
- "number-too-large", field.getPage().getLocale());
-
+ String pattern = getPattern(getNumberTooLargeMessage(), "number-too-large", field.getPage()
+ .getLocale());
+
return formatString(pattern, field.getDisplayName(), maximum);
}
- protected String buildNumberRangeMessage(IFormComponent field,
- Number mininum, Number maximum)
+ protected String buildNumberRangeMessage(IFormComponent field, Number mininum, Number maximum)
{
- String pattern = getPattern(getNumberRangeMessage(), "number-range",
- field.getPage().getLocale());
-
- return formatString(pattern, new Object[] { field.getDisplayName(),
- mininum, maximum });
+ String pattern = getPattern(getNumberRangeMessage(), "number-range", field.getPage()
+ .getLocale());
+
+ return formatString(pattern, new Object[]
+ { field.getDisplayName(), mininum, maximum });
}
- protected String buildRangeMessage(IFormComponent field, Number minimum,
- Number maximum)
+ protected String buildRangeMessage(IFormComponent field, Number minimum, Number maximum)
{
if (minimum != null && maximum != null)
return buildNumberRangeMessage(field, minimum, maximum);
-
- if (maximum != null) return buildNumberTooLargeMessage(field, maximum);
-
+
+ if (maximum != null)
+ return buildNumberTooLargeMessage(field, maximum);
+
return buildNumberTooSmallMessage(field, minimum);
}
-
+
protected abstract String getDefaultScriptPath();
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/IValidationDelegate.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -27,57 +27,50 @@
* {@link IFormComponent form element component}s (including
* {@link org.apache.tapestry.form.AbstractTextField} and its subclasses).
* <p>
- * In addition, controls how fields that are in error are presented (they can be
- * <em>decorated</em> in various ways by the delegate; the default
- * implementation adds two red asterisks to the right of the field).
+ * In addition, controls how fields that are in error are presented (they can be <em>decorated</em>
+ * in various ways by the delegate; the default implementation adds two red asterisks to the right
+ * of the field).
* <p>
- * Each {@link org.apache.tapestry.form.Form} must have its own validation
- * delegate instance.
+ * Each {@link org.apache.tapestry.form.Form} must have its own validation delegate instance.
* <p>
- * Starting with release 1.0.8, this interface was extensively revised (in a
- * non-backwards compatible way) to move the tracking of errors and invalid
- * values (during a request cycle) to the delegate. It has evolved from a
- * largely stateless conduit for error messages into a very stateful tracker of
- * field state.
+ * Starting with release 1.0.8, this interface was extensively revised (in a non-backwards
+ * compatible way) to move the tracking of errors and invalid values (during a request cycle) to the
+ * delegate. It has evolved from a largely stateless conduit for error messages into a very stateful
+ * tracker of field state.
* <p>
- * Starting with release 1.0.9, this interface was <em>again</em> reworked, to
- * allow tracking of errors in {@link IFormComponent form components}, and to
- * allow unassociated errors to be tracked. Unassociated errors are "global",
- * they don't apply to any particular field.
+ * Starting with release 1.0.9, this interface was <em>again</em> reworked, to allow tracking of
+ * errors in {@link IFormComponent form components}, and to allow unassociated errors to be
+ * tracked. Unassociated errors are "global", they don't apply to any particular field.
* <p>
* <b>Fields vs. Form Element Components </b> <br>
- * For most simple forms, these terms are pretty much synonymous. Your form will
- * render normally, and each form element component will render only once. Some
- * of your form components will be {@link ValidField} components and
- * handle most of their validation internally (with the help of
- * {@link IValidator} objects). In addition, your form listener may do
- * additional validation and notify the validation delegate of additional
- * errors, some of which are associated with a particular field, some of which
- * are unassociated with any particular field.
+ * For most simple forms, these terms are pretty much synonymous. Your form will render normally,
+ * and each form element component will render only once. Some of your form components will be
+ * {@link ValidField} components and handle most of their validation internally (with the help
+ * of {@link IValidator} objects). In addition, your form listener may do additional
+ * validation and notify the validation delegate of additional errors, some of which are associated
+ * with a particular field, some of which are unassociated with any particular field.
* <p>
* But what happens if you use a {@link org.apache.tapestry.components.Foreach} or
- * {@link org.apache.tapestry.form.ListEdit} inside your form? Some of
- * your components will render multiple times. In this case you will have
- * multiple <em>fields</em>. Each field will have a unique field name (the
- * {@link org.apache.tapestry.form.FormSupport#getElementId(IFormComponent) element id},
- * which you can see this in the generated HTML). It is this field name that the
- * delegate keys off of, which means that some fields generated by a component
- * may have errors and some may not, it all works fine (with one exception).
+ * {@link org.apache.tapestry.form.ListEdit} inside your form? Some of your components will
+ * render multiple times. In this case you will have multiple <em>fields</em>. Each field will
+ * have a unique field name (the
+ * {@link org.apache.tapestry.form.FormSupport#getElementId(IFormComponent) element id}, which you
+ * can see this in the generated HTML). It is this field name that the delegate keys off of, which
+ * means that some fields generated by a component may have errors and some may not, it all works
+ * fine (with one exception).
* <p>
* <b>The Exception </b> <br>
- * The problem is that a component doesn't know its field name until its
- * <code>render()</code> method is invoked (at which point, it allocates a
- * unique field name from the
- * {@link org.apache.tapestry.IForm#getElementId(org.apache.tapestry.form.IFormComponent)}.
- * This is not a problem for the field or its {@link IValidator}, but screws
- * things up for the {@link FieldLabel}.
+ * The problem is that a component doesn't know its field name until its <code>render()</code>
+ * method is invoked (at which point, it allocates a unique field name from the
+ * {@link org.apache.tapestry.IForm#getElementId(org.apache.tapestry.form.IFormComponent)}. This is
+ * not a problem for the field or its {@link IValidator}, but screws things up for the
+ * {@link FieldLabel}.
* <p>
- * Typically, the label is rendered <em>before</em> the corresponding form
- * component. Form components leave their last assigned field name in their
- * {@link IFormComponent#getName() name property}. So if the form component is
- * in any kind of loop, the {@link FieldLabel}will key its name,
- * {@link IFormComponent#getDisplayName() display name} and error status off of
- * its last renderred value. So the moral of the story is don't use
+ * Typically, the label is rendered <em>before</em> the corresponding form component. Form
+ * components leave their last assigned field name in their
+ * {@link IFormComponent#getName() name property}. So if the form component is in any kind of loop,
+ * the {@link FieldLabel}will key its name, {@link IFormComponent#getDisplayName() display name}
+ * and error status off of its last renderred value. So the moral of the story is don't use
* {@link FieldLabel}in this situation.
*
* @author Howard Lewis Ship
@@ -85,59 +78,53 @@
public interface IValidationDelegate extends Serializable
{
-
/**
- * Invoked before other methods to configure the delegate for the given form
- * component. Sets the current field based on the
- * {@link IFormComponent#getName() name} of the form component.
+ * Invoked before other methods to configure the delegate for the given form component. Sets the
+ * current field based on the {@link IFormComponent#getName() name} of the form component.
* <p>
- * The caller should invoke this with a parameter of null to record
- * unassociated global errors (errors not associated with any particular
- * field).
+ * The caller should invoke this with a parameter of null to record unassociated global errors
+ * (errors not associated with any particular field).
*
* @since 1.0.8
*/
- void setFormComponent(IFormComponent component);
+ public void setFormComponent(IFormComponent component);
/**
- * Returns true if the current field is in error (that is, had bad input
- * submitted by the end user).
+ * Returns true if the current field is in error (that is, had bad input submitted by the end
+ * user).
*
* @since 1.0.8
*/
- boolean isInError();
+ public boolean isInError();
/**
- * Returns the string submitted by the client as the value for the current
- * field.
+ * Returns the string submitted by the client as the value for the current field.
*
* @since 1.0.8
*/
- String getFieldInputValue();
+ public String getFieldInputValue();
/**
- * Returns a {@link List} of {@link IFieldTracking}, in default order (the
- * order in which fields are renderred). A caller should not change the
- * values (the List is immutable). May return null if no fields are in
- * error.
+ * Returns a {@link List} of {@link IFieldTracking}, in default order (the order in which
+ * fields are renderred). A caller should not change the values (the List is immutable). May
+ * return null if no fields are in error.
*
* @since 1.0.8
*/
- List getFieldTracking();
+ public List getFieldTracking();
/**
- * Resets any tracking information for the current field. This will clear
- * the field's inError flag, and set its error message and invalid input
- * value to null.
+ * Resets any tracking information for the current field. This will clear the field's inError
+ * flag, and set its error message and invalid input value to null.
*
* @since 1.0.8
*/
- void reset();
+ public void reset();
/**
* Clears all tracking information.
@@ -145,51 +132,46 @@
* @since 1.0.10
*/
- void clear();
+ public void clear();
/**
- * Clears all errors, but maintains user input. This is useful when a form
- * has been submitted for a semantic other than "process this data". A
- * common example of this is a dependent drop down list; selecting an option
- * in one drop down list forces a refresh submit of the form, to repopulate
- * the options in a second, dependent drop down list.
+ * Clears all errors, but maintains user input. This is useful when a form has been submitted
+ * for a semantic other than "process this data". A common example of this is a dependent drop
+ * down list; selecting an option in one drop down list forces a refresh submit of the form, to
+ * repopulate the options in a second, dependent drop down list.
* <p>
- * In these cases, the user input provided in the request is maintained, but
- * any errors should be cleared out (to prevent unwanted error messages and
- * decorations).
+ * In these cases, the user input provided in the request is maintained, but any errors should
+ * be cleared out (to prevent unwanted error messages and decorations).
*
* @since 3.0.1
*/
- void clearErrors();
+ public void clearErrors();
/**
- * Records the user's input for the current form component. Input should be
- * recorded even if there isn't an explicit error, since later form-wide
- * validations may discover an error in the field.
+ * Records the user's input for the current form component. Input should be recorded even if
+ * there isn't an explicit error, since later form-wide validations may discover an error in the
+ * field.
*
* @since 3.0
*/
- void recordFieldInputValue(String input);
+ public void recordFieldInputValue(String input);
/**
- * The error notification method, invoked during the rewind phase (that is,
- * while HTTP parameters are being extracted from the request and assigned
- * to various object properties).
+ * The error notification method, invoked during the rewind phase (that is, while HTTP
+ * parameters are being extracted from the request and assigned to various object properties).
* <p>
- * Typically, the delegate simply invokes
- * {@link #record(String, ValidationConstraint)}or
- * {@link #record(IRender, ValidationConstraint)}, but special delegates
- * may override this behavior to provide (in some cases) different error
- * messages or more complicated error renderers.
+ * Typically, the delegate simply invokes {@link #record(String, ValidationConstraint)}or
+ * {@link #record(IRender, ValidationConstraint)}, but special delegates may override this
+ * behavior to provide (in some cases) different error messages or more complicated error
+ * renderers.
*/
- void record(ValidatorException ex);
+ public void record(ValidatorException ex);
/**
- * Records an error in the current field, or an unassociated error if there
- * is no current field.
+ * Records an error in the current field, or an unassociated error if there is no current field.
*
* @param message
* message to display (@see RenderString}
@@ -198,24 +180,24 @@
* @since 1.0.9
*/
- void record(String message, ValidationConstraint constraint);
+ public void record(String message, ValidationConstraint constraint);
/**
* Convienience for recording a standard string messages against a field.
*
* @param field
- * the field to record the error message against, or null to
- * record an unassociated error
+ * the field to record the error message against, or null to record an unassociated
+ * error
* @param message
* the error message to record
* @since 4.0
*/
- void record(IFormComponent field, String message);
+ public void record(IFormComponent field, String message);
/**
- * Records an error in the current component, or an unassociated error. The
- * maximum flexibility recorder.
+ * Records an error in the current component, or an unassociated error. The maximum flexibility
+ * recorder.
*
* @param errorRenderer
* object that will render the error message (@see RenderString}
@@ -223,12 +205,11 @@
* the constraint that was violated, or null if not known
*/
- void record(IRender errorRenderer, ValidationConstraint constraint);
+ public void record(IRender errorRenderer, ValidationConstraint constraint);
/**
- * Invoked before the field is rendered. If the field is in error, the
- * delegate may decorate the field in some way (to highlight its error
- * state).
+ * Invoked before the field is rendered. If the field is in error, the delegate may decorate the
+ * field in some way (to highlight its error state).
*
* @param writer
* the writer to which output should be sent
@@ -237,17 +218,17 @@
* @param component
* the component being decorated
* @param validator
- * the validator for the component, or null if the component does
- * have (or doesn't support) a validator
+ * the validator for the component, or null if the component does have (or doesn't
+ * support) a validator
*/
- void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator);
+ public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
+ IValidator validator);
/**
- * Invoked just before the <input> element is closed. The delegate can
- * write additional attributes. This is often used to set the CSS class of
- * the field so that it can be displayed differently, if in error (or
- * required). *
+ * Invoked just before the <input> element is closed. The delegate can write additional
+ * attributes. This is often used to set the CSS class of the field so that it can be displayed
+ * differently, if in error (or required). *
*
* @param writer
* the writer to which output should be sent
@@ -256,16 +237,17 @@
* @param component
* the component being decorated
* @param validator
- * the validator for the component, or null if the component does
- * have (or doesn't support) a validator
+ * the validator for the component, or null if the component does have (or doesn't
+ * support) a validator
* @since 1.0.5
*/
- void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator);
+ public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
+ IFormComponent component, IValidator validator);
/**
- * Invoked after the form component is rendered, so that the delegate may
- * decorate the form component (if it is in error). *
+ * Invoked after the form component is rendered, so that the delegate may decorate the form
+ * component (if it is in error). *
*
* @param writer
* the writer to which output should be sent
@@ -274,25 +256,24 @@
* @param component
* the component being decorated
* @param validator
- * the validator for the component, or null if the component does
- * have (or doesn't support) a validator
+ * the validator for the component, or null if the component does have (or doesn't
+ * support) a validator
*/
- void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator);
+ public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
+ IValidator validator);
/**
- * Invoked by a {@link FieldLabel} just before writing the name of the form
- * component.
+ * Invoked by a {@link FieldLabel} just before writing the name of the form component.
*/
- void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
+ public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
/**
- * Invoked just before the <label> element is closed. The delegate can
- * write additional attributes. This is often used to set the CSS class of
- * the label so that it can be displayed differently, if in error (or
- * required). Any attributes written here will be overriden by any informal
- * parameters specified in the {@link FieldLabel} implementation.
+ * Invoked just before the <label> element is closed. The delegate can write additional
+ * attributes. This is often used to set the CSS class of the label so that it can be displayed
+ * differently, if in error (or required). Any attributes written here will be overriden by any
+ * informal parameters specified in the {@link FieldLabel} implementation.
*
* @param writer
* the writer to which output should be sent
@@ -303,55 +284,53 @@
* @since 4.0.1
*/
- void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component);
-
+ public void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle,
+ IFormComponent component);
+
/**
- * Invoked by a {@link FieldLabel} just after writing the name of the form
- * component.
+ * Invoked by a {@link FieldLabel} just after writing the name of the form component.
*/
- void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
+ public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle);
/**
* Returns true if any form component has errors.
*/
- boolean getHasErrors();
+ public boolean getHasErrors();
/**
- * Returns the {@link IFieldTracking} for the current component, if
- * any. Useful when displaying error messages for individual fields.
+ * Returns the {@link IFieldTracking} for the current component, if any. Useful when
+ * displaying error messages for individual fields.
*
* @since 3.0.2
*/
- IFieldTracking getCurrentFieldTracking();
+ public IFieldTracking getCurrentFieldTracking();
/**
- * Returns a list of {@link org.apache.tapestry.IRender} objects, each of
- * which will render an error message for a field tracked by the delegate,
- * plus any unassociated errors (for which no specific field is identified).
- * These objects can be rendered or converted to a string (via toString()).
+ * Returns a list of {@link org.apache.tapestry.IRender} objects, each of which will render an
+ * error message for a field tracked by the delegate, plus any unassociated errors (for which no
+ * specific field is identified). These objects can be rendered or converted to a string (via
+ * toString()).
*
* @return non-empty List of {@link org.apache.tapestry.IRender}.
*/
- List getErrorRenderers();
+ public List getErrorRenderers();
/**
- * Registers a field for automatic focus. The goal is for the first field
- * that is in error to get focus; failing that, the first required field;
- * failing that, any field.
+ * Registers a field for automatic focus. The goal is for the first field that is in error to
+ * get focus; failing that, the first required field; failing that, any field.
*
* @param field
* the field requesting focus
* @param priority
- * a priority level used to determine whether the registered
- * field becomes the focus field. Constants for this purpose are
- * defined in {@link ValidationConstants}.
+ * a priority level used to determine whether the registered field becomes the focus
+ * field. Constants for this purpose are defined in {@link ValidationConstants}.
* @since 4.0
*/
- void registerForFocus(IFormComponent field, int priority);
+ public void registerForFocus(IFormComponent field, int priority);
/**
* Returns the field to focus upon, based on prior calls to
@@ -360,6 +339,6 @@
* @return the field name, or null if no field should receive focus.
* @since 4.0
*/
- String getFocusField();
+ public String getFocusField();
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/NumberValidator.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * Simple validation for standard number classes. This is probably insufficient
- * for anything tricky and application specific, such as parsing currency.
+ * Simple validation for standard number classes. This is probably insufficient for anything tricky
+ * and application specific, such as parsing currency.
*
* @author Howard Lewis Ship
* @since 1.0.8
@@ -38,14 +38,8 @@
public class NumberValidator extends AbstractNumericValidator
{
- public static final int NUMBER_TYPE_INTEGER = 0;
-
- public static final int NUMBER_TYPE_REAL = 1;
-
private static final Map TYPES = new HashMap();
-
- private static StrategyRegistry _numberAdaptors = new StrategyRegistryImpl();
-
+
static
{
TYPES.put("boolean", boolean.class);
@@ -82,75 +76,73 @@
private Number _maximum;
+ private static StrategyRegistry _numberAdaptors = new StrategyRegistryImpl();
+
+ public final static int NUMBER_TYPE_INTEGER = 0;
+
+ public final static int NUMBER_TYPE_REAL = 1;
+
/**
- * This class is not meant for use outside of NumberValidator; it is public
- * only to fascilitate some unit testing.
+ * This class is not meant for use outside of NumberValidator; it is public only to fascilitate
+ * some unit testing.
*/
- public abstract static class NumberStrategy
+ public static abstract class NumberStrategy
{
-
/**
- * Parses a non-empty {@link String}into the correct subclass of
- * {@link Number}.
+ * Parses a non-empty {@link String}into the correct subclass of {@link Number}.
*
* @throws NumberFormatException
* if the String can not be parsed.
*/
- public abstract Number parse(String value);
+ abstract public Number parse(String value);
/**
- * Indicates the type of the number represented -- integer or real. The
- * information is used to build the client-side validator. This method
- * could return a boolean, but returns an int to allow future extensions
- * of the validator.
+ * Indicates the type of the number represented -- integer or real. The information is used
+ * to build the client-side validator. This method could return a boolean, but returns an
+ * int to allow future extensions of the validator.
*
* @return one of the predefined number types
*/
- public abstract int getNumberType();
+ abstract public int getNumberType();
public int compare(Number left, Number right)
{
- if (!left.getClass().equals(right.getClass())) right = coerce(right);
-
- Comparable lc = (Comparable)left;
-
+ if (!left.getClass().equals(right.getClass()))
+ right = coerce(right);
+
+ Comparable lc = (Comparable) left;
+
return lc.compareTo(right);
}
/**
- * Invoked when comparing two Numbers of different types. The number is
- * cooerced from its ordinary type to the correct type for comparison.
+ * Invoked when comparing two Numbers of different types. The number is cooerced from its
+ * ordinary type to the correct type for comparison.
*
* @since 3.0
*/
protected abstract Number coerce(Number number);
}
- /** Placeholder comment. */
private static abstract class IntegerNumberAdaptor extends NumberStrategy
{
-
public int getNumberType()
{
return NUMBER_TYPE_INTEGER;
}
}
- /** Placeholder comment. */
private static abstract class RealNumberAdaptor extends NumberStrategy
{
-
public int getNumberType()
{
return NUMBER_TYPE_REAL;
}
}
- /** Placeholder comment. */
private static class ByteAdaptor extends IntegerNumberAdaptor
{
-
public Number parse(String value)
{
return new Byte(value);
@@ -162,10 +154,8 @@
}
}
- /** Placeholder comment. */
private static class ShortAdaptor extends IntegerNumberAdaptor
{
-
public Number parse(String value)
{
return new Short(value);
@@ -177,10 +167,8 @@
}
}
- /** Placeholder comment. */
private static class IntAdaptor extends IntegerNumberAdaptor
{
-
public Number parse(String value)
{
return new Integer(value);
@@ -192,10 +180,8 @@
}
}
- /** Placeholder comment. */
private static class LongAdaptor extends IntegerNumberAdaptor
{
-
public Number parse(String value)
{
return new Long(value);
@@ -207,10 +193,8 @@
}
}
- /** Placeholder comment. */
private static class FloatAdaptor extends RealNumberAdaptor
{
-
public Number parse(String value)
{
return new Float(value);
@@ -222,10 +206,8 @@
}
}
- /** Placeholder comment. */
private static class DoubleAdaptor extends RealNumberAdaptor
{
-
public Number parse(String value)
{
return new Double(value);
@@ -237,10 +219,8 @@
}
}
- /** Placeholder comment. */
private static class BigDecimalAdaptor extends RealNumberAdaptor
{
-
public Number parse(String value)
{
return new BigDecimal(value);
@@ -252,10 +232,8 @@
}
}
- /** Placeholder comment. */
private static class BigIntegerAdaptor extends IntegerNumberAdaptor
{
-
public Number parse(String value)
{
return new BigInteger(value);
@@ -299,8 +277,7 @@
}
/**
- * Initializes the NumberValidator with properties defined by the
- * initializer.
+ * Initializes the NumberValidator with properties defined by the initializer.
*
* @since 4.0
*/
@@ -312,13 +289,15 @@
public String toString(IFormComponent field, Object value)
{
- if (value == null) return null;
+ if (value == null)
+ return null;
if (getZeroIsNull())
{
- Number number = (Number)value;
+ Number number = (Number) value;
- if (number.doubleValue() == 0.0) return null;
+ if (number.doubleValue() == 0.0)
+ return null;
}
return value.toString();
@@ -329,7 +308,9 @@
NumberStrategy result = getStrategy(_valueTypeClass);
if (result == null)
- throw new ApplicationRuntimeException(Tapestry.format("NumberValidator.no-adaptor-for-field", field,
+ throw new ApplicationRuntimeException(Tapestry.format(
+ "NumberValidator.no-adaptor-for-field",
+ field,
_valueTypeClass.getName()));
return result;
@@ -338,8 +319,8 @@
/**
* Returns an strategy for the given type.
* <p>
- * Note: this method exists only for testing purposes. It is not meant to be
- * invoked by user code and is subject to change at any time.
+ * Note: this method exists only for testing purposes. It is not meant to be invoked by user
+ * code and is subject to change at any time.
*
* @param type
* the type (a Number subclass) for which to return an adaptor
@@ -348,13 +329,13 @@
*/
public static NumberStrategy getStrategy(Class type)
{
- return (NumberStrategy)_numberAdaptors.getStrategy(type);
+ return (NumberStrategy) _numberAdaptors.getStrategy(type);
}
- public Object toObject(IFormComponent field, String value)
- throws ValidatorException
+ public Object toObject(IFormComponent field, String value) throws ValidatorException
{
- if (checkRequired(field, value)) return null;
+ if (checkRequired(field, value))
+ return null;
NumberStrategy adaptor = getStrategy(field);
Number result = null;
@@ -365,14 +346,17 @@
}
catch (NumberFormatException ex)
{
- throw new ValidatorException(buildInvalidNumericFormatMessage(field), ValidationConstraint.NUMBER_FORMAT);
+ throw new ValidatorException(buildInvalidNumericFormatMessage(field),
+ ValidationConstraint.NUMBER_FORMAT);
}
if (_minimum != null && adaptor.compare(result, _minimum) < 0)
- throw new ValidatorException(buildNumberTooSmallMessage(field, _minimum), ValidationConstraint.TOO_SMALL);
+ throw new ValidatorException(buildNumberTooSmallMessage(field, _minimum),
+ ValidationConstraint.TOO_SMALL);
if (_maximum != null && adaptor.compare(result, _maximum) > 0)
- throw new ValidatorException(buildNumberTooLargeMessage(field, _maximum), ValidationConstraint.TOO_LARGE);
+ throw new ValidatorException(buildNumberTooLargeMessage(field, _maximum),
+ ValidationConstraint.TOO_LARGE);
return result;
}
@@ -411,19 +395,24 @@
* @since 2.2
*/
- public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer, IRequestCycle cycle)
+ public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer,
+ IRequestCycle cycle)
{
- if (!isClientScriptingEnabled()) return;
+ if (!isClientScriptingEnabled())
+ return;
- if (!(isRequired() || _minimum != null || _maximum != null)) return;
+ if (!(isRequired() || _minimum != null || _maximum != null))
+ return;
Map symbols = new HashMap();
- if (isRequired()) symbols.put("requiredMessage", buildRequiredMessage(field));
+ if (isRequired())
+ symbols.put("requiredMessage", buildRequiredMessage(field));
if (isIntegerNumber())
symbols.put("formatMessage", buildInvalidIntegerFormatMessage(field));
- else symbols.put("formatMessage", buildInvalidNumericFormatMessage(field));
+ else
+ symbols.put("formatMessage", buildInvalidNumericFormatMessage(field));
if (_minimum != null || _maximum != null)
symbols.put("rangeMessage", buildRangeMessage(field, _minimum, _maximum));
@@ -432,19 +421,21 @@
}
/**
- * Sets the value type from a string type name. The name may be a scalar
- * numeric type, a fully qualified class name, or the name of a numeric
- * wrapper type from java.lang (with the package name omitted).
+ * Sets the value type from a string type name. The name may be a scalar numeric type, a fully
+ * qualified class name, or the name of a numeric wrapper type from java.lang (with the package
+ * name omitted).
*
* @since 3.0
*/
public void setValueType(String typeName)
{
- Class typeClass = (Class)TYPES.get(typeName);
+ Class typeClass = (Class) TYPES.get(typeName);
if (typeClass == null)
- throw new ApplicationRuntimeException(Tapestry.format("NumberValidator.unknown-type", typeName));
+ throw new ApplicationRuntimeException(Tapestry.format(
+ "NumberValidator.unknown-type",
+ typeName));
_valueTypeClass = typeClass;
}
@@ -471,8 +462,9 @@
public boolean isIntegerNumber()
{
- NumberStrategy strategy = (NumberStrategy)_numberAdaptors.getStrategy(_valueTypeClass);
- if (strategy == null) return false;
+ NumberStrategy strategy = (NumberStrategy) _numberAdaptors.getStrategy(_valueTypeClass);
+ if (strategy == null)
+ return false;
return strategy.getNumberType() == NUMBER_TYPE_INTEGER;
}
@@ -481,4 +473,4 @@
{
return "/org/apache/tapestry/valid/NumberValidator.script";
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/UrlValidator.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@
*/
public class UrlValidator extends BaseValidator
{
-
private int _minimumLength;
private String _minimumLengthMessage;
@@ -64,24 +63,30 @@
public String toString(IFormComponent field, Object value)
{
- if (value == null) return null;
+ if (value == null)
+ return null;
return value.toString();
}
- public Object toObject(IFormComponent field, String input)
- throws ValidatorException
+ public Object toObject(IFormComponent field, String input) throws ValidatorException
{
- if (checkRequired(field, input)) return null;
+ if (checkRequired(field, input))
+ return null;
if (_minimumLength > 0 && input.length() < _minimumLength)
- throw new ValidatorException(buildMinimumLengthMessage(field), ValidationConstraint.MINIMUM_WIDTH);
+ throw new ValidatorException(buildMinimumLengthMessage(field),
+ ValidationConstraint.MINIMUM_WIDTH);
if (!isValidUrl(input))
- throw new ValidatorException(buildInvalidUrlFormatMessage(field), ValidationConstraint.URL_FORMAT);
+ throw new ValidatorException(buildInvalidUrlFormatMessage(field),
+ ValidationConstraint.URL_FORMAT);
- if (!isAllowedProtocol(input)) { throw new ValidatorException(buildDisallowedProtocolMessage(field),
- ValidationConstraint.DISALLOWED_PROTOCOL); }
+ if (!isAllowedProtocol(input))
+ {
+ throw new ValidatorException(buildDisallowedProtocolMessage(field),
+ ValidationConstraint.DISALLOWED_PROTOCOL);
+ }
return input;
}
@@ -96,16 +101,20 @@
_minimumLength = minimumLength;
}
- public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer, IRequestCycle cycle)
+ public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer,
+ IRequestCycle cycle)
{
- if (!isClientScriptingEnabled()) return;
+ if (!isClientScriptingEnabled())
+ return;
Map symbols = new HashMap();
- if (isRequired()) symbols.put("requiredMessage", buildRequiredMessage(field)); //$NON-NLS-1$
+ if (isRequired())
+ symbols.put("requiredMessage", buildRequiredMessage(field)); //$NON-NLS-1$
- if (_minimumLength > 0) symbols.put("minimumLengthMessage", //$NON-NLS-1$
- buildMinimumLengthMessage(field));
+ if (_minimumLength > 0)
+ symbols.put("minimumLengthMessage", //$NON-NLS-1$
+ buildMinimumLengthMessage(field));
symbols.put("urlFormatMessage", buildInvalidUrlFormatMessage(field)); //$NON-NLS-1$
@@ -119,12 +128,15 @@
private String buildUrlRegexpProtocols()
{
- if (_allowedProtocols == null) { return null; }
+ if (_allowedProtocols == null)
+ {
+ return null;
+ }
String regexp = "/("; //$NON-NLS-1$
Iterator iter = _allowedProtocols.iterator();
- while(iter.hasNext())
+ while (iter.hasNext())
{
- String protocol = (String)iter.next();
+ String protocol = (String) iter.next();
regexp += protocol;
if (iter.hasNext())
{
@@ -176,9 +188,9 @@
}
String actualProtocol = oUrl.getProtocol();
Iterator iter = _allowedProtocols.iterator();
- while(iter.hasNext())
+ while (iter.hasNext())
{
- String protocol = (String)iter.next();
+ String protocol = (String) iter.next();
if (protocol.equals(actualProtocol))
{
bIsAllowed = true;
@@ -241,15 +253,18 @@
protected String buildDisallowedProtocolMessage(IFormComponent field)
{
- if (_allowedProtocols == null) { return null; }
+ if (_allowedProtocols == null)
+ {
+ return null;
+ }
String pattern = getPattern(_disallowedProtocolMessage, "disallowed-protocol", //$NON-NLS-1$
field.getPage().getLocale());
String allowedProtocols = ""; //$NON-NLS-1$
Iterator iter = _allowedProtocols.iterator();
- while(iter.hasNext())
+ while (iter.hasNext())
{
- String protocol = (String)iter.next();
+ String protocol = (String) iter.next();
if (!allowedProtocols.equals("")) { //$NON-NLS-1$
if (iter.hasNext())
{
@@ -268,9 +283,12 @@
protected String getPattern(String override, String key, Locale locale)
{
- if (override != null) return override;
+ if (override != null)
+ return override;
- ResourceBundle strings = ResourceBundle.getBundle("org.apache.tapestry.valid.ValidationStrings", locale);
+ ResourceBundle strings = ResourceBundle.getBundle(
+ "org.apache.tapestry.valid.ValidationStrings",
+ locale);
return strings.getString(key);
}
@@ -284,10 +302,10 @@
// String[] aProtocols = protocols.split(","); //$NON-NLS-1$
String[] aProtocols = spliter.splitToArray(protocols); //$NON-NLS-1$
_allowedProtocols = new Vector();
- for(int i = 0; i < aProtocols.length; i++)
+ for (int i = 0; i < aProtocols.length; i++)
{
_allowedProtocols.add(aProtocols[i]);
}
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidField.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidField.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidField.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidField.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,23 +20,20 @@
import org.apache.tapestry.form.AbstractFormComponent;
/**
- * A {@link Form}component that creates a text field that allows for validation
- * of user input and conversion between string and object values. [ <a
- * href="../../../../../ComponentReference/ValidField.html">Component Reference
- * </a>]
+ * A {@link Form}component that creates a text field that allows for validation of user input and
+ * conversion between string and object values. [ <a
+ * href="../../../../../ComponentReference/ValidField.html">Component Reference </a>]
* <p>
- * A ValidatingTextField uses an {@link IValidationDelegate} to track errors and
- * an {@link IValidator}to convert between strings and objects (as well as
- * perform validations). The validation delegate is shared by all validating
- * text fields in a form, the validator may be shared my multiple elements as
- * desired.
+ * A ValidatingTextField uses an {@link IValidationDelegate} to track errors and an
+ * {@link IValidator}to convert between strings and objects (as well as perform validations). The
+ * validation delegate is shared by all validating text fields in a form, the validator may be
+ * shared my multiple elements as desired.
*
* @author Howard Lewis Ship
*/
public abstract class ValidField extends AbstractFormComponent
{
-
public abstract boolean isHidden();
public abstract boolean isDisabled();
@@ -45,7 +42,7 @@
public abstract void setValue(Object value);
- /** Parameter. */
+ /** Parameter */
public abstract String getDisplayName();
@@ -66,12 +63,14 @@
writer.attribute("type", isHidden() ? "password" : "text");
- if (isDisabled()) writer.attribute("disabled", "disabled");
+ if (isDisabled())
+ writer.attribute("disabled", "disabled");
writer.attribute("name", getName());
String value = readValue();
- if (value != null) writer.attribute("value", value);
+ if (value != null)
+ writer.attribute("value", value);
renderIdAttribute(writer, cycle);
@@ -81,9 +80,11 @@
IValidator validator = getValidator();
- if (validator == null) throw Tapestry.createRequiredParameterException(this, "validator");
+ if (validator == null)
+ throw Tapestry.createRequiredParameterException(this, "validator");
- if (validator.isRequired()) delegate.registerForFocus(this, ValidationConstants.REQUIRED_FIELD);
+ if (validator.isRequired())
+ delegate.registerForFocus(this, ValidationConstants.REQUIRED_FIELD);
validator.renderValidatorContribution(this, writer, cycle);
@@ -106,11 +107,13 @@
protected String readValue()
{
IValidator validator = getValidator();
- if (validator == null) throw Tapestry.createRequiredParameterException(this, "validator");
+ if (validator == null)
+ throw Tapestry.createRequiredParameterException(this, "validator");
IValidationDelegate delegate = getForm().getDelegate();
- if (delegate.isInError()) return delegate.getFieldInputValue();
+ if (delegate.isInError())
+ return delegate.getFieldInputValue();
Object value = getValue();
@@ -124,7 +127,8 @@
Object objectValue = null;
IValidator validator = getValidator();
- if (validator == null) throw Tapestry.createRequiredParameterException(this, "validator");
+ if (validator == null)
+ throw Tapestry.createRequiredParameterException(this, "validator");
IValidationDelegate delegate = getForm().getDelegate();
@@ -144,4 +148,4 @@
}
public abstract IValidator getValidator();
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidMessages.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidMessages.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidMessages.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidMessages.java Sat Mar 11 12:54:27 2006
@@ -14,7 +14,6 @@
package org.apache.tapestry.valid;
-import org.apache.hivemind.Messages;
import org.apache.hivemind.impl.MessageFormatter;
import org.apache.tapestry.IComponent;
@@ -22,18 +21,13 @@
* @author Howard M. Lewis Ship
* @since 4.0
*/
-final class ValidMessages
+class ValidMessages
{
-
- private static final Messages MESSAGES = new MessageFormatter(ValidMessages.class);
-
- /** @since 4.1 */
- private ValidMessages()
- {
- }
+ private final static MessageFormatter _formatter = new MessageFormatter(ValidMessages.class);
static String noDisplayName(IComponent label, IComponent field)
{
- return MESSAGES.format("no-display-name", label.getExtendedId(), field.getExtendedId());
+ return _formatter.format("no-display-name", label.getExtendedId(), field.getExtendedId());
}
-}
+
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationConstraint.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationConstraint.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationConstraint.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationConstraint.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,35 +17,37 @@
import java.io.Serializable;
/**
- * Defines an enumeration of different types of validation constraints that may
- * be violated.
+ * Defines an enumeration of different types of validation constraints that may be violated.
*
* @author Howard Lewis Ship
*/
public class ValidationConstraint implements Serializable
{
+ private static final long serialVersionUID = 371593028205311930L;
/**
- * Indicates that no value (or a value consisting only of white space) was
- * provided for a field that requires a non-null value.
+ * Indicates that no value (or a value consisting only of white space) was provided for a field
+ * that requires a non-null value.
*/
public static final ValidationConstraint REQUIRED = new ValidationConstraint("REQUIRED");
/**
- * Indicates that a non-null value was provided, but that (after removing
- * leading and trailing whitespace), the value was not long enough.
+ * Indicates that a non-null value was provided, but that (after removing leading and trailing
+ * whitespace), the value was not long enough.
*/
- public static final ValidationConstraint MINIMUM_WIDTH = new ValidationConstraint("MINIMUM_WIDTH");
+ public static final ValidationConstraint MINIMUM_WIDTH = new ValidationConstraint(
+ "MINIMUM_WIDTH");
/**
- * Indicates that a non-null value was provided, but that (after removing
- * leading and trailing whitespace), the value was too long.
+ * Indicates that a non-null value was provided, but that (after removing leading and trailing
+ * whitespace), the value was too long.
*/
- public static final ValidationConstraint MAXIMUM_WIDTH = new ValidationConstraint("MAXIMUM_WIDTH");
+ public static final ValidationConstraint MAXIMUM_WIDTH = new ValidationConstraint(
+ "MAXIMUM_WIDTH");
/**
* Indicates a general error in converting a String into a Date.
@@ -54,18 +56,17 @@
public static final ValidationConstraint DATE_FORMAT = new ValidationConstraint("DATE_FORMAT");
/**
- * Indicates a general error in the format of a string that is to be
- * interpreted as a email.
+ * Indicates a general error in the format of a string that is to be interpreted as a email.
*/
public static final ValidationConstraint EMAIL_FORMAT = new ValidationConstraint("EMAIL_FORMAT");
/**
- * Indicates a general error in the format of a string that is to be
- * interpreted as a number.
+ * Indicates a general error in the format of a string that is to be interpreted as a number.
*/
- public static final ValidationConstraint NUMBER_FORMAT = new ValidationConstraint("NUMBER_FORMAT");
+ public static final ValidationConstraint NUMBER_FORMAT = new ValidationConstraint(
+ "NUMBER_FORMAT");
/**
* Indicates that the value was too small (for a Date, too early).
@@ -85,7 +86,8 @@
* @since 3.0
*/
- public static final ValidationConstraint PATTERN_MISMATCH = new ValidationConstraint("PATTERN_MISMATCH");
+ public static final ValidationConstraint PATTERN_MISMATCH = new ValidationConstraint(
+ "PATTERN_MISMATCH");
/**
* Indicates a consistency error, usually between too different fields.
@@ -96,7 +98,7 @@
public static final ValidationConstraint CONSISTENCY = new ValidationConstraint("CONSISTENCY");
/**
- * Indicates that a URL is not of the correct format.
+ * Indicates that a URL is not of the correct format
*
* @since 3.0
*/
@@ -104,20 +106,18 @@
public static final ValidationConstraint URL_FORMAT = new ValidationConstraint("URL_FORMAT");
/**
- * Indicates that the URL does not use one of the specified protocols.
+ * Indicates that the URL does not use one of the specified protocols
*
* @since 3.0
*/
- public static final ValidationConstraint DISALLOWED_PROTOCOL = new ValidationConstraint("DISALLOWED_PROTOCOL");
-
- private static final long serialVersionUID = 371593028205311930L;
+ public static final ValidationConstraint DISALLOWED_PROTOCOL = new ValidationConstraint(
+ "DISALLOWED_PROTOCOL");
private final String _name;
/**
- * Protected constructor, which allows new constraints to be created as
- * subclasses.
+ * Protected constructor, which allows new constraints to be created as subclasses.
*/
protected ValidationConstraint(String name)
@@ -129,4 +129,4 @@
{
return "ValidationConstraint[" + _name + "]";
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -28,9 +28,8 @@
import org.apache.tapestry.form.IFormComponent;
/**
- * A base implementation of {@link IValidationDelegate}that can be used as a
- * managed bean. This class is often subclassed, typically to override
- * presentation details.
+ * A base implementation of {@link IValidationDelegate}that can be used as a managed bean. This
+ * class is often subclassed, typically to override presentation details.
*
* @author Howard Lewis Ship
* @since 1.0.5
@@ -38,7 +37,6 @@
public class ValidationDelegate implements IValidationDelegate
{
-
private static final long serialVersionUID = 6215074338439140780L;
private transient IFormComponent _currentComponent;
@@ -68,20 +66,21 @@
public void clearErrors()
{
- if (_trackings == null) return;
+ if (_trackings == null)
+ return;
Iterator i = _trackings.iterator();
- while(i.hasNext())
+ while (i.hasNext())
{
- FieldTracking ft = (FieldTracking)i.next();
+ FieldTracking ft = (FieldTracking) i.next();
ft.setErrorRenderer(null);
}
}
/**
- * If the form component is in error, places a <font color="red"<
- * around it. Note: this will only work on the render phase after a rewind,
- * and will be confused if components are inside any kind of loop.
+ * If the form component is in error, places a <font color="red"< around it. Note: this
+ * will only work on the render phase after a rewind, and will be confused if components are
+ * inside any kind of loop.
*/
public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
@@ -94,17 +93,17 @@
}
/**
- * Does nothing by default. {@inheritDoc}
+ * Does nothing by default.
+ * {@inheritDoc}
*/
+
+ public void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component) {
+ }
- public void writeLabelAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component)
- {
- }
-
- /**
+ /**
* Closes the <font> element,started by
- * {@link #writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle)},
- * if the form component is in error.
+ * {@link #writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle)}, if the form component
+ * is in error.
*/
public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
@@ -117,14 +116,13 @@
/**
* Returns the {@link IFieldTracking}for the current component, if any. The
- * {@link IFieldTracking}is usually created in
- * {@link #record(String, ValidationConstraint)}or in
- * {@link #record(IRender, ValidationConstraint)}.
+ * {@link IFieldTracking}is usually created in {@link #record(String, ValidationConstraint)}or
+ * in {@link #record(IRender, ValidationConstraint)}.
* <p>
- * Components may be rendered multiple times, with multiple names (provided
- * by the {@link org.apache.tapestry.form.Form}, care must be taken that
- * this method is invoked <em>after</em> the Form has provided a unique
- * {@link IFormComponent#getName()}for the component.
+ * Components may be rendered multiple times, with multiple names (provided by the
+ * {@link org.apache.tapestry.form.Form}, care must be taken that this method is invoked
+ * <em>after</em> the Form has provided a unique {@link IFormComponent#getName()}for the
+ * component.
*
* @see #setFormComponent(IFormComponent)
* @return the {@link FieldTracking}, or null if the field has no tracking.
@@ -132,7 +130,7 @@
protected FieldTracking getComponentTracking()
{
- return (FieldTracking)_trackingMap.get(_currentComponent.getName());
+ return (FieldTracking) _trackingMap.get(_currentComponent.getName());
}
public void setFormComponent(IFormComponent component)
@@ -160,7 +158,8 @@
public List getFieldTracking()
{
- if (Tapestry.size(_trackings) == 0) return null;
+ if (Tapestry.size(_trackings) == 0)
+ return null;
return Collections.unmodifiableList(_trackings);
}
@@ -185,8 +184,7 @@
/**
* Invokes {@link #record(String, ValidationConstraint)}, or
* {@link #record(IRender, ValidationConstraint)}if the
- * {@link ValidatorException#getErrorRenderer() error renderer property}is
- * not null.
+ * {@link ValidatorException#getErrorRenderer() error renderer property}is not null.
*/
public void record(ValidatorException ex)
@@ -195,12 +193,13 @@
if (errorRenderer == null)
record(ex.getMessage(), ex.getConstraint());
- else record(errorRenderer, ex.getConstraint());
+ else
+ record(errorRenderer, ex.getConstraint());
}
/**
- * Invokes {@link #record(IRender, ValidationConstraint)}, after wrapping
- * the message parameter in a {@link RenderString}.
+ * Invokes {@link #record(IRender, ValidationConstraint)}, after wrapping the message parameter
+ * in a {@link RenderString}.
*/
public void record(String message, ValidationConstraint constraint)
@@ -209,16 +208,14 @@
}
/**
- * Records error information about the currently selected component, or
- * records unassociated (with any field) errors.
+ * Records error information about the currently selected component, or records unassociated
+ * (with any field) errors.
* <p>
- * Currently, you may have at most one error per <em>field</em> (note the
- * difference between field and component), but any number of unassociated
- * errors.
+ * Currently, you may have at most one error per <em>field</em> (note the difference between
+ * field and component), but any number of unassociated errors.
* <p>
- * Subclasses may override the default error message (based on other
- * factors, such as the field and constraint) before invoking this
- * implementation.
+ * Subclasses may override the default error message (based on other factors, such as the field
+ * and constraint) before invoking this implementation.
*
* @since 1.0.9
*/
@@ -251,9 +248,9 @@
}
/**
- * Finds or creates the field tracking for the
- * {@link #setFormComponent(IFormComponent)} current component. If no
- * current component, an unassociated error is created and returned.
+ * Finds or creates the field tracking for the {@link #setFormComponent(IFormComponent)}
+ * current component. If no current component, an unassociated error is created and
+ * returned.
*
* @since 3.0
*/
@@ -293,7 +290,8 @@
* Does nothing. Override in a subclass to decoreate fields.
*/
- public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
+ public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
+ IValidator validator)
{
}
@@ -301,18 +299,18 @@
* Does nothing. Override in a subclass to decorate fields.
*/
- public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
- IValidator validator)
+ public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
+ IFormComponent component, IValidator validator)
{
}
/**
- * Default implementation; if the current field is in error, then a suffix
- * is written. The suffix is:
- * <code>&nbsp;<font color="red">**</font></code>.
+ * Default implementation; if the current field is in error, then a suffix is written. The
+ * suffix is: <code>&nbsp;<font color="red">**</font></code>.
*/
- public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
+ public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
+ IValidator validator)
{
if (isInError())
{
@@ -332,31 +330,31 @@
/**
* A convienience, as most pages just show the first error on the page.
* <p>
- * As of release 1.0.9, this returns an instance of {@link IRender}, not a
- * {@link String}.
+ * As of release 1.0.9, this returns an instance of {@link IRender}, not a {@link String}.
*/
public IRender getFirstError()
{
- if (Tapestry.size(_trackings) == 0) return null;
+ if (Tapestry.size(_trackings) == 0)
+ return null;
Iterator i = _trackings.iterator();
- while(i.hasNext())
+ while (i.hasNext())
{
- IFieldTracking tracking = (IFieldTracking)i.next();
+ IFieldTracking tracking = (IFieldTracking) i.next();
- if (tracking.isInError()) return tracking.getErrorRenderer();
+ if (tracking.isInError())
+ return tracking.getErrorRenderer();
}
return null;
}
/**
- * Checks to see if the field is in error. This will <em>not</em> work
- * properly in a loop, but is only used by {@link FieldLabel}. Therefore,
- * using {@link FieldLabel}in a loop (where the {@link IFormComponent}is
- * renderred more than once) will not provide correct results.
+ * Checks to see if the field is in error. This will <em>not</em> work properly in a loop, but
+ * is only used by {@link FieldLabel}. Therefore, using {@link FieldLabel}in a loop (where the
+ * {@link IFormComponent}is renderred more than once) will not provide correct results.
*/
protected boolean isInError(IFormComponent component)
@@ -365,33 +363,35 @@
String fieldName = component.getName();
- IFieldTracking tracking = (IFieldTracking)_trackingMap.get(fieldName);
+ IFieldTracking tracking = (IFieldTracking) _trackingMap.get(fieldName);
return tracking != null && tracking.isInError();
}
/**
- * Returns a {@link List}of {@link IFieldTracking}s. This is the master
- * list of trackings, except that it omits and trackings that are not
- * associated with a particular field. May return an empty list, or null.
+ * Returns a {@link List}of {@link IFieldTracking}s. This is the master list of trackings,
+ * except that it omits and trackings that are not associated with a particular field. May
+ * return an empty list, or null.
* <p>
- * Order is not determined, though it is likely the order in which
- * components are laid out on in the template (this is subject to change).
+ * Order is not determined, though it is likely the order in which components are laid out on in
+ * the template (this is subject to change).
*/
public List getAssociatedTrackings()
{
int count = Tapestry.size(_trackings);
- if (count == 0) return null;
+ if (count == 0)
+ return null;
List result = new ArrayList(count);
- for(int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
- IFieldTracking tracking = (IFieldTracking)_trackings.get(i);
+ IFieldTracking tracking = (IFieldTracking) _trackings.get(i);
- if (tracking.getFieldName() == null) continue;
+ if (tracking.getFieldName() == null)
+ continue;
result.add(tracking);
}
@@ -400,29 +400,29 @@
}
/**
- * Like {@link #getAssociatedTrackings()}, but returns only the
- * unassociated trackings. Unassociated trackings are new (in release
- * 1.0.9), and are why interface {@link IFieldTracking}is not very well
- * named.
+ * Like {@link #getAssociatedTrackings()}, but returns only the unassociated trackings.
+ * Unassociated trackings are new (in release 1.0.9), and are why interface
+ * {@link IFieldTracking}is not very well named.
* <p>
- * The trackings are returned in an unspecified order, which (for the
- * moment, anyway) is the order in which they were added (this could change
- * in the future, or become more concrete).
+ * The trackings are returned in an unspecified order, which (for the moment, anyway) is the
+ * order in which they were added (this could change in the future, or become more concrete).
*/
public List getUnassociatedTrackings()
{
int count = Tapestry.size(_trackings);
- if (count == 0) return null;
+ if (count == 0)
+ return null;
List result = new ArrayList(count);
- for(int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
- IFieldTracking tracking = (IFieldTracking)_trackings.get(i);
+ IFieldTracking tracking = (IFieldTracking) _trackings.get(i);
- if (tracking.getFieldName() != null) continue;
+ if (tracking.getFieldName() != null)
+ continue;
result.add(tracking);
}
@@ -435,13 +435,14 @@
List result = new ArrayList();
Iterator i = _trackings.iterator();
- while(i.hasNext())
+ while (i.hasNext())
{
- IFieldTracking tracking = (IFieldTracking)i.next();
+ IFieldTracking tracking = (IFieldTracking) i.next();
IRender errorRenderer = tracking.getErrorRenderer();
- if (errorRenderer != null) result.add(errorRenderer);
+ if (errorRenderer != null)
+ result.add(errorRenderer);
}
return result;
@@ -459,8 +460,8 @@
}
/**
- * Returns the focus field, or null if no form components registered for
- * focus (i.e., they were all disabled).
+ * Returns the focus field, or null if no form components registered for focus (i.e., they were
+ * all disabled).
*/
public String getFocusField()
@@ -468,4 +469,4 @@
return _focusField;
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -24,40 +24,38 @@
*/
public final class ValidationStrings
{
-
public static final String REQUIRED_FIELD = "field-is-required";
public static final String INVALID_DATE = "invalid-date-format";
public static final String INVALID_NUMBER = "invalid-numeric-format";
public static final String INVALID_EMAIL = "invalid-email-format";
-
+
public static final String REGEX_MISMATCH = "regex-mismatch";
-
+
public static final String VALUE_TOO_SHORT = "field-too-short";
public static final String VALUE_TOO_LONG = "field-too-long";
-
+
public static final String VALUE_TOO_SMALL = "number-too-small";
public static final String VALUE_TOO_LARGE = "number-too-large";
-
+
public static final String DATE_TOO_EARLY = "date-too-early";
public static final String DATE_TOO_LATE = "date-too-late";
-
+
public static final String INVALID_FIELD_EQUALITY = "invalid-field-equality";
-
+
private static final String RESOURCE_BUNDLE = ValidationStrings.class.getName();
-
- private ValidationStrings()
- {
- // Disable construction
- }
-
+
/**
- * Fetches the appropriate validation message pattern from the appropriate
- * localized resource. This method should be called with the locale of the
- * current request.
+ * Fetches the appropriate validation message pattern from the appropriate localized resource.
+ * This method should be called with the locale of the current request.
*/
public static String getMessagePattern(String key, Locale locale)
{
return ResourceBundle.getBundle(RESOURCE_BUNDLE, locale).getString(key);
+ }
+
+ private ValidationStrings()
+ {
+ // Disable construction
}
}
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings_de.properties
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings_de.properties?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings_de.properties (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidationStrings_de.properties Sat Mar 11 12:54:27 2006
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
field-is-required=Eingabefeld {0} ist ein Pflichtfeld.
field-too-short=Sie m\u00c3\u00bcssen min. {0} Zeichen in das Eingabefeld {1} eingeben.
invalid-date-format=Das Eingabefeld ''{0}'' hat ein falsches Datumsformat (Eingabeformat ist {1}).
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBinding.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBinding.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBinding.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBinding.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,12 +20,11 @@
import org.apache.tapestry.coerce.ValueConverter;
/**
- * Implementation of {@link IBinding} that provides
- * {@link org.apache.tapestry.valid.IValidator} instances based on a
- * validator bean descriptor. The descriptor is of the form "type[,properties]".
- * The types are values such as "string", "date" or "number" defined in the
- * tapestry.valid.Validators configuration point. The properties are a
- * properties initialization string.
+ * Implementation of {@link IBinding} that provides {@link org.apache.tapestry.valid.IValidator}
+ * instances based on a validator bean descriptor. The descriptor is of the form
+ * "type[,properties]". The types are values such as "string", "date" or "number" defined in the
+ * tapestry.valid.Validators configuration point. The properties are a properties initialization
+ * string.
*
* @author Howard M. Lewis Ship
* @since 4.0
@@ -34,10 +33,10 @@
*/
public class ValidatorBinding extends AbstractBinding
{
-
private final IValidator _validator;
- public ValidatorBinding(String description, ValueConverter valueConverter, Location location, IValidator validator)
+ public ValidatorBinding(String description, ValueConverter valueConverter, Location location,
+ IValidator validator)
{
super(description, valueConverter, location);
@@ -51,4 +50,4 @@
return _validator;
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBindingFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBindingFactory.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBindingFactory.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorBindingFactory.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2005, 2006 The Apache Software Foundation
+// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@
import org.apache.tapestry.binding.AbstractBindingFactory;
/**
- * Uses the tapestry.valid.ValidatorBeanFactory service to obtain configuration
- * IValidator instances.
+ * Uses the tapestry.valid.ValidatorBeanFactory service to obtain configuration IValidator
+ * instances.
*
* @author Howard M. Lewis Ship
* @since 4.0
@@ -31,7 +31,6 @@
*/
public class ValidatorBindingFactory extends AbstractBindingFactory
{
-
private BeanFactory _validatorBeanFactory;
public void setValidatorBeanFactory(BeanFactory validatorBeanFactory)
@@ -40,22 +39,24 @@
}
/**
- * Creates and returns a {@link ValidatorBinding}. Interprets the path as a
- * bean initializer, used to locate a particular type of validator and a
- * particular configuration of its properties.
+ * Creates and returns a {@link ValidatorBinding}. Interprets the path as a bean initializer,
+ * used to locate a particular type of validator and a particular configuration of its
+ * properties.
*/
- public IBinding createBinding(IComponent root, String bindingDescription, String expression, Location location)
+ public IBinding createBinding(IComponent root, String bindingDescription, String expression,
+ Location location)
{
try
{
- IValidator validator = (IValidator)_validatorBeanFactory.get(expression);
+ IValidator validator = (IValidator) _validatorBeanFactory.get(expression);
- return new ValidatorBinding(bindingDescription, getValueConverter(), location, validator);
+ return new ValidatorBinding(bindingDescription, getValueConverter(), location,
+ validator);
}
catch (Exception ex)
{
throw new ApplicationRuntimeException(ex.getMessage(), location, ex);
}
}
-}
+}
\ No newline at end of file
Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorException.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorException.java?rev=385164&r1=385163&r2=385164&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorException.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/valid/ValidatorException.java Sat Mar 11 12:54:27 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -23,21 +23,20 @@
* @since 1.0.8
*/
-public class ValidatorException extends Exception {
-
+public class ValidatorException extends Exception
+{
private static final long serialVersionUID = 2451683137746501377L;
- private final IRender _errorRenderer;
+ private IRender _errorRenderer;
- private final ValidationConstraint _constraint;
+ private ValidationConstraint _constraint;
public ValidatorException(String errorMessage)
{
this(errorMessage, null, null);
}
- public ValidatorException(String errorMessage,
- ValidationConstraint constraint)
+ public ValidatorException(String errorMessage, ValidationConstraint constraint)
{
this(errorMessage, null, constraint);
}
@@ -46,17 +45,16 @@
* Creates a new instance.
*
* @param errorMessage
- * the default error message to be used (this may be overriden by
- * the {@link IValidationDelegate})
+ * the default error message to be used (this may be overriden by the
+ * {@link IValidationDelegate})
* @param errorRenderer
- * to use to render the error message (may be null). This is used
- * with custom validators that create renderers that produce rich
- * markup (such as icons or links to help pages). Such renderes
- * are expected to implement a <code>toString()</code> that
- * returns a simple error message (without any markup).
+ * to use to render the error message (may be null). This is used with custom
+ * validators that create renderers that produce rich markup (such as icons or links
+ * to help pages). Such renderes are expected to implement a <code>toString()</code>
+ * that returns a simple error message (without any markup).
* @param constraint
- * a validation constraint that has been compromised, or null if
- * no constraint is applicable
+ * a validation constraint that has been compromised, or null if no constraint is
+ * applicable
*/
public ValidatorException(String errorMessage, IRender errorRenderer,
@@ -83,4 +81,4 @@
{
return _errorRenderer;
}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org