You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/11/27 16:00:57 UTC

AjaxFormLoop validation not working properly.

Hello, I'm using the AjaxFormLoop component throughout my app. I'm not using
clientside validation, but rather serverside validation. Lastly I'm using
flash persist to rebuild the objects within the AjaxFormLoop when a
serverside validation occurs. This all seems to work perfectly well with the
exception of a couple strange behaviors. 

If I add a new row with the addrow button and add bad data to a field,
"example alpha in a numeric field" and submit the form, the app will return
a serverside validation error within the <t:errors/> component properly
describing the error, however the field with the bad data will be cleared of
it's data and no field validation decoration will occur, but the newly
created row will still exist. Now if I repopulate the same field or any
other field within the row with bad data and submit the form, the app will
return the validation error, but this time retain the field data plus
decorate the field with the red border and red label. Now if I add a new row
from the backend on page render, the fields behave properly.

I'm not very familiar with the ValidationTracker, but it almost seems to me
as if the data isn't making it into there. Does anybody think they might
know what's going on here, or have any additional thoughts?

Thanks



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326.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: AjaxFormLoop validation not working properly.

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Just a guess but have you specified t:id for your new row?

On Nov 27, 2012, at 10:44 AM, George Christman <gc...@cardaddy.com> wrote:

> Another update, I'm thinking I'm getting closer to understanding the problem,
> but not sure of the cause. 
> 
> What I'm finding is when I add a new row, tapestry generates an id for my
> fields, 
> 
> example
> quantity_13b4286fcf5
> 
> When I submit the form and it returns with a validation error, I'm noticing
> the id has changed to the following,
> quantity_0
> 
> But if I submit the form a second time with the same row, the id remains the
> same, quantity_0 and the validation error works properly. 
> 
> I'm not sure what would cause the field id's to change. Anybody know?
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718330.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
> 

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


Re: AjaxFormLoop validation not working properly.

Posted by George Christman <gc...@cardaddy.com>.
Another update, I'm thinking I'm getting closer to understanding the problem,
but not sure of the cause. 

What I'm finding is when I add a new row, tapestry generates an id for my
fields, 

example
quantity_13b4286fcf5

When I submit the form and it returns with a validation error, I'm noticing
the id has changed to the following,
quantity_0

But if I submit the form a second time with the same row, the id remains the
same, quantity_0 and the validation error works properly. 

I'm not sure what would cause the field id's to change. Anybody know?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718330.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: AjaxFormLoop validation not working properly.

Posted by George Christman <gc...@cardaddy.com>.
So I was able to get everything working without an issue. I created a method
on the backend which allowed me to pass back my field and then append a
sequence number to the field label. 

t:clientId="prop:getGenerateFieldId(orgKey)"

In order to get the ValidationTracker to record the input properly, I also
needed to override the "recordInput" in ValidationTrackerWrapper just as I
did with "recordError".

Thanks everyone for all your help. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718349.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: AjaxFormLoop validation not working properly.

Posted by George Christman <gc...@cardaddy.com>.
Excellent, Thanks Nourredine. I think I have enough now to finish figuring
this out. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718345.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: AjaxFormLoop validation not working properly.

Posted by Nourredine <no...@atos.net>.
The ValidationTracker stores also the value (see
ValidationTrackerImpl#recordInput() and ValidationTrackerImpl#getInput()).
Again, the key used to store the field's input is based on the
"controlName". That's why the value is not rendered after the first
submission (the key used to store the input was "quantity_13b4286fcf5")



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718343.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: AjaxFormLoop validation not working properly.

Posted by George Christman <gc...@cardaddy.com>.
So last question, where is the field value stored? example I put alpha in a
numeric field and a validation error occurs, the field should return
decorated but with the alpha character still within it. I'm able to return a
decorated field, but the field is returned blank. I'm not sure if the value
is stored with Tapestry or cached in the browser. If cached in the browser
and the id changes, this might be the cause of me losing the value. Once
again, I'm just speculating as I'm not entirely sure how Tapestry is
handling this. 

Thanks



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718342.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: AjaxFormLoop validation not working properly.

Posted by Nourredine <no...@atos.net>.
Hi George,

The "t:id" is a server-side id (used when you @InjectComponent the field in
your class) while the "t:clientId" is used by the TextField component to
generate its client-side id. They are not interdependent.

Also, the TextField 's "controlName" is used by the "ValidationTracker" to
store error messages for fields. The "controlName" is generated from the
clientId if provided. 

In your case, make sure the clientId is unique



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718341.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: AjaxFormLoop validation not working properly.

Posted by George Christman <gc...@cardaddy.com>.
Hi Nourredine, Thanks for the explanation, makes perfect sense. 

I'm a little confused with the id generation sample your using though. Is
the field suppose to read the t:id="label" and append the id from
t:clientId="prop:row.id" ? I'm not sure I follow this logic just yet. Would
you mind elaborating a bit more on this. Thanks. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718339.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: AjaxFormLoop validation not working properly.

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 27 Nov 2012 14:14:54 -0200, Nourredine  
<no...@atos.net> wrote:

> yes, I saw that, but don't know how to make it visible in the mailing  
> list from nabble (I edited my previous post to add a link to nabble).

As a general suggestion, I'd say don't post from Nabble. And don't forget  
that editing posts in Nabble doesn't make the changes you've done arrive  
to people who subscribe to the mailing list instead of using Nabble.

Guys, don't forget: this is a mailing list, not a forum.

-- 
Thiago H. de Paula Figueiredo

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


Re: AjaxFormLoop validation not working properly.

Posted by Nourredine <no...@atos.net>.
yes, I saw that, but don't know how to make it visible in the mailing list
from nabble (I edited my previous post to add a link to nabble).



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718334.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: AjaxFormLoop validation not working properly.

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Nabble ate your code. 

On Nov 27, 2012, at 10:54 AM, Nourredine <no...@atos.net> wrote:

> Hi,
> 
> It is a side effect of the zone refresh and IdAllocator. Ajax requests use
> IdAllocator to generate unique ids. but when the page is rendered after
> submission, the original ids are used. While the ValidationTracker stores
> the "ajaxified" ids.
> 
> as a workaround, you will have to implement your own ValidationTracker and
> return the expected id based on the field controlName. You will have also to
> generate unique ids thanks to the "clientId" parameter
> 
> your page :
> 
> 
> 
> your tml : 
> 
> 
> 
> 
> the custom ValidationTracker : 
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718332.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
> 

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


Re: AjaxFormLoop validation not working properly.

Posted by Nourredine <no...@atos.net>.
Hi,

It is a side effect of the zone refresh and IdAllocator. Ajax requests use
IdAllocator to generate unique ids. but when the page is rendered after
submission, the original ids are used. While the ValidationTracker stores
the "ajaxified" ids.

as a workaround, you will have to implement your own ValidationTracker and
return the expected id based on the field controlName. You will have also to
generate unique ids thanks to the "clientId" parameter

your page :



your tml : 




the custom ValidationTracker : 







--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718332.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: AjaxFormLoop validation not working properly.

Posted by George Christman <gc...@cardaddy.com>.
I'd also like to add I'm applying my field validation within the tml using
t:validate="...".



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-validation-not-working-properly-tp5718326p5718327.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