Checkbox value for zone update

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Checkbox value for zone update

Stephan Windmüller
Hello,

according to the Tapestry documentation, zones cannot be updated by
checkboxes. I found some information on this topic, primarily in this
mailing list, for how to circumvent this problem.

My current approach is to use tapestry5-jquery:


<t:checkbox t:id="valueCheckBox"
        value="ignoreLengthSelected"
        t:mixins="jquery/bind"
        bind.event="lengthChange"
        bind.eventtype="change"
        bind.zone="resultZone"/>

public Object onValueChange() {
        return resultZone.getBody();
}


However, I do not know how to access the value of the checkbox.
Injecting the component does not help because it does not provide
methods to read the state. Adding a parameter to onValueChange also does
not work.

Does anyone know how to use a checkbox this way?

TIA
 Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Checkbox value for zone update

Chris Poulsen
Hi,

We have a "submittingcheckbox" component for this kind of thing. Basically
the component renders a checkbox and a hidden submit.

An onChange handler on the checkbox clicks the submit

Example usage (T5.4):
 <t:form t:id="selectActionForm" async="true" context="actionRow.original.id
">
    <t:submittingcheckbox value="actionSelected" appearance="inline"
label="" />
</t:form>

Form context can be used for setting up the environment if needed (can be
handled in EventConstants.PREPARE_SUBMIT handler - the example above is
from a data table cell) and the value of the checkbox is properly bound
when handling the EventConstants.SUCCESS event  for the form (where you can
use ajax response renderer to perform zone updates etc)

If you are using t5-jquery you are probably not on 5.4 - so you would need
to replace the form.async with the 5.3 zone equivalent.

HTH
--
Chris

On Fri, Jan 23, 2015 at 1:32 PM, Stephan Windmüller <
[hidden email]> wrote:

> Hello,
>
> according to the Tapestry documentation, zones cannot be updated by
> checkboxes. I found some information on this topic, primarily in this
> mailing list, for how to circumvent this problem.
>
> My current approach is to use tapestry5-jquery:
>
>
> <t:checkbox t:id="valueCheckBox"
>         value="ignoreLengthSelected"
>         t:mixins="jquery/bind"
>         bind.event="lengthChange"
>         bind.eventtype="change"
>         bind.zone="resultZone"/>
>
> public Object onValueChange() {
>         return resultZone.getBody();
> }
>
>
> However, I do not know how to access the value of the checkbox.
> Injecting the component does not help because it does not provide
> methods to read the state. Adding a parameter to onValueChange also does
> not work.
>
> Does anyone know how to use a checkbox this way?
>
> TIA
>  Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Checkbox value for zone update

Thiago H de Paula Figueiredo
In reply to this post by Stephan Windmüller
On Fri, 23 Jan 2015 10:32:00 -0200, Stephan Windmüller  
<[hidden email]> wrote:

> Hello,

Hi!

> <t:checkbox t:id="valueCheckBox"
> value="ignoreLengthSelected"

> However, I do not know how to access the value of the checkbox.

You access the value of the checkbox (or any other Tapestry form field  
component) by accessing the property it's editing. It the case above, the  
ignoreLengthSelected property.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Checkbox value for zone update

Lance Java
In reply to this post by Stephan Windmüller
You could use the observe mixin from tapestry stitch. The mixin can fire a
zone update based on the change event, the current checkbox value can be
sent as the event context.

http://t5stitch-lazan.rhcloud.com/observedemo
On 23 Jan 2015 12:33, "Stephan Windmüller" <
[hidden email]> wrote:

> Hello,
>
> according to the Tapestry documentation, zones cannot be updated by
> checkboxes. I found some information on this topic, primarily in this
> mailing list, for how to circumvent this problem.
>
> My current approach is to use tapestry5-jquery:
>
>
> <t:checkbox t:id="valueCheckBox"
>         value="ignoreLengthSelected"
>         t:mixins="jquery/bind"
>         bind.event="lengthChange"
>         bind.eventtype="change"
>         bind.zone="resultZone"/>
>
> public Object onValueChange() {
>         return resultZone.getBody();
> }
>
>
> However, I do not know how to access the value of the checkbox.
> Injecting the component does not help because it does not provide
> methods to read the state. Adding a parameter to onValueChange also does
> not work.
>
> Does anyone know how to use a checkbox this way?
>
> TIA
>  Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Checkbox value for zone update

Stephan Windmüller
In reply to this post by Thiago H de Paula Figueiredo
On 23.01.2015, Thiago H de Paula Figueiredo wrote:

> You access the value of the checkbox (or any other Tapestry form field
> component) by accessing the property it's editing. It the case above,
> the ignoreLengthSelected property.

This does not work with the zone update, the value is always false.

- Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Checkbox value for zone update

Stephan Windmüller
In reply to this post by Lance Java
On 23.01.2015, schrieb Lance Java wrote:

> You could use the observe mixin from tapestry stitch. The mixin can fire a
> zone update based on the change event, the current checkbox value can be
> sent as the event context.

Hey Lance,

your project sounds very promising, thanks for the hint. But are you
sure that is works with checkboxes? According to Chrome, there is no
event listener registered for "change" with this code:

                                                                <t:checkbox value="ignoreValueSelected"
        t:mixins="stitch/observe"
        clientEvent="click"
        event="updateLength"
        zone="resultZone"/>

- Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Checkbox value for zone update

Stephan Windmüller
In reply to this post by Chris Poulsen
On 23.01.2015, Chris Poulsen wrote:

> We have a "submittingcheckbox" component for this kind of thing. Basically
> the component renders a checkbox and a hidden submit.

Thanks for the suggestion, but using a separate submit field sounds a
bit complex for such a simple task. I refuse to believe that there is no
other way. ;)

- Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Checkbox value for zone update

Lance Java
In reply to this post by Stephan Windmüller
I'm guessing you have a javascript error on your page.

Are you using jquery or prototype? tapestry-stitch only works for
prototype. You'll need to tweak observe. js to get it to work with jquery
(eg observe() changed to on() etc)
On 26 Jan 2015 09:17, "Stephan Windmüller" <
[hidden email]> wrote:

> On 23.01.2015, schrieb Lance Java wrote:
>
> > You could use the observe mixin from tapestry stitch. The mixin can fire
> a
> > zone update based on the change event, the current checkbox value can be
> > sent as the event context.
>
> Hey Lance,
>
> your project sounds very promising, thanks for the hint. But are you
> sure that is works with checkboxes? According to Chrome, there is no
> event listener registered for "change" with this code:
>
>
> <t:checkbox value="ignoreValueSelected"
>         t:mixins="stitch/observe"
>         clientEvent="click"
>         event="updateLength"
>         zone="resultZone"/>
>
> - Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>