You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andreas Andreou <an...@di.uoa.gr> on 2010/01/20 17:51:29 UTC

Re: T4.1.6 Troubles with accessing bindings from async listener method

When the direct link is triggered, your listener is called.
I don't think the source parameter will be bound since there's no page
rendering (or rewinding) happening - just the listener method getting called.

Anyway, you have a few options here:
- Persist the list into the session.
- or, just add the item to the direct link (it needs to be
serializable or you need
to write a custom DataSqueezer for it) using:
    <binding name="parameters" value="ognl:value" />

For further reading:
- http://tapestry.apache.org/tapestry4.1/quickstart/directlink.html
- http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/services/DataSqueezer.html
- http://wiki.apache.org/tapestry/DataSqueezer


On Wed, Jan 20, 2010 at 18:20, Marko Mrkus <ma...@bumblehood.com> wrote:
> Is it possible that only invariant expression bindings are updated in
> listener methods for form submissions and invoking direct service urls?
>
> -----Original Message-----
> From: Marko Mrkus [mailto:marko.mrkus@bumblehood.com]
> Sent: Wednesday, January 20, 2010 2:55 PM
> To: 'Tapestry users'
> Subject: T4.1.6 Troubles with accessing bindings from async listener method
>
> Hi, all!
>
>
>
> I have problems with understanding how bindings work in Tapestry when they
> are accessed from async listener.
>
> I'm trying to build a List component which takes parameters source, value
> and selectedValue. It renders source and updates value as For component.
>
> I would like that users can select one row in List component and that some
> components on page are updated and that they use this updated selected
> object value.
>
>
>
> Component specification is:
>
>
>
> <component-specification class="org.tapestry.example.ListComponent">
>
>            <parameter name="source" />
>
>            <parameter name="value" />
>
>            <parameter name="selectedValue" />
>
>            <parameter name="updateComponents" />
>
>
>
>            <component id="iterator" type="For">
>
>            <inherited-binding parameter-name="source" name="source" />
>
>            <inherited-binding parameter-name="value" name="value" />
>
> </component>
>
>
>
> <component id="selectLink" type="DirectLink">
>
>            <binding name="listener" value="listener:changeSelecedObject" />
>
>            <binding name="parameters"
> value="ognl:components.get('iterator').index" />
>
>  </component>
>
>
>
> </component-specification>
>
>
>
> Java class:
>
>
>
> package org.tapestry.example;
>
>
>
> public abstract class ListComponent extends BaseComponents{
>
>
>
>            public void changeSelectedObject(IRequestCycle cycle) {
>
>                        int indexOfRow =
> (Integer)cycle.getListenerParameters[0];
>
>                        Object value = this.getSource().get(indexOfRow);
> <----------------- THIS LINE THROWS IndexOutOfBoundsException since
> this.getSource() returns empty list.
>
>
>
>                        this.setSelectedValue(value);
>
>
>
>                        for (String compId : this.getUpdateComponents) {
>
>
> cycle.getResponseBuilder().updateComponent(compId);
>
> }
>
> }
>
>
>
> public abstract void getSource(); // Biding accessor for Source parameter
>
> public abstract void getUpdateComponents(); //Biding accessor for Update
> Components parameter
>
> public abstract void setSelectedValue(Object objValue);
>
> }
>
>
>
> I wonder why I'm getting empty list in listener method. Parameter source was
> bound with list with 2 items in it and I got there empty list.
>
>
>
> Any help is appreciated.
>
>
>
> Regards,
>
> Marko
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


RE: T4.1.6 Troubles with accessing bindings from async listener method

Posted by Marko Mrkus <ma...@bumblehood.com>.
I solved it with passing the index of an item in collection as a direct link
parameter which then updates component's parameter. Then the client of this
component (usually page) access the object from collection with updated
index. Thanks!

-----Original Message-----
From: andreoua@gmail.com [mailto:andreoua@gmail.com] On Behalf Of Andreas
Andreou
Sent: Wednesday, January 20, 2010 5:51 PM
To: Tapestry users
Subject: Re: T4.1.6 Troubles with accessing bindings from async listener
method

When the direct link is triggered, your listener is called.
I don't think the source parameter will be bound since there's no page
rendering (or rewinding) happening - just the listener method getting
called.

Anyway, you have a few options here:
- Persist the list into the session.
- or, just add the item to the direct link (it needs to be
serializable or you need
to write a custom DataSqueezer for it) using:
    <binding name="parameters" value="ognl:value" />

For further reading:
- http://tapestry.apache.org/tapestry4.1/quickstart/directlink.html
-
http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/services/
DataSqueezer.html
- http://wiki.apache.org/tapestry/DataSqueezer


On Wed, Jan 20, 2010 at 18:20, Marko Mrkus <ma...@bumblehood.com>
wrote:
> Is it possible that only invariant expression bindings are updated in
> listener methods for form submissions and invoking direct service urls?
>
> -----Original Message-----
> From: Marko Mrkus [mailto:marko.mrkus@bumblehood.com]
> Sent: Wednesday, January 20, 2010 2:55 PM
> To: 'Tapestry users'
> Subject: T4.1.6 Troubles with accessing bindings from async listener
method
>
> Hi, all!
>
>
>
> I have problems with understanding how bindings work in Tapestry when they
> are accessed from async listener.
>
> I'm trying to build a List component which takes parameters source, value
> and selectedValue. It renders source and updates value as For component.
>
> I would like that users can select one row in List component and that some
> components on page are updated and that they use this updated selected
> object value.
>
>
>
> Component specification is:
>
>
>
> <component-specification class="org.tapestry.example.ListComponent">
>
>            <parameter name="source" />
>
>            <parameter name="value" />
>
>            <parameter name="selectedValue" />
>
>            <parameter name="updateComponents" />
>
>
>
>            <component id="iterator" type="For">
>
>            <inherited-binding parameter-name="source" name="source" />
>
>            <inherited-binding parameter-name="value" name="value" />
>
> </component>
>
>
>
> <component id="selectLink" type="DirectLink">
>
>            <binding name="listener" value="listener:changeSelecedObject"
/>
>
>            <binding name="parameters"
> value="ognl:components.get('iterator').index" />
>
>  </component>
>
>
>
> </component-specification>
>
>
>
> Java class:
>
>
>
> package org.tapestry.example;
>
>
>
> public abstract class ListComponent extends BaseComponents{
>
>
>
>            public void changeSelectedObject(IRequestCycle cycle) {
>
>                        int indexOfRow =
> (Integer)cycle.getListenerParameters[0];
>
>                        Object value = this.getSource().get(indexOfRow);
> <----------------- THIS LINE THROWS IndexOutOfBoundsException since
> this.getSource() returns empty list.
>
>
>
>                        this.setSelectedValue(value);
>
>
>
>                        for (String compId : this.getUpdateComponents) {
>
>
> cycle.getResponseBuilder().updateComponent(compId);
>
> }
>
> }
>
>
>
> public abstract void getSource(); // Biding accessor for Source parameter
>
> public abstract void getUpdateComponents(); //Biding accessor for Update
> Components parameter
>
> public abstract void setSelectedValue(Object objValue);
>
> }
>
>
>
> I wonder why I'm getting empty list in listener method. Parameter source
was
> bound with list with 2 items in it and I got there empty list.
>
>
>
> Any help is appreciated.
>
>
>
> Regards,
>
> Marko
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


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