You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bertrand Guay-Paquet <be...@step.polymtl.ca> on 2012/03/07 20:52:34 UTC

Form with variable number of inputs

Hi,

I have a form with a list of FormComponentPanels for phone numbers. 
Currently, adding a new phone number to the list involves an ajax 
request to add a new FormComponentPanel instance to the form and then 
another request to submit the form.

Is there a way to achieve this without the intermediate ajax roundtrip 
which adds the new component? Adding a new FormComponentPanel to the 
client's DOM can easily be done with javascript, but can Wicket's form 
processing handle a variable size array of inputs?

The input array would be of the form:
phoneNumber[0]="..."
phoneType[0]="..."
phoneNumber[n]="..."
phoneType[n]="..."

Besides less requests sent to the server, this is also necessary to make 
such a form stateless.

Thanks,
Bertrand

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


Re: Form with variable number of inputs

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Thanks for the input Martin. Essentially, it's possible, but I'd have to 
rewrite form handling code and lose functionality :)

Another idea: maybe it is possible to handle the variable number of form 
components with page parameters. Something like 
"http://....&numPhones=n" where "numPhones" would be set by the "add 
phone number" button. A stateless form in a stateless page would then be 
able to add the required number of form components to process the 
received input.

One way or another, this doesn't look like a very easy task. I'll 
definitely work on some other parts of the site before attempting this.

On 08/03/2012 2:50 AM, Martin Grigorov wrote:
> Hi,
>
> One way to accomplish this is to submit to a page, not to a Form, and
> handle the request parameters manually.
> But this way it wont be Ajax anymore and you'll go to a new page.
> Additionally you will lose the form validation.
>
> On Wed, Mar 7, 2012 at 9:52 PM, Bertrand Guay-Paquet
> <be...@step.polymtl.ca>  wrote:
>> Hi,
>>
>> I have a form with a list of FormComponentPanels for phone numbers.
>> Currently, adding a new phone number to the list involves an ajax request to
>> add a new FormComponentPanel instance to the form and then another request
>> to submit the form.
>>
>> Is there a way to achieve this without the intermediate ajax roundtrip which
>> adds the new component? Adding a new FormComponentPanel to the client's DOM
>> can easily be done with javascript, but can Wicket's form processing handle
>> a variable size array of inputs?
>>
>> The input array would be of the form:
>> phoneNumber[0]="..."
>> phoneType[0]="..."
>> phoneNumber[n]="..."
>> phoneType[n]="..."
>>
>> Besides less requests sent to the server, this is also necessary to make
>> such a form stateless.
>>
>> Thanks,
>> Bertrand
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>

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


Re: Form with variable number of inputs

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

One way to accomplish this is to submit to a page, not to a Form, and
handle the request parameters manually.
But this way it wont be Ajax anymore and you'll go to a new page.
Additionally you will lose the form validation.

On Wed, Mar 7, 2012 at 9:52 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> Hi,
>
> I have a form with a list of FormComponentPanels for phone numbers.
> Currently, adding a new phone number to the list involves an ajax request to
> add a new FormComponentPanel instance to the form and then another request
> to submit the form.
>
> Is there a way to achieve this without the intermediate ajax roundtrip which
> adds the new component? Adding a new FormComponentPanel to the client's DOM
> can easily be done with javascript, but can Wicket's form processing handle
> a variable size array of inputs?
>
> The input array would be of the form:
> phoneNumber[0]="..."
> phoneType[0]="..."
> phoneNumber[n]="..."
> phoneType[n]="..."
>
> Besides less requests sent to the server, this is also necessary to make
> such a form stateless.
>
> Thanks,
> Bertrand
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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