You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kartweel <rh...@exemail.com.au> on 2011/06/13 19:26:05 UTC

Re: Ajax and Validation

Hi,

I've had major issues with this because the ValidationTracker also reloads
old field values which in a non-ajax scenario is great, but in an ajax
scenario has caused it to clobber the proper field values. It has caused
many headaches and I think it really should be handled [better] by default
in tapestry.

I think I just came across a simple solution to the issue (that i was
specifically having anyway)


	@PageDetached
	void clearValidationTracker() {
		if (request.isXHR()) {
			if (form.getDefaultTracker() != null) form.getDefaultTracker().clear();
		}
	}


In early testing it seems to do what I want.

I also wrote a dummy validation tracker which doesn't persist. But it means
there is no fallback on non-ajax (which was fine for me because my objects
were persisted anyway).

Side note: I've done quite a bit of Ajax and forms in tapestry and found in
general they are nasty together. Almost to the point where I want to dump
tapestry and just code it with javascript and something a lot dumber on the
server side. Then forms and loops and ajax and wowzers!. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Ajax-and-Validation-tp2431706p4485141.html
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: Ajax and Validation

Posted by Dmitry Gusev <dm...@gmail.com>.
I know this thread is too old, but I still have this same issue in T5.3.7.

Since @PageDetached is no longer works, here is how I managed to fix this
for my form:

    @Inject private Heartbeat heartbeat;



    public void onSubmit()

    {

        if (request.isXHR())

        {

            // ...

            ajaxResponseRenderer.addCallback(new JavaScriptCallback()

            {

                @Override

                public void run(JavaScriptSupport javascriptSupport)

                {

                    // ...



                    heartbeat.defer(new Runnable()

                    {

                        @Override

                        public void run()

                        {

                            form.clearErrors();

                        }

                    });

                }

            });

        }

    }



On Mon, Jun 13, 2011 at 10:07 PM, Kartweel <rh...@exemail.com.au> wrote:

> It still gave me issues when submitting a form with an error then
> submitting
> it valid, then it would bring up the old values and clobber the real values
> (after saving I default back to different data in the form).
>
> So I ammended it to
>
>
>         @PageDetached
>         void clearValidationTracker() {
>                 if (request.isXHR()) {
>                         if (workItemsForm.getDefaultTracker() != null)
> workItemsForm.getDefaultTracker().clear();
>                         workItemsForm.setDefaultTracker(null);
>                 }
>         }
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Ajax-and-Validation-tp2431706p4485240.html
> 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
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Re: Ajax and Validation

Posted by Kartweel <rh...@exemail.com.au>.
It still gave me issues when submitting a form with an error then submitting
it valid, then it would bring up the old values and clobber the real values
(after saving I default back to different data in the form).

So I ammended it to


	@PageDetached
	void clearValidationTracker() {
		if (request.isXHR()) {
			if (workItemsForm.getDefaultTracker() != null)
workItemsForm.getDefaultTracker().clear();
			workItemsForm.setDefaultTracker(null);
		}
	}


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Ajax-and-Validation-tp2431706p4485240.html
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