Re: wicket 6 dynamic form parts generated in JS

2012-05-15 Thread kamiseq
ok, great.
this is what I thought so I dont want to reinvent things again, many
thanks for quick replay

pozdrawiam
Paweł Kamiński

kami...@gmail.com
pkaminski@gmail.com
__

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



Re: wicket 6 dynamic form parts generated in JS

2012-05-14 Thread Martin Grigorov
Hi,

On Tue, May 15, 2012 at 1:50 AM, kamiseq  wrote:
> hej,
> I would like to dynamically add same part to form, let say I have a
> form that has a section with 3 inputs : start, end and name. those
> section can occur many times depending on model.
>
> this is very easy when depending on server logic and making full page
> refresh every time users add section via link.
> I would like to add such section from javascript, without server
> interaction. the problem I see is that I need to generate names of
> inputs in section witch will contain the right index so wicket knows
> where to put data, right?
>
> example
>
> 
>  
>    
>       
>    
>  
> 
> I created custom FormComponentPanel and overridden convertInput. and
> added ListView to create list with panels.
> when I looked on generated html, names of input where something like :
> name="each.section:1:form.part:start, so I guess I could generate
> something like that in JS but I wonder if this will not break wicket
> logic. more even I hack those names creating elements in JS list will
> not be synchronised with model on server and they will be removed when
> user refreshes the page
>
> I think the best way to do it is to make a round trip to server with
> ajax and replace form content every time user clicks a button.

This is the Wicket way. It is simple to develop.

Another (also Wicket) way is to generate the next row and make it
invisible, then with JS just make it visible and do an Ajax call to
add another invisible row for the next record. This way the model will
be in sync in the client and the server, but you have to be prepared
that the last row may be not used yet.

Yet another way is to create the form components dynamically with JS
and submit to a Page instead of a Form, i.e. 's action will
point to a mounted page. This way when you submit you will have the
flexibility to handle any number of parameters, create a proper model
at the server side and visualize it later however you want.

>
> what do you think?
>
> pozdrawiam
> Paweł Kamiński
>
> kami...@gmail.com
> pkaminski@gmail.com
> __
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>



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

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



wicket 6 dynamic form parts generated in JS

2012-05-14 Thread kamiseq
hej,
I would like to dynamically add same part to form, let say I have a
form that has a section with 3 inputs : start, end and name. those
section can occur many times depending on model.

this is very easy when depending on server logic and making full page
refresh every time users add section via link.
I would like to add such section from javascript, without server
interaction. the problem I see is that I need to generate names of
inputs in section witch will contain the right index so wicket knows
where to put data, right?

example


  

   

  

I created custom FormComponentPanel and overridden convertInput. and
added ListView to create list with panels.
when I looked on generated html, names of input where something like :
name="each.section:1:form.part:start, so I guess I could generate
something like that in JS but I wonder if this will not break wicket
logic. more even I hack those names creating elements in JS list will
not be synchronised with model on server and they will be removed when
user refreshes the page

I think the best way to do it is to make a round trip to server with
ajax and replace form content every time user clicks a button.

what do you think?

pozdrawiam
Paweł Kamiński

kami...@gmail.com
pkaminski@gmail.com
__

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