You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by davidb82 <da...@thisisnumero.com> on 2009/08/03 18:12:39 UTC

question about forminjector and client ids

I have been experimenting with using the AjaxFormLoop component, however,
I've run into a problem with displaying validation errors and I was hoping
someone could help me out.

My problem is that if additional rows are added to the form via the formloop
and the form is submitted with errors in these fields, when the form is
redisplayed, the new rows that were added are blank (i.e. have no values)
and aren't highlighted as being in error, although they are redisplayed.
This is as opposed to fields which are part of the form loop but which were
rendered by the initial page request.

The reason for this behaviour seems to be that the clientids change between
submission and response. I can see that the FormInjector is munging the ids
in json responses as each row gets added, to ensure uniqueness - which seems
reasonable - however, the exact details of how this bit of code works are
beyond comprehension by my tiny and inferior brain. And when the form gets
re-rendered to display the validation error messages, I can see that the
form fields have their ids assigned via RenderSupport, which delegates to
simple strategy of just appending "_<incrementing_number>" for duplicate
ids. So I think I understand roughly what's going wrong, but don't know how
to resolve it (another productive afternoon...)  

Has anyone else run into this problem before and had more success than me?
-- 
View this message in context: http://www.nabble.com/question-about-forminjector-and-client-ids-tp24793495p24793495.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: question about forminjector and client ids

Posted by davidb82 <da...@thisisnumero.com>.

davidb82 wrote:
> 
> I have been experimenting with using the AjaxFormLoop component, however,
> I've run into a problem with displaying validation errors and I was hoping
> someone could help me out.
> 
> My problem is that if additional rows are added to the form via the
> formloop and the form is submitted with errors in these fields, when the
> form is redisplayed, the new rows that were added are blank (i.e. have no
> values) and aren't highlighted as being in error, although they are
> redisplayed. This is as opposed to fields which are part of the form loop
> but which were rendered by the initial page request.
> 
> The reason for this behaviour seems to be that the clientids change
> between submission and response. I can see that the FormInjector is
> munging the ids in json responses as each row gets added, to ensure
> uniqueness - which seems reasonable - however, the exact details of how
> this bit of code works are beyond comprehension by my tiny and inferior
> brain. And when the form gets re-rendered to display the validation error
> messages, I can see that the form fields have their ids assigned via
> RenderSupport, which delegates to simple strategy of just appending
> "_<incrementing_number>" for duplicate ids. So I think I understand
> roughly what's going wrong, but don't know how to resolve it (another
> productive afternoon...)  
> 
> Has anyone else run into this problem before and had more success than me?
> 

I've created a fix for this issue myself and thought I'd upload a mixin
which fixes it (for me at least). 
To use it, just add it as a mixin to the component that is rendering the
FormInjector.

http://www.nabble.com/file/p24812024/FormInjectorValidationMixin.java
FormInjectorValidationMixin.java 




-- 
View this message in context: http://www.nabble.com/question-about-forminjector-and-client-ids-tp24793495p24812024.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