this should work perfectly for you

 public String getZonedId() {
        return resources.getId() + "-zone";
}

public void onUpdateCount() {
        count++;
        System.out.println(getCompId());
        ajaxResponseRenderer.addRender(getZonedId(), countZone);
    }

<t:zone t:id="countZone" id="prop:zoneId">
        Count : ${count}
    </t:zone>
    <t:eventLink t:async="true" t:event="updateCount" >Update Count for
        Component ${compId}</t:eventLink>

On Thu, Feb 19, 2015 at 1:53 PM, George Christman <gchrist...@cardaddy.com>
wrote:

> As Thiago pointed out, you need to come up with some sort of dynamic id
> generator that can be used to set the id in the tml and the
> responseRenderer. I happened to just use the id you used for your
> component, but as thiago said, you may want to use that else where and may
> want to generate a unique one for your zone.
>
> On Thu, Feb 19, 2015 at 1:45 PM, Sumanth <roasteddra...@gmail.com> wrote:
>
>> @Chris
>> Hi Chris,
>>
>> I've tried with zone's with t:async and even zone with ^ but doesnt solve
>> the problem.
>>
>> shouldn't the component be a black box from my perspective? And  like
>> George Christman has said, the zone's client id's are uniquely generated
>> by
>> tapestry itself, but some how it is unaware of this fact. Secondly doing
>> this manually on the above mentioned component is easy but that is not
>> dynamic too.
>>
>> One more thing, if we are building such a component from scratch maybe we
>> can take care of it but we have some complex component (a table component
>> with lazy loading etc) and going inside it to change every id to make it
>> unique ourselves cannot be done. This issue came up today only because we
>> needed two such components in the same page but different tabs and when
>> the
>> second table never updated it's data content instead it was updating the
>> first table's data.
>>
>> ajaxResponseRenderer.addRender("countZone_0", countZone) this will never
>> work for us because, once the zone is updated then there is high
>> possibility that the client id would have changed, for example in lazy
>> loading results , then the results would not further load as the id will
>> be
>> updated by tapestry.
>>
>> kind regards
>> Sumanth
>> On 19-Feb-2015 7:15 pm, "George Christman" <gchrist...@cardaddy.com>
>> wrote:
>>
>> > I would have thought tapestry would have done this automatically, but
>> the
>> > problem is your ajaxresponserender is telling the first zone to update
>> > rather than _0. This will get your second zone updating.
>> >
>> > ajaxResponseRenderer.addRender("countZone_0", countZone);
>> >
>> > I'm not sure what the best automated way to do this would be.
>> >
>> > On Thu, Feb 19, 2015 at 8:17 AM, Sumanth <roasteddra...@gmail.com>
>> wrote:
>> >
>> > > Forgot. :)
>> > >
>> > > TestPage.tml
>> > >
>> > > <t:test.TestComponent t:id="abcd" t:count="countForComponentA" />
>> > >
>> > >  <t:test.TestComponent t:id="hijk" t:count="countForComponentB" />
>> > >
>> > > TestPage.java
>> > >
>> > > public class TestPage {
>> > >
>> > >   @Property
>> > >   @Persist
>> > >   private int countForComponentA;
>> > >
>> > >   @Property
>> > >   @Persist
>> > >   private int countForComponentB;
>> > >
>> > > }
>> > >
>> > > TestComponent.tml
>> > >
>> > > <t:container
>> > > xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd";
>> > > xmlns:p="tapestry:parameter">
>> > >
>> > >   <t:zone t:id="countZone" >
>> > >     Count : ${count}
>> > >   </t:zone>
>> > >   <t:eventLink t:async="true" t:event="updateCount" >Update Count for
>> > > Component ${compId}</t:eventLink>
>> > >
>> > > </t:container>
>> > >
>> > > TestComponent.java
>> > >
>> > >
>> > >
>> > > public class TestComponent{
>> > >
>> > >
>> > >   @Parameter(required=true)
>> > >   @Property
>> > >   private int count;
>> > >
>> > >   @Inject
>> > >   private ComponentResources componentResources;
>> > >
>> > >   @Inject
>> > >   private AjaxResponseRenderer ajaxResponseRenderer;
>> > >
>> > >   @InjectComponent
>> > >   private Zone countZone;
>> > >
>> > >   public void onUpdateCount() {
>> > >     count++;
>> > >     ajaxResponseRenderer.addRender(countZone);
>> > >   }
>> > >
>> > >   public String getCompId() {
>> > >     return componentResources.getId();
>> > >   }
>> > > }
>> > >
>> > >
>> > > On Thu, Feb 19, 2015 at 2:10 PM, Thiago H de Paula Figueiredo <
>> > > thiag...@gmail.com> wrote:
>> > >
>> > > > On Thu, 19 Feb 2015 11:01:13 -0200, Sumanth <
>> roasteddra...@gmail.com>
>> > > > wrote:
>> > > >
>> > > >  Hello Users,
>> > > >>
>> > > >
>> > > > Hi!
>> > > >
>> > > > Please post the code when asking for help. We're not psychics
>> (well, at
>> > > > least I know I'm not). :)
>> > > >
>> > > >
>> > > >
>> > > >> I am facing a problem with Tapestry components and would like to
>> know
>> > if
>> > > >> this is a bug.
>> > > >>
>> > > >> I have two components which are the same . They have a count field
>> > and a
>> > > >> link to update the count via ajax.
>> > > >>
>> > > >> The problem is when you click on the link from the second component
>> > then
>> > > >> the count zone of the first component gets updated (from UI
>> > > perspective).
>> > > >> But if you refresh the page, then the values are properly shown.
>> > > >>
>> > > >> Please see the screenshots for further explanations
>> > > >>
>> > > >> http://s7.postimg.org/qrz7zuqjf/Before_Clicking_Anything.png
>> > > >>
>> > > >> http://s4.postimg.org/nenbw7brh/After_Clicking_Second_Link.png
>> > > >>
>> > > >> http://s10.postimg.org/8kaij68rt/After_Refresh.png
>> > > >>
>> > > >>
>> > > >> Kind Regards,
>> > > >> Sumanth
>> > > >>
>> > > >
>> > > >
>> > > > --
>> > > > Thiago H. de Paula Figueiredo
>> > > > Tapestry, Java and Hibernate consultant and developer
>> > > > http://machina.com.br
>> > > >
>> > > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> > > > For additional commands, e-mail: users-h...@tapestry.apache.org
>> > > >
>> > > >
>> > >
>> >
>> >
>> >
>> > --
>> > George Christman
>> > CEO
>> > www.CarDaddy.com
>> > P.O. Box 735
>> > Johnstown, New York
>> >
>>
>
>
>
> --
> George Christman
> CEO
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York
>
>


-- 
George Christman
CEO
www.CarDaddy.com
P.O. Box 735
Johnstown, New York

Reply via email to