You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by RachelS <re...@gmail.com> on 2007/07/23 09:47:48 UTC

Mixing AjaxForm and Form

Hi there

(I'm using Tapestry 4.0.2 and Tacos 4.0.1)

I have a situation where I have a Form and a separate AjaxForm on a page.

What I find is that the Form works perfectly when the AjaxForm is not also
on the page. As soon as the AjaxForm is added, most of the Form's validation
fails with errors like "Tapestry.validate_currency is not a method" or
"Tapestry.validate_number is not a method." 

I see that Tapestry.validate_number is a method that is added by Tapestry's
form.js when you have "translator="translator:number" on a TextField. To try
and force this to work when both forms are on the page, I'm taking out the
translator and creating a custom validator that I attach to the TextField
with a bean which seems like a bit of overkill to duplicate the translator
functionality.

So I have done some reading and I see that the AjaxForm supplies it's own
copy of Form.js to the page and that this is why most of the methods fail to
work once the AjaxForm is added to the page.

I also see that there is mention of having a form profile and using
dojo.validate.check(form, profile) to see if the form passed validation.
(Once you have setup up the profile of course)

I'd like to know if adding a profile to the form is the 'correct' way to
accomplish validation in this case. 

Also, I'd like to know what the 'correct' way is to do this. Is the best
pattern to simply add javascript to the page and add the check into the
form's submit handler? I just don't know what to do with the result from
dojo.validate.check.

Are there any detailed examples of this available?

Many thanks,
Rachel
-- 
View this message in context: http://www.nabble.com/Mixing-AjaxForm-and-Form-tf4128054.html#a11739250
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Mixing AjaxForm and Form

Posted by RachelS <re...@gmail.com>.
Hi Marcus

That sounds like it will be very nice to use! My eyes must have jumped over
that in the documentation. I'm going to go up to 4.1 and see how it goes.

Thanks again,
Rachel



Marcus Schulte wrote:
> 
> 
> In Tap 4.1, you can do all the things you could do with Tacos' Ajax*
> components directly with the native Tap-components. For example, the
> standard form will create your validation profile automatically - and it
> will support async submission, update of selected components and so on.
> 
> /Marcus
> 
> 

-- 
View this message in context: http://www.nabble.com/Mixing-AjaxForm-and-Form-tf4128054.html#a11776412
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Mixing AjaxForm and Form

Posted by Marcus Schulte <et...@googlemail.com>.
Hi Rachel,

2007/7/24, RachelS <re...@gmail.com>:
>
>
> Even after reading the documentation, I still could not see (whether on
> 4.0
> or 4.1) how to get the more detailed validation of Tacos forms to work.
>
> The one way (with profiles) i imagine would involve writing a js profile
> for
> every form and having the form know about every field in every component
> on
> it that requires validation. That said, I'm still not sure how I would
> then
> get the server side validation to work in a similar way to the Validators
> of
> 4.0.


In Tap 4.1, you can do all the things you could do with Tacos' Ajax*
components directly with the native Tap-components. For example, the
standard form will create your validation profile automatically - and it
will support async submission, update of selected components and so on.

/Marcus

Re: Mixing AjaxForm and Form

Posted by RachelS <re...@gmail.com>.
Hi Marcus

I read the Tap4.1 documentation and ultimately we'll move up to that
release. The project I am on now is simply to see how viable Tacos is to
use.

Even after reading the documentation, I still could not see (whether on 4.0
or 4.1) how to get the more detailed validation of Tacos forms to work.

The one way (with profiles) i imagine would involve writing a js profile for
every form and having the form know about every field in every component on
it that requires validation. That said, I'm still not sure how I would then
get the server side validation to work in a similar way to the Validators of
4.0.

The way I got around the problem in the end was changing the custom
Validators and Translators that we have, to declare their own methods
independently of the Tapestry JSON (I assume it's a JSON) that gets put on
the page. I wrote the js functions into the JSON originally because the
built in validators and translators of Tapestry (like Number and Min) did it
this way. As soon as the tacos validation.js showed up, the Tapesry JSON
disappears. Well, the whole JSON didn't disappear because the Required field
validator was still there. Anyway, having validation js methods that aren't
on the Tapestry JSON worked.

When the Ajax form arrived and took with it the built in Number and Min
validators, I went and made custom ones of those too just so that I could
have number and min validation. But this seemed like a very overkill way of
doing it. But because of the sheer number of components on the form that
required the number and min validation (along with my deadline) this was the
only option for me.

Still, if there is anyone who has an example of an Ajax form doing
validation of numbers, email addresses or min value fields I would very much
appreciate a link to it. I am very keen to learn more about this because the
framework seems to be very good, it's just the lack of examples that I am
struggling with.

Thanks again for your reply,
Kind regards,
Rachel





Marcus Schulte wrote:
> 
> I fear, I can't help a lot with your concrete problems. Nevertheless, two
> hints:
> 
> - Maybe the Tap 4.1 docs on the subject helps:
> http://tapestry.apache.org/tapestry4.1/javascript/index.html
> 
> - Did you consider updating to T 4.1.2? It's really an
> "almost-drop-in-replacement" for 4.0.x. And it's main topic was to pull
> over
> the best from Tacos and make all the Ajax stuff integrate smoothly with
> the
> synchronous-request-oriented parts. Unfortunately, the Tacos version
> for 4.1is not yet final, but we found the snapshot quite workable.
> 
> 
-- 
View this message in context: http://www.nabble.com/Mixing-AjaxForm-and-Form-tf4128054.html#a11770410
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Mixing AjaxForm and Form

Posted by Marcus Schulte <et...@googlemail.com>.
I fear, I can't help a lot with your concrete problems. Nevertheless, two
hints:

- Maybe the Tap 4.1 docs on the subject helps:
http://tapestry.apache.org/tapestry4.1/javascript/index.html

- Did you consider updating to T 4.1.2? It's really an
"almost-drop-in-replacement" for 4.0.x. And it's main topic was to pull over
the best from Tacos and make all the Ajax stuff integrate smoothly with the
synchronous-request-oriented parts. Unfortunately, the Tacos version
for 4.1is not yet final, but we found the snapshot quite workable.

2007/7/23, RachelS <re...@gmail.com>:
>
>
> Hi there
>
> (I'm using Tapestry 4.0.2 and Tacos 4.0.1)
>
> I have a situation where I have a Form and a separate AjaxForm on a page.
>
> What I find is that the Form works perfectly when the AjaxForm is not also
> on the page. As soon as the AjaxForm is added, most of the Form's
> validation
> fails with errors like "Tapestry.validate_currency is not a method" or
> "Tapestry.validate_number is not a method."
>
> I see that Tapestry.validate_number is a method that is added by
> Tapestry's
> form.js when you have "translator="translator:number" on a TextField. To
> try
> and force this to work when both forms are on the page, I'm taking out the
> translator and creating a custom validator that I attach to the TextField
> with a bean which seems like a bit of overkill to duplicate the translator
> functionality.
>
> So I have done some reading and I see that the AjaxForm supplies it's own
> copy of Form.js to the page and that this is why most of the methods fail
> to
> work once the AjaxForm is added to the page.
>
> I also see that there is mention of having a form profile and using
> dojo.validate.check(form, profile) to see if the form passed validation.
> (Once you have setup up the profile of course)
>
> I'd like to know if adding a profile to the form is the 'correct' way to
> accomplish validation in this case.
>
> Also, I'd like to know what the 'correct' way is to do this. Is the best
> pattern to simply add javascript to the page and add the check into the
> form's submit handler? I just don't know what to do with the result from
> dojo.validate.check.
>
> Are there any detailed examples of this available?
>
> Many thanks,
> Rachel
> --
> View this message in context:
> http://www.nabble.com/Mixing-AjaxForm-and-Form-tf4128054.html#a11739250
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Marcus Schulte
http://marcus-schulte.blogspot.com