You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Julio C. Rivera" <ju...@ya.com> on 2003/06/13 01:01:08 UTC
Bugs, patches and enhancements
I have done some bug fixes and enhances in the tapestry validation framework.
I hope this will be useful.
BUGS
=====
BUG: In NumericField and DateFields components (in ValidatingTextField was
fixed by Neil Clayton)
------------------------------------------------------------------------------------------------------
Using a DateField component I get this exception:
Method 'public abstract org.apache.tapestry.IBinding
org.apache.tapestry.contrib.valid.DateField.getValueBinding()' (declared in
class org.apache.tapestry.contrib.valid.DateField) has no implementation in
class org.apache.tapestry.contrib.valid.DateField (or enhanced subclass
org.apache.tapestry.contrib.valid.DateField$Enhance_8).
For fix it I implement methods get/setValue, get/setValueBinding.
After this I get similar exceptions about getName and getForm.
Method 'public abstract java.lang.String
org.apache.tapestry.form.AbstractFormComponent.getName()' (declared in
class org.apache.tapestry.form.AbstractFormComponent) has no implementation
in class pfc.components.valid.DateField (or enhanced subclass
pfc.components.valid.DateField$Enhance_8).
I fix it adding name and form properties in the DateField specification
(similar to the fix done to the ValidatingTextField)
Similar problems get with the NumericField component and I fix it in a
analogous way.
BUG: Using NumericField with "minimum"(or "maximum") parameter equal to any
float value and input a integer value cause a ClassCastException
--------------------------------------------------------------------------------------------------
Example:
<input type="text" jwcid="@contrib:NumericField" value="ognl:fieldValue"
displayName="FieldName" minimum="10.5"
required="ognl:false" type="Integer"/>
If I write the value "20" in the input field I get a
java.lang.ClassCastException when the form is submitted:
Stack Trace:
java.lang.Integer.compareTo(Integer.java:913)
org.apache.tapestry.valid.NumberValidator$NumberAdaptor.compare(NumberValidator.java:143)
org.apache.tapestry.valid.NumberValidator.toObject(NumberValidator.java:285)
org.apache.tapestry.valid.ValidField.updateValue(ValidField.java:224)
org.apache.tapestry.form.AbstractTextField.renderComponent(AbstractTextField.java:109)
org.apache.tapestry.valid.ValidField.renderComponent(ValidField.java:127)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896)
Cause:
NumericField receive a type parameter but it is not transfered to the
NumberValidator.
Solution:
Add to the getValidator method in NumeriField.java the line:
validator.setValueType(getTypeName());
and declare de abstract method
public abstract String getTypeName();
ENHANCEMENTS
==============
Add client-size validation to NumericField and ValidatingTextField components.
Check using javascript that the number format is correct differentiating
between integer format and float format.
I have added a clientScriptingEnabled parameter to these components and
transfer if in the getValidator method doing:
public IValidator getValidator()
{
......
if (clientScriptingEnabledBinding != null)
{
boolean clientScriptingEnabled =
clientScriptingEnabledBinding.getBoolean();
validator.setClientScriptingEnabled(clientScriptingEnabled);
}
.....
}
I have modified NumberValidator.java for add a "invalid integer format"
message and a method (boolean isRealNumber()) for check from the script if
the number to validate has a integer format or a float format.
I have added some code to NumberValidator.script.
I have done similar changes to the ValidatingTextField component.
I woud like to add client side validation to the DateField component too soon.
I attach files I have modified and the output of the command diff .
Regards.
Julio.
RE: Bugs, patches and enhancements
Posted by "Howard M. Lewis Ship" <hl...@attbi.com>.
Thanks for the contribution; I hope to get a chance to look at it this weekend.
--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
> -----Original Message-----
> From: Julio C. Rivera [mailto:juceri@ya.com]
> Sent: Thursday, June 12, 2003 7:01 PM
> To: tapestry-dev@jakarta.apache.org
> Subject: Bugs, patches and enhancements
>
>
> I have done some bug fixes and enhances in the tapestry
> validation framework.
>
> I hope this will be useful.
>
> BUGS
> =====
>
> BUG: In NumericField and DateFields components (in
> ValidatingTextField was
> fixed by Neil Clayton)
> --------------------------------------------------------------
> ----------------------------------------
>
> Using a DateField component I get this exception:
>
> Method 'public abstract org.apache.tapestry.IBinding
> org.apache.tapestry.contrib.valid.DateField.getValueBinding()'
> (declared in
> class org.apache.tapestry.contrib.valid.DateField) has no
> implementation in
> class org.apache.tapestry.contrib.valid.DateField (or
> enhanced subclass
> org.apache.tapestry.contrib.valid.DateField$Enhance_8).
>
> For fix it I implement methods get/setValue,
> get/setValueBinding. After this I get similar exceptions
> about getName and getForm.
>
> Method 'public abstract java.lang.String
> org.apache.tapestry.form.AbstractFormComponent.getName()'
> (declared in
> class org.apache.tapestry.form.AbstractFormComponent) has no
> implementation
> in class pfc.components.valid.DateField (or enhanced subclass
> pfc.components.valid.DateField$Enhance_8).
>
> I fix it adding name and form properties in the DateField
> specification
> (similar to the fix done to the ValidatingTextField)
>
> Similar problems get with the NumericField component and I
> fix it in a
> analogous way.
>
>
> BUG: Using NumericField with "minimum"(or "maximum")
> parameter equal to any
> float value and input a integer value cause a ClassCastException
> --------------------------------------------------------------
> ------------------------------------
>
> Example:
> <input type="text" jwcid="@contrib:NumericField"
> value="ognl:fieldValue"
> displayName="FieldName" minimum="10.5"
> required="ognl:false" type="Integer"/>
>
>
> If I write the value "20" in the input field I get a
> java.lang.ClassCastException when the form is submitted:
> Stack Trace:
> java.lang.Integer.compareTo(Integer.java:913)
>
> org.apache.tapestry.valid.NumberValidator$NumberAdaptor.compar
> e(NumberValidator.java:143)
>
>
> org.apache.tapestry.valid.NumberValidator.toObject(NumberValid
> ator.java:285)
>
> org.apache.tapestry.valid.ValidField.updateValue(ValidField.java:224)
>
> org.apache.tapestry.form.AbstractTextField.renderComponent(Abs
> tractTextField.java:109)
>
>
> org.apache.tapestry.valid.ValidField.renderComponent(ValidFiel
> d.java:127)
>
> org.apache.tapestry.AbstractComponent.render(AbstractComponent
> .java:896)
>
> Cause:
> NumericField receive a type parameter but it is not
> transfered to the
> NumberValidator.
>
> Solution:
> Add to the getValidator method in NumeriField.java the line:
> validator.setValueType(getTypeName());
> and declare de abstract method
> public abstract String getTypeName();
>
>
> ENHANCEMENTS
> ==============
>
> Add client-size validation to NumericField and
> ValidatingTextField components.
>
> Check using javascript that the number format is correct
> differentiating between integer format and float format.
>
> I have added a clientScriptingEnabled parameter to these
> components and
> transfer if in the getValidator method doing:
> public IValidator getValidator()
> {
> ......
> if (clientScriptingEnabledBinding != null)
> {
> boolean clientScriptingEnabled =
> clientScriptingEnabledBinding.getBoolean();
>
> validator.setClientScriptingEnabled(clientScriptingEnabled);
> }
> .....
> }
>
> I have modified NumberValidator.java for add a "invalid
> integer format"
> message and a method (boolean isRealNumber()) for check from
> the script if
> the number to validate has a integer format or a float
> format. I have added some code to NumberValidator.script.
>
> I have done similar changes to the ValidatingTextField component.
>
> I woud like to add client side validation to the DateField
> component too soon.
>
> I attach files I have modified and the output of the command diff .
>
>
> Regards.
>
> Julio.
>