Select onChange with a context value

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

Select onChange with a context value

lebenski
Hi All,

I am generating ~100 select items in a loop and would like to listen for the ajax onChange event for each of these.  I am getting the event successfully using the following:

<t:zone t:id="gridZone">
...
<t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:zone="gridZone">
...
</t:zone>

public Object onChangeFromColourProfileOverride() {
...
return gridZone.getBody();
}

The value is set as expected on the cubeCard.colourCombinationOverride object, however in order to know which select was updated I need some sort of context value.  

I have played around with the jquery/bind mixin and can get it to do what I would like but it involves setting  bind.callback="function(event,ui,url) { url.addContext(event.target.value); } on each of my select components.  This significantly reduces client side performance.

So I'd like to know if anyone has figured out a way to pass a context value in onChange Ajax requests from select components?  My ideal situation would be to end up with something along these lines:

<t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:context="myId" t:zone="gridZone">

public Object onChangeFromColourProfileOverride(Integer myId) {
...
}

Thanks,
Ben.
     
Reply | Threaded
Open this post in threaded view
|

Re: Select onChange with a context value

Lance Java
I've just recently added a onEvent mixin to tapestry-stitch... it sounds
like exactly what you're after
http://tapestry-stitch.uklance.cloudbees.net/oneventdemo



On 26 June 2013 18:14, Ben Titmarsh <[hidden email]> wrote:

> Hi All,
>
> I am generating ~100 select items in a loop and would like to listen for
> the ajax onChange event for each of these.  I am getting the event
> successfully using the following:
>
> <t:zone t:id="gridZone">
> ...
> <t:select t:id="colourProfileOverride"
> t:value="cubeCard.colourCombinationOverride" t:zone="gridZone">
> ...
> </t:zone>
>
> public Object onChangeFromColourProfileOverride() {
> ...
> return gridZone.getBody();
> }
>
> The value is set as expected on the cubeCard.colourCombinationOverride
> object, however in order to know which select was updated I need some sort
> of context value.
>
> I have played around with the jquery/bind mixin and can get it to do what
> I would like but it involves setting  bind.callback="function(event,ui,url)
> { url.addContext(event.target.value); } on each of my select components.
>  This significantly reduces client side performance.
>
> So I'd like to know if anyone has figured out a way to pass a context
> value in onChange Ajax requests from select components?  My ideal situation
> would be to end up with something along these lines:
>
> <t:select t:id="colourProfileOverride"
> t:value="cubeCard.colourCombinationOverride" t:context="myId"
> t:zone="gridZone">
>
> public Object onChangeFromColourProfileOverride(Integer myId) {
> ...
> }
>
> Thanks,
> Ben.
>
Reply | Threaded
Open this post in threaded view
|

Re: Select onChange with a context value

Jens Breitenstein
In reply to this post by lebenski
Hi Ben!

AFAIR you can pass a context but this value remains constant and is independent from the selection made. So at the very end I used bind like you did. Same problem applies to Checkboxes, so I do not know if Tapestry generally misses something or we simply did not find it yet...

Why did you think there is a "dramatic" performance impact?

Jens

Sent from my iPhone

On 26.06.2013, at 19:14, Ben Titmarsh <[hidden email]> wrote:

> Hi All,
>
> I am generating ~100 select items in a loop and would like to listen for the ajax onChange event for each of these.  I am getting the event successfully using the following:
>
> <t:zone t:id="gridZone">
> ...
> <t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:zone="gridZone">
> ...
> </t:zone>
>
> public Object onChangeFromColourProfileOverride() {
> ...
> return gridZone.getBody();
> }
>
> The value is set as expected on the cubeCard.colourCombinationOverride object, however in order to know which select was updated I need some sort of context value.  
>
> I have played around with the jquery/bind mixin and can get it to do what I would like but it involves setting  bind.callback="function(event,ui,url) { url.addContext(event.target.value); } on each of my select components.  This significantly reduces client side performance.
>
> So I'd like to know if anyone has figured out a way to pass a context value in onChange Ajax requests from select components?  My ideal situation would be to end up with something along these lines:
>
> <t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:context="myId" t:zone="gridZone">
>
> public Object onChangeFromColourProfileOverride(Integer myId) {
> ...
> }
>
> Thanks,
> Ben.
>                        

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

Reply | Threaded
Open this post in threaded view
|

Re: Select onChange with a context value

JumpStart
In reply to this post by lebenski
Some random ides that I haven't tried...

I think you'll need to combine this:

        http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/selectdependency1

with this:

        http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/eventlinksinaloop

To get the id of the entity in the row, try:

        - Make the Select encoder include the id in the value that it encodes/decodes; or
        - Use zone per row, include the id in the zone id (see the second example) and in the event handler you might be able to get clientId from the zone.

Geoff

On 27/06/2013, at 3:14 AM, Ben Titmarsh wrote:

> Hi All,
>
> I am generating ~100 select items in a loop and would like to listen for the ajax onChange event for each of these.  I am getting the event successfully using the following:
>
> <t:zone t:id="gridZone">
> ...
> <t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:zone="gridZone">
> ...
> </t:zone>
>
> public Object onChangeFromColourProfileOverride() {
> ...
> return gridZone.getBody();
> }
>
> The value is set as expected on the cubeCard.colourCombinationOverride object, however in order to know which select was updated I need some sort of context value.  
>
> I have played around with the jquery/bind mixin and can get it to do what I would like but it involves setting  bind.callback="function(event,ui,url) { url.addContext(event.target.value); } on each of my select components.  This significantly reduces client side performance.
>
> So I'd like to know if anyone has figured out a way to pass a context value in onChange Ajax requests from select components?  My ideal situation would be to end up with something along these lines:
>
> <t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:context="myId" t:zone="gridZone">
>
> public Object onChangeFromColourProfileOverride(Integer myId) {
> ...
> }
>
> Thanks,
> Ben.
>    


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

Reply | Threaded
Open this post in threaded view
|

Re: Select onChange with a context value

JumpStart
Actually, replace the first link with this simpler example:

        http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/selectmore1

Geoff

On 27/06/2013, at 7:38 PM, Geoff Callender wrote:

> Some random ides that I haven't tried...
>
> I think you'll need to combine this:
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/selectdependency1
>
> with this:
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/eventlinksinaloop
>
> To get the id of the entity in the row, try:
>
> - Make the Select encoder include the id in the value that it encodes/decodes; or
> - Use zone per row, include the id in the zone id (see the second example) and in the event handler you might be able to get clientId from the zone.
>
> Geoff
>
> On 27/06/2013, at 3:14 AM, Ben Titmarsh wrote:
>
>> Hi All,
>>
>> I am generating ~100 select items in a loop and would like to listen for the ajax onChange event for each of these.  I am getting the event successfully using the following:
>>
>> <t:zone t:id="gridZone">
>> ...
>> <t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:zone="gridZone">
>> ...
>> </t:zone>
>>
>> public Object onChangeFromColourProfileOverride() {
>> ...
>> return gridZone.getBody();
>> }
>>
>> The value is set as expected on the cubeCard.colourCombinationOverride object, however in order to know which select was updated I need some sort of context value.  
>>
>> I have played around with the jquery/bind mixin and can get it to do what I would like but it involves setting  bind.callback="function(event,ui,url) { url.addContext(event.target.value); } on each of my select components.  This significantly reduces client side performance.
>>
>> So I'd like to know if anyone has figured out a way to pass a context value in onChange Ajax requests from select components?  My ideal situation would be to end up with something along these lines:
>>
>> <t:select t:id="colourProfileOverride" t:value="cubeCard.colourCombinationOverride" t:context="myId" t:zone="gridZone">
>>
>> public Object onChangeFromColourProfileOverride(Integer myId) {
>> ...
>> }
>>
>> Thanks,
>> Ben.
>>    
>


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