Re: Dynamic form fields

2017-12-16 Thread Nathan Quirynen

Thanks,

This works perfect for my use case :)
Also when I want to trigger it by something else than a checkbox, for 
example a change in a select, I can probably add a hidden checkbox that 
I can check with javascript to toggle the FormFragment.


Greetings,

Nathan


Op 14/12/2017 om 14:16 schreef Bob Harner:

Nathan,

Have you tried the FormFragment component?

See
https://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/FormFragment.html


On Dec 14, 2017 5:47 AM, "Nathan Quirynen" 
wrote:

Hi,

This subject has been spoken about more in the past, but I still have not
found a good solution to this and still struggle with this.

What is the best practice (Tapestry 5.4+) to add fields to a form
"dynamically". In my use case I just want to add some fields to a form when
a checkbox (also part of the same form) is selected, or remove/hide them
(in a way that they will not be validated and posted) when the checkbox is
deselected.

How do you guys handle these use cases with forms?

Nathan


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




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



Re: Dynamic form fields

2017-12-14 Thread Norman Franke
That definitely works. You can also just add all the fields you’ll need to the 
form and then use JavaScript to hide fields that you don’t need at the time. 
This method is super simple, although you may need to validate some fields on 
the server side. Or set the values to null when you hide them.

-Norman Franke

> On Dec 14, 2017, at 8:16 AM, Bob Harner  wrote:
> 
> Nathan,
> 
> Have you tried the FormFragment component?
> 
> See
> https://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/FormFragment.html
> 


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



Re: Dynamic form fields

2017-12-14 Thread Thiago H. de Paula Figueiredo
On Thu, Dec 14, 2017 at 8:47 AM, Nathan Quirynen <
nat...@pensionarchitects.be> wrote:

> Hi,
>

Hi!


> This subject has been spoken about more in the past, but I still have not
> found a good solution to this and still struggle with this.
>
> What is the best practice (Tapestry 5.4+) to add fields to a form
> "dynamically". In my use case I just want to add some fields to a form when
> a checkbox (also part of the same form) is selected, or remove/hide them
> (in a way that they will not be validated and posted) when the checkbox is
> deselected.
>

Use BeanEditForm or BeanEditor, their 'model' parameters, which is of type
BeanModel, get one instance of it using BeanModelSource and add properties
to it using one of the beanModel.add() methods which receive a
PropertyConduit. In other words, you're creating synthetic properties, in
the sense that they don't map to an existing combination of
field/getter/setter in the class on which the BeanModel was created. Your
PropertyConduit implementation (actually, you'll probably have more than
one) is how you tell Tapestry how to get and set the value for that
property.

There's one example of doing this for editing a Map in
https://stackoverflow.com/questions/21675856/how-to-create-bean-edit-model-for-map-in-tapestry
.

--
Thiago


Re: Dynamic form fields

2017-12-14 Thread Bob Harner
Nathan,

Have you tried the FormFragment component?

See
https://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/FormFragment.html


On Dec 14, 2017 5:47 AM, "Nathan Quirynen" 
wrote:

Hi,

This subject has been spoken about more in the past, but I still have not
found a good solution to this and still struggle with this.

What is the best practice (Tapestry 5.4+) to add fields to a form
"dynamically". In my use case I just want to add some fields to a form when
a checkbox (also part of the same form) is selected, or remove/hide them
(in a way that they will not be validated and posted) when the checkbox is
deselected.

How do you guys handle these use cases with forms?

Nathan


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