You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Glen Stampoultzis <gs...@iinet.net.au> on 2003/12/05 07:51:49 UTC

Never mind that last question...

I can see an example in the ValidField component help.

One other related question though.

If I want to trigger a validation message manually in my submit function is 
there an easy way to do this?

Regards,


Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Never mind that last question

Posted by "Julio C. Rivera" <Ju...@carm.es>.
You can do something like this:

public void onFormSubmit(IRequestCycle cycle) {
     ValidationDelegate delegate =
         (ValidationDelegate) getBeans().getBean("delegate");

     if (someErrorCondition) {
         delegate.record(
            "You have to insert some value.",
             ValidationConstraint.REQUIRED);
     }
     else {
          //Process submit
     }
}

Regards
    Julio.

At 07:51 05/12/2003, you wrote:

>I can see an example in the ValidField component help.
>
>One other related question though.
>
>If I want to trigger a validation message manually in my submit function 
>is there an easy way to do this?
>
>Regards,
>
>
>Glen Stampoultzis
>gstamp@iinet.net.au
>http://members.iinet.net.au/~gstamp/glen/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org

*************************************************
Julio C. Rivera Riquelme
Unidad de Informática
Gerencia de Atención Primaria de Murcia
C\ Escultor Sanchez Lozano, 7
************************************************* 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Never mind that last question...

Posted by Glen Stampoultzis <gs...@iinet.net.au>.
That looks promising.  I'll try that.  Thanks.

Regards,

Glen

At 07:17 PM 5/12/2003, you wrote:
>I use something like this:
>
>public class SimpleValidationDelegate {
>...
>         public Collection getAllErrors() {
>                 List trackings = getFieldTracking();
>                 List allErrors = new ArrayList();
>
>                 if (Tapestry.size(trackings) == 0)
>                         return null;
>
>                 Iterator i = trackings.iterator();
>                 while (i.hasNext()) {
>                         IFieldTracking tracking = (IFieldTracking)
>i.next();
>
>                         if (tracking.isInError()) {
>
>allErrors.add(((RenderString)tracking.getErrorRenderer()).getString());
>                         }
>                 }
>
>                 return allErrors;
>         }
>...
>}
>
>And then display the output using a "showErrors" component.  Couldn't
>you use something like this and create dynamic Javascript with the
>collection of errors?
>
>Cheers
>
>Peter
>
>-----Original Message-----
>From: Glen Stampoultzis [mailto:gstamp@iinet.net.au]
>Sent: Friday, 5 December 2003 9:04 p.m.
>To: Tapestry users
>Subject: Re: Never mind that last question...
>
>
>
>Sorry... I didn't explain myself properly at all.  Note to self: think
>twice before hitting send.
>
>What I actually wanted was that to display a javascript alert with the
>problem(s) and then focus to the first non-valid field.  So the sequence
>is:
>
>1. User inputs some junk.
>2. Submit listener called
>3. Submit realizes there's an issue and calls setFormComponent() and
>record() to record the problem.
>4. New page is rendered and an alert is displayed with the problem(s)
>and
>the first problem component has focus.
>
>I've figured out most of how to do this but one remaining problem is the
>
>validation delegate does not keep track of the validation error messages
>
>and instead converts them straight to an error renderer.
>
>Regards,
>
>Glen
>
>
>At 06:22 PM 5/12/2003, you wrote:
> >Correction...
> >
> >     if (validationFailed)
> >     {
> >         IFormComponent component = (IFormComponent)
> > getComponents().get(componentId);
> >         IValidationDelegate delegate = (IValidationDelegate)
> > getBeans().getBean(delegateName);
> >         delegate.setFormComponent(component);
> >         delegate.record("validation message", validationConstraint);
> >     }
> >
> >
> >Harish Krishnaswamy wrote:
> >
> >>Do you mean you need to perform validations specific to a page not
> >>provided by the generic validators? If this is what you want, then all
>
> >>you have to do is do your validation and record your messages in the
> >>validation delegate. The rest is the same as regular validations.
> >>     if (validationFailed)
> >>     {
> >>             IFormComponent component = (IFormComponent)
> >> getComponents().get(componentId);
> >>         IValidationDelegate delegate = (IValidationDelegate)
> >> getBeans().getBean(delegateName);
> >>             delegate.setFormComponent(component);
> >>             delegate.record(fieldComponentId, validationConstraint);
> >>     }
> >>Hope this makes sense.
> >>-Harish
> >>Glen Stampoultzis wrote:
> >>
> >>>
> >>>I can see an example in the ValidField component help.
> >>>
> >>>One other related question though.
> >>>
> >>>If I want to trigger a validation message manually in my submit
> >>>function
> >>>is there an easy way to do this?
> >>>
> >>>Regards,
> >>>
> >>>
> >>>Glen Stampoultzis
> >>>gstamp@iinet.net.au http://members.iinet.net.au/~gstamp/glen/
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail:
> >>>tapestry-user-help@jakarta.apache.org
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
>
>
>Glen Stampoultzis
>gstamp@iinet.net.au
>http://members.iinet.net.au/~gstamp/glen/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/

RE: Never mind that last question...

Posted by Peter Butler <pe...@141.com>.
I use something like this:

public class SimpleValidationDelegate {
...
	public Collection getAllErrors() {
		List trackings = getFieldTracking();
		List allErrors = new ArrayList();

		if (Tapestry.size(trackings) == 0)
			return null;

		Iterator i = trackings.iterator();
		while (i.hasNext()) {
			IFieldTracking tracking = (IFieldTracking)
i.next();

			if (tracking.isInError()) {
	
allErrors.add(((RenderString)tracking.getErrorRenderer()).getString());
			}
		}

		return allErrors;
	}
...
}

And then display the output using a "showErrors" component.  Couldn't
you use something like this and create dynamic Javascript with the
collection of errors?

Cheers

Peter

-----Original Message-----
From: Glen Stampoultzis [mailto:gstamp@iinet.net.au] 
Sent: Friday, 5 December 2003 9:04 p.m.
To: Tapestry users
Subject: Re: Never mind that last question...



Sorry... I didn't explain myself properly at all.  Note to self: think 
twice before hitting send.

What I actually wanted was that to display a javascript alert with the 
problem(s) and then focus to the first non-valid field.  So the sequence
is:

1. User inputs some junk.
2. Submit listener called
3. Submit realizes there's an issue and calls setFormComponent() and 
record() to record the problem.
4. New page is rendered and an alert is displayed with the problem(s)
and 
the first problem component has focus.

I've figured out most of how to do this but one remaining problem is the

validation delegate does not keep track of the validation error messages

and instead converts them straight to an error renderer.

Regards,

Glen


At 06:22 PM 5/12/2003, you wrote:
>Correction...
>
>     if (validationFailed)
>     {
>         IFormComponent component = (IFormComponent)
> getComponents().get(componentId);
>         IValidationDelegate delegate = (IValidationDelegate) 
> getBeans().getBean(delegateName);
>         delegate.setFormComponent(component);
>         delegate.record("validation message", validationConstraint);
>     }
>
>
>Harish Krishnaswamy wrote:
>
>>Do you mean you need to perform validations specific to a page not
>>provided by the generic validators? If this is what you want, then all

>>you have to do is do your validation and record your messages in the 
>>validation delegate. The rest is the same as regular validations.
>>     if (validationFailed)
>>     {
>>             IFormComponent component = (IFormComponent) 
>> getComponents().get(componentId);
>>         IValidationDelegate delegate = (IValidationDelegate) 
>> getBeans().getBean(delegateName);
>>             delegate.setFormComponent(component);
>>             delegate.record(fieldComponentId, validationConstraint);
>>     }
>>Hope this makes sense.
>>-Harish
>>Glen Stampoultzis wrote:
>>
>>>
>>>I can see an example in the ValidField component help.
>>>
>>>One other related question though.
>>>
>>>If I want to trigger a validation message manually in my submit 
>>>function
>>>is there an easy way to do this?
>>>
>>>Regards,
>>>
>>>
>>>Glen Stampoultzis
>>>gstamp@iinet.net.au http://members.iinet.net.au/~gstamp/glen/
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: 
>>>tapestry-user-help@jakarta.apache.org
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Never mind that last question...

Posted by Glen Stampoultzis <gs...@iinet.net.au>.
Sorry... I didn't explain myself properly at all.  Note to self: think 
twice before hitting send.

What I actually wanted was that to display a javascript alert with the 
problem(s) and then focus to the first non-valid field.  So the sequence is:

1. User inputs some junk.
2. Submit listener called
3. Submit realizes there's an issue and calls setFormComponent() and 
record() to record the problem.
4. New page is rendered and an alert is displayed with the problem(s) and 
the first problem component has focus.

I've figured out most of how to do this but one remaining problem is the 
validation delegate does not keep track of the validation error messages 
and instead converts them straight to an error renderer.

Regards,

Glen


At 06:22 PM 5/12/2003, you wrote:
>Correction...
>
>     if (validationFailed)
>     {
>         IFormComponent component = (IFormComponent) 
> getComponents().get(componentId);
>         IValidationDelegate delegate = (IValidationDelegate) 
> getBeans().getBean(delegateName);
>         delegate.setFormComponent(component);
>         delegate.record("validation message", validationConstraint);
>     }
>
>
>Harish Krishnaswamy wrote:
>
>>Do you mean you need to perform validations specific to a page not 
>>provided by the generic validators? If this is what you want, then all 
>>you have to do is do your validation and record your messages in the 
>>validation delegate. The rest is the same as regular validations.
>>     if (validationFailed)
>>     {
>>             IFormComponent component = (IFormComponent) 
>> getComponents().get(componentId);
>>         IValidationDelegate delegate = (IValidationDelegate) 
>> getBeans().getBean(delegateName);
>>             delegate.setFormComponent(component);
>>             delegate.record(fieldComponentId, validationConstraint);
>>     }
>>Hope this makes sense.
>>-Harish
>>Glen Stampoultzis wrote:
>>
>>>
>>>I can see an example in the ValidField component help.
>>>
>>>One other related question though.
>>>
>>>If I want to trigger a validation message manually in my submit function 
>>>is there an easy way to do this?
>>>
>>>Regards,
>>>
>>>
>>>Glen Stampoultzis
>>>gstamp@iinet.net.au
>>>http://members.iinet.net.au/~gstamp/glen/
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/

Re: Never mind that last question...

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Correction...

     if (validationFailed)
     {
         IFormComponent component = (IFormComponent) getComponents().get(componentId);
         IValidationDelegate delegate = (IValidationDelegate) getBeans().getBean(delegateName);
         delegate.setFormComponent(component);
         delegate.record("validation message", validationConstraint);
     }


Harish Krishnaswamy wrote:

> Do you mean you need to perform validations specific to a page not 
> provided by the generic validators? If this is what you want, then all 
> you have to do is do your validation and record your messages in the 
> validation delegate. The rest is the same as regular validations.
> 
>     if (validationFailed)
>     {
>             IFormComponent component = (IFormComponent) 
> getComponents().get(componentId);
>         IValidationDelegate delegate = (IValidationDelegate) 
> getBeans().getBean(delegateName);
>             delegate.setFormComponent(component);
>             delegate.record(fieldComponentId, validationConstraint);
>     }
> 
> Hope this makes sense.
> 
> -Harish
> 
> Glen Stampoultzis wrote:
> 
>>
>> I can see an example in the ValidField component help.
>>
>> One other related question though.
>>
>> If I want to trigger a validation message manually in my submit 
>> function is there an easy way to do this?
>>
>> Regards,
>>
>>
>> Glen Stampoultzis
>> gstamp@iinet.net.au
>> http://members.iinet.net.au/~gstamp/glen/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Never mind that last question...

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Do you mean you need to perform validations specific to a page not provided by the generic 
validators? If this is what you want, then all you have to do is do your validation and record your 
messages in the validation delegate. The rest is the same as regular validations.

	if (validationFailed)
	{
             IFormComponent component = (IFormComponent) getComponents().get(componentId);
	    IValidationDelegate delegate = (IValidationDelegate) getBeans().getBean(delegateName);
             delegate.setFormComponent(component);
             delegate.record(fieldComponentId, validationConstraint);
	}

Hope this makes sense.

-Harish

Glen Stampoultzis wrote:

> 
> I can see an example in the ValidField component help.
> 
> One other related question though.
> 
> If I want to trigger a validation message manually in my submit function 
> is there an easy way to do this?
> 
> Regards,
> 
> 
> Glen Stampoultzis
> gstamp@iinet.net.au
> http://members.iinet.net.au/~gstamp/glen/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org