how to access client id of the component rendered later than the current one

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

how to access client id of the component rendered later than the current one

Ilya Obshadko-2
Is there any convenient way to do that?

--
Ilya Obshadko
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Lance Java
Take a look at the Label component which uses @HeartbeatDeferred
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Ilya Obshadko-2
Ah, thanks! That's what I was looking for, just forgot the name of
annotation.

On Tue, May 19, 2015 at 10:39 AM, Lance Java <[hidden email]>
wrote:

> Take a look at the Label component which uses @HeartbeatDeferred
>



--
Ilya Obshadko
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Ilya Obshadko-2
Interesting - I'm still receiving the same exception:

java.lang.IllegalStateException: Unable to provide client id for component
MyPage:component.name as it has not yet rendered.
at org.apache.tapestry5.corelib.components.Any.getClientId(Any.java:135)
at
com.xdance.components.ScoreField.advised$deferredInit_13b51aa37fc1c38c(ScoreField.java:164)
at
com.xdance.components.ScoreField$Invocation_deferredInit_13b51aa37fc1c38b.proceedToAdvisedMethod(Unknown
Source)
at
org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:84)
at
org.apache.tapestry5.internal.transform.HeartbeatDeferredWorker$1$1.run(HeartbeatDeferredWorker.java:39)
at
org.apache.tapestry5.internal.services.HeartbeatImpl.end(HeartbeatImpl.java:49)
at org.apache.tapestry5.corelib.components.Loop.endHeartbeat(Loop.java:442)
at org.apache.tapestry5.corelib.components.Loop.after(Loop.java:430)
at org.apache.tapestry5.corelib.components.Loop.afterRender(Loop.java)

Although HeartbeatDeferred is involved, it doesn't quite help.



On Tue, May 19, 2015 at 12:36 PM, Ilya Obshadko <[hidden email]>
wrote:

> Ah, thanks! That's what I was looking for, just forgot the name of
> annotation.
>
> On Tue, May 19, 2015 at 10:39 AM, Lance Java <[hidden email]>
> wrote:
>
>> Take a look at the Label component which uses @HeartbeatDeferred
>>
>
>
>
> --
> Ilya Obshadko
>
>


--
Ilya Obshadko
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Lance Java
Can you include your template? Perhaps the two components are not within
the same heartbeat.

Depending on your use case, you might need a container component to invoke
a method on a child at some later stage. Take a look at parallel /
parallelContainer for inspiration

http://t5stitch-lazan.rhcloud.com/paralleldemo
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Lance Java
Possibly a much simpler option is to explicitly provide a clientId

<t:any t:id="serverId" id="clientId"... />
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Ilya Obshadko-2
In reply to this post by Lance Java
Thanks, that's helpful.

I think that 'two components not in the same heartbeat' is really the
reason, however I don't quite understand how to make them work in the same
heartbeat and if that's even possible.

Both components are rendered inside a zone, and the second one is a
Bootstrap Affix, which should be updated as user navigates the form (which
contains a lot of input fields).


On Wed, May 20, 2015 at 10:43 AM, Lance Java <[hidden email]>
wrote:

> Can you include your template? Perhaps the two components are not within
> the same heartbeat.
>
> Depending on your use case, you might need a container component to invoke
> a method on a child at some later stage. Take a look at parallel /
> parallelContainer for inspiration
>
> http://t5stitch-lazan.rhcloud.com/paralleldemo
>



--
Ilya Obshadko
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Lance Java
Can you generate the clientId yourself and pass as a parameter into both
components?

Why do you need to know the clientId? If it's for a javascript selector can
you use a data- attribute instead?
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Ilya Obshadko-2
Yes, I've finally resorted to data attributes. I wanted Tapestry-generated
client ids for consistency, but it works either way.

On Wed, May 20, 2015 at 7:38 PM, Lance Java <[hidden email]>
wrote:

> Can you generate the clientId yourself and pass as a parameter into both
> components?
>
> Why do you need to know the clientId? If it's for a javascript selector can
> you use a data- attribute instead?
>



--
Ilya Obshadko
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Lance Java
If you're solving it by explicitly setting a data attribute, why can't you
just explicitly set the id?
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Ilya Obshadko-2
Inside a zone this id gets overridden by an automatically generated one.

On Thu, May 21, 2015 at 7:45 PM, Lance Java <[hidden email]>
wrote:

> If you're solving it by explicitly setting a data attribute, why can't you
> just explicitly set the id?
>



--
Ilya Obshadko
Reply | Threaded
Open this post in threaded view
|

Re: how to access client id of the component rendered later than the current one

Lance Java
Which component are we talking about here? Are you sure you're setting id
(not to be confused with t:id, the serverside component id).