You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ilya Obshadko <il...@gmail.com> on 2014/04/14 12:36:27 UTC
dynamic forms concept & possible solutions
I've tried to approach the problem from different angles, but
unsuccessfully.
Let's suppose the following scenario (that's what I'm working on right now
actually).
You have an event registration form and you may register another
participant with you; you're using suggestion (autocomplete) to enter other
participant's name; if this person is already in the system, field is
marked with a checkmark; if not, user is prompted to enter email so the
system could send an invitation upon form completion.
What do we need to implement it?
1) handle autocompletion selection event (that's already done, the
resulting mixin is pretty straightforward once you realize the mechanics of
jQuery autocomplete).
2) update the form based on autocompletion result.
Now, here is a problem:
- if we use a component event request that updates form zone, yes, we can
get what we want, but everything user has entered into other fields is
lost; obviously this is not acceptable
- if we trigger form submission (it's possible to do that using hidden
submit, it's not very elegant, but it works), we have to go through form
validation which fails in most cases because at this point form is not yet
completed; user receives non-relevant validation errors
- FormInjector might be a solution, but it can only add something to a
form, rather than update its current controls
So none of the above can actually solve the problem.
Are there any other approaches to this?
--
Ilya Obshadko
Re: dynamic forms concept & possible solutions
Posted by Ville Virtanen <vi...@orientimport.fi>.
I think Thiago means onSubmit()
(If there are errors, it will never reach on success, right?)
This also means that client side validation must be disabled, or then a
bit of JS must be used to disable it for the hidden button. (Js
interface also exists to submit the form iirc, but for these bits
someone else knows better than me probably.)
Ville
14.4.2014 15:19, Thiago H de Paula Figueiredo kirjoitti:
> On Mon, 14 Apr 2014 07:36:27 -0300, Ilya Obshadko
> <il...@gmail.com> wrote:
>
>> - if we trigger form submission (it's possible to do that using hidden
>> submit, it's not very elegant, but it works), we have to go through form
>> validation which fails in most cases because at this point form is
>> not yet completed; user receives non-relevant validation errors
>
> Please try this:
>
> @Environmental
> private ValidationTracker validationTracker;
>
> public void onSuccess() {
> if (notReallyValidationNow) { // submission from autocomplete
> validationTracker.clear(); // all validation errors are dropped
> }
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: dynamic forms concept & possible solutions
Posted by Ilya Obshadko <il...@gmail.com>.
OK, so we can omit validation when needed.
That's great (I wasn't aware of such a method), but I don't like "hidden
submit" concept either, it looks more like a workaround rather than a
solution.
I remember from my earlier experience with Tapestry that simply calling
form.submit() without any hidden submit button didn't work. Is that still
the case?
On Tue, Apr 15, 2014 at 12:26 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> On Mon, 14 Apr 2014 09:39:33 -0300, Chris Poulsen <ma...@nesluop.dk>
> wrote:
>
> I dont think onSuccess is called if validation fails, perhaps one could
>> adjust the outcome of the validation phase of the form like suggested.
>>
>
> Yeah, I just noticed that after I posted the message, and you're right
> about the validation phase (specifically of the form) being the right place
> for putting that code. Thanks for pointing this! :)
>
>
>
>>
>> On Mon, Apr 14, 2014 at 2:19 PM, Thiago H de Paula Figueiredo <
>> thiagohp@gmail.com> wrote:
>>
>> On Mon, 14 Apr 2014 07:36:27 -0300, Ilya Obshadko <
>>> ilya.obshadko@gmail.com>
>>> wrote:
>>>
>>> - if we trigger form submission (it's possible to do that using hidden
>>>
>>>> submit, it's not very elegant, but it works), we have to go through form
>>>> validation which fails in most cases because at this point form is not
>>>> yet completed; user receives non-relevant validation errors
>>>>
>>>>
>>> Please try this:
>>>
>>> @Environmental
>>> private ValidationTracker validationTracker;
>>>
>>> public void onSuccess() {
>>> if (notReallyValidationNow) { // submission from autocomplete
>>> validationTracker.clear(); // all validation errors are
>>> dropped
>>> }
>>> }
>>>
>>> --
>>> Thiago H. de Paula Figueiredo
>>> Tapestry, Java and Hibernate consultant and developer
>>> http://machina.com.br
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Ilya Obshadko
Re: dynamic forms concept & possible solutions
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 14 Apr 2014 09:39:33 -0300, Chris Poulsen <ma...@nesluop.dk>
wrote:
> I dont think onSuccess is called if validation fails, perhaps one could
> adjust the outcome of the validation phase of the form like suggested.
Yeah, I just noticed that after I posted the message, and you're right
about the validation phase (specifically of the form) being the right
place for putting that code. Thanks for pointing this! :)
>
>
> On Mon, Apr 14, 2014 at 2:19 PM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
>> On Mon, 14 Apr 2014 07:36:27 -0300, Ilya Obshadko
>> <il...@gmail.com>
>> wrote:
>>
>> - if we trigger form submission (it's possible to do that using hidden
>>> submit, it's not very elegant, but it works), we have to go through
>>> form
>>> validation which fails in most cases because at this point form is not
>>> yet completed; user receives non-relevant validation errors
>>>
>>
>> Please try this:
>>
>> @Environmental
>> private ValidationTracker validationTracker;
>>
>> public void onSuccess() {
>> if (notReallyValidationNow) { // submission from autocomplete
>> validationTracker.clear(); // all validation errors are
>> dropped
>> }
>> }
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: dynamic forms concept & possible solutions
Posted by Chris Poulsen <ma...@nesluop.dk>.
I dont think onSuccess is called if validation fails, perhaps one could
adjust the outcome of the validation phase of the form like suggested.
On Mon, Apr 14, 2014 at 2:19 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> On Mon, 14 Apr 2014 07:36:27 -0300, Ilya Obshadko <il...@gmail.com>
> wrote:
>
> - if we trigger form submission (it's possible to do that using hidden
>> submit, it's not very elegant, but it works), we have to go through form
>> validation which fails in most cases because at this point form is not
>> yet completed; user receives non-relevant validation errors
>>
>
> Please try this:
>
> @Environmental
> private ValidationTracker validationTracker;
>
> public void onSuccess() {
> if (notReallyValidationNow) { // submission from autocomplete
> validationTracker.clear(); // all validation errors are
> dropped
> }
> }
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: dynamic forms concept & possible solutions
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 14 Apr 2014 07:36:27 -0300, Ilya Obshadko
<il...@gmail.com> wrote:
> - if we trigger form submission (it's possible to do that using hidden
> submit, it's not very elegant, but it works), we have to go through form
> validation which fails in most cases because at this point form is not
> yet completed; user receives non-relevant validation errors
Please try this:
@Environmental
private ValidationTracker validationTracker;
public void onSuccess() {
if (notReallyValidationNow) { // submission from autocomplete
validationTracker.clear(); // all validation errors are dropped
}
}
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org