You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kaspar Fischer <fi...@inf.ethz.ch> on 2008/01/17 17:21:53 UTC
Re: Programmatically generating DirectLinks with updateComponents
For others running into a similar problem. I've solved it as follows.
My markup contains:
<div jwcid="block@Block">
<a jwcid="link@DirectLink" listener="listener:showResult"
updateComponents="result" async="true" parameters="ognl:
{page.parameter}"><span jwcid="@Insert" value="ognl:page.linkText"/></a>
</div>
At the place where I need to programmatically generate the link, I
call my page's setLinkText() method (which I added as an abstract
method) and similarly, setParameter(). Then I do
Block block = (Block)this.getContainer().getComponent("block");
block.renderForComponent(writer, cycle, this);
That worked for me.
On 24.12.2007, at 10:39, Kaspar Fischer wrote:
>
> On 22.12.2007, at 23:30, Andreas Andreou wrote:
>
>> Hi,
>> what's the html template for
>> ResultElement ?
>> Can't you add the link there?
>
> ResultElement does not have a HTML but is an AbstractComponent
> rendering
> its content using the renderComponent(). The name "ResultElement"
> is a little
> missleading; in reality, ResultElement's renderComponent() method
> renders
> a tree-like structure and needs to emit lots of DirectLinks with
> update-
> Components:
>
>>> ... and from the code (ResultElement's renderComponent()) I try to
>>> render the link as follows:
>>>
>>> DirectLink link = (DirectLink)this.getContainer().getComponent
>>> ("link");
>>> String url = link.getLink(cycle).getURL();
>>> writer.begin("a");
>>> writer.appendAttribute("href", url);
>>> writer.print(title);
>>> writer.end();
>
> In the meantime I've taken a look at DefaultLinkRenderer.java and
> see how
> they output the onClick element. But this does not seem to anwser my
> original question:
>
> How can I programatically generate a DirectLink? Is the above way of
> doing it (using getComponent("link"), referring to an existing
> DirectLink
> component, that is) the "right" way? If so, how would I add a body to
> the component?
>
> I'd prefer to generate the link like this:
>
> DirectLink mylink = new DirectLink(...);
> // how to add the body of the link?
>
> How can I do this?
>
> Kaspar
>
> ---------------------------------------------------------------------
> 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