You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dariusz Majewski <da...@gmail.com> on 2010/01/07 01:00:45 UTC
tapestry 5 - How to call peekUniqueId?
Hi All,
In tapestry4, IRequestCycle has a peekUniqueId method
(link<http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/IRequestCycle.html#peekUniqueId%28java.lang.String%29>).
How to achieve that in tapestry5 ?
Thanks,
Dariusz
Re: tapestry 5 - How to call peekUniqueId?
Posted by Dariusz Majewski <da...@gmail.com>.
What I was trying to achieve is to have element to trigger formInjector
above forminjector component. Finally I was able to do so by using logic
similar to Label component.
I wrote a new component:
public class FormInjectorTrigger {
@Parameter(required=true)
private ClientElement target;
@Environmental
private Heartbeat heartbeat;
private Element element;
void beginRender(final MarkupWriter writer){
element = writer.element("a");
writer.attributes("href","#");
heartbeat.defer(new Runnable() {
@Override
public void run() {
element.forceAttributes("onclick",
"$('"+target.getClientId()+"').trigger();");
}
});
}
void afterRender(MarkupWriter writer)
{
writer.end(); // a
}
}
and use example is:
<t:form t:id="testForm">
<a t:type="FormInjectorTrigger" t:id="injectorTrigger"
target="component:forminjector">Click me...</a>
<div t:type="forminjector" t:id="formInjector" position="below"/>
<t:block t:id="textBlock">
<t:textfield value="stringValue"/><br/>
</t:block>
</t:form>
inside java:
@Inject
private Block textBlock;
public Object onActionFromFormInjector() {
return textBlock;
}
I would really like someone to comment on this. Is there an easier approach?
I have to admit I don't understand how heartbeat works. When I used
writer.attributes("onclick", "$('"+target.getClientId()+"').trigger();")
instead of element.forceAttributes these attributes where added to a form
tag.
Cheers,
Dariusz
On Thu, Jan 7, 2010 at 12:22 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> Generally, you should wait until after a component has rendered, then
> invoke getClientId() on it.
>
> On Wed, Jan 6, 2010 at 4:00 PM, Dariusz Majewski
> <da...@gmail.com> wrote:
> > Hi All,
> >
> > In tapestry4, IRequestCycle has a peekUniqueId method
> > (link<
> http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/IRequestCycle.html#peekUniqueId%28java.lang.String%29
> >).
> > How to achieve that in tapestry5 ?
> >
> > Thanks,
> > Dariusz
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: tapestry 5 - How to call peekUniqueId?
Posted by Howard Lewis Ship <hl...@gmail.com>.
Generally, you should wait until after a component has rendered, then
invoke getClientId() on it.
On Wed, Jan 6, 2010 at 4:00 PM, Dariusz Majewski
<da...@gmail.com> wrote:
> Hi All,
>
> In tapestry4, IRequestCycle has a peekUniqueId method
> (link<http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/IRequestCycle.html#peekUniqueId%28java.lang.String%29>).
> How to achieve that in tapestry5 ?
>
> Thanks,
> Dariusz
>
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org