You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kevin Menard <ni...@negativetwenty.net> on 2005/07/04 01:01:59 UTC
Re: Tapestry 4.0 validation
Hi Paul,
On Jun 28, 2005, at 2:05 PM, Paul Ferraro wrote:
>
> The process for recording validation errors using the
> IValidationDelegate has not changed.
I like to add markup to indicate a component is required to have a
value in my validation delegate. However, when writeSuffix() is
encountered in the delegate, the validator object is always null. Am
I doing something wrong? FWIW, the delegate will detect that an
error has occurred later on. Also, if multiple validators are
defined, how does it affect the semantics of the parameters of this
method?
Thanks,
Kevin
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Tapestry 4.0 validation
Posted by "Scott F. Walter" <sc...@scottwalter.com>.
Kevin Menard wrote:
>
> On Jul 3, 2005, at 8:17 PM, Scott F. Walter wrote:
>
>>
>> ValidatorsBinding vb = (ValidatorsBinding)
>> component.getBinding("validators"); Collection
>> collection = (Collection) vb.getObject();
>> for(Iterator it = collection.iterator();it.hasNext();){
>> Validator validatorObject = (Validator) it.next();
>> System.out.println("Validator" + validatorObject.getClass
>> ().getName());
>> }
>>
>> So in your case if you would check tat the class name of a validator
>> is "org.apache.tapestry.form.validator.Required", then you can put
>> the required field marker.
>
>
> Thanks Scott, this indeed worked (well, I had to add a few null
> checks in there). Not as nice a solution as I was hoping for, but
> it's got me going now anyway.
>
> Thanks again,
> Kevin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
I reported an enhancement to see if we could get some type of helper
method that would at least just return a collection so that we don't
need to worry about getting the correct binding.
--
Scott F. Walter Scott F. Walter
Principal Consultant
Vivare, Inc.
E: scott.walter@vivare.com
E: scott@scottwalter.com
Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Tapestry 4.0 validation
Posted by Kevin Menard <ni...@negativetwenty.net>.
On Jul 3, 2005, at 8:17 PM, Scott F. Walter wrote:
>
> ValidatorsBinding vb = (ValidatorsBinding)
> component.getBinding("validators"); Collection
> collection = (Collection) vb.getObject();
> for(Iterator it = collection.iterator();it.hasNext();){
> Validator validatorObject = (Validator) it.next();
> System.out.println("Validator" + validatorObject.getClass
> ().getName());
> }
>
> So in your case if you would check tat the class name of a
> validator is "org.apache.tapestry.form.validator.Required", then
> you can put the required field marker.
Thanks Scott, this indeed worked (well, I had to add a few null
checks in there). Not as nice a solution as I was hoping for, but
it's got me going now anyway.
Thanks again,
Kevin
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Tapestry 4.0 validation
Posted by "Scott F. Walter" <sc...@scottwalter.com>.
Kevin Menard wrote:
> Hi Paul,
>
>
> On Jun 28, 2005, at 2:05 PM, Paul Ferraro wrote:
>
>>
>> The process for recording validation errors using the
>> IValidationDelegate has not changed.
>
>
> I like to add markup to indicate a component is required to have a
> value in my validation delegate. However, when writeSuffix() is
> encountered in the delegate, the validator object is always null. Am
> I doing something wrong? FWIW, the delegate will detect that an
> error has occurred later on. Also, if multiple validators are
> defined, how does it affect the semantics of the parameters of this
> method?
>
> Thanks,
> Kevin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
I believe the reason that validator is null because it uses the old
validation interface "IValidator". If you are using the new validation
system, you will be using validators that implement the "Validator"
interface. Below is a code snippet to get all the validators for a
particular component:
ValidatorsBinding vb = (ValidatorsBinding)
component.getBinding("validators");
Collection collection = (Collection) vb.getObject();
for(Iterator it = collection.iterator();it.hasNext();){
Validator validatorObject = (Validator) it.next();
System.out.println("Validator" +
validatorObject.getClass().getName());
}
So in your case if you would check tat the class name of a validator is
"org.apache.tapestry.form.validator.Required", then you can put the
required field marker.
scott.
--
Scott F. Walter Scott F. Walter
Principal Consultant
Vivare, Inc.
E: scott.walter@vivare.com
E: scott@scottwalter.com
Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org