Then use the Insert component:
<span jwcid="[EMAIL PROTECTED]" source="ognl:{0,1,2,3,4,5,6,7,8,9,10}">
<a jwcid="@DirectLink" parameters="ognl:components.for.value"
listener="listener:onClick">link#<span jwcid="@Insert"
value="ognl:component.for.value" /></a>
</span>
I refactored my example to make it more readable.
Let's suppose that your query returns a list of class
class Entity
{
public int getId();
public String getLabel();
}
page file:
<property name="current" />
<component id="for" type="For">
<binding name="source" value="queryResult" />
<binding name="value" value="current" />
</component>
<component id="link" type="DirectLink">
<binding name="parameters" value="current.id" />
<binding name="listener" value="listener:onClick" />
</component>
<component id="linkLabel" type="Insert">
<binding name="value" value="current.label" />
</component>
html file:
<span jwcid="for"><a jwcid="link"><span jwcid="linkLabel" /></a></span>
java file:
public Entity[] getQueryResult()
{
....
}
public void onClick(int id)
{
System.out.println("link#" + id + " is clicked!");
}
Of course this is only handwritten code without real testing :)
Regards,
Norbi
----- Original Message -----
From: "tapestry" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, February 01, 2006 10:57 AM
Subject: Re: [NEWB]How to get the current link
I do it in the .java- file because I get my imformation from the database.
The linktext is for each link diffrent. In your example I get always the
same text.
Norbert Sándor wrote:
Why can't you use For and DirectLink? I mean something like:
in .html file:
<span jwcid="[EMAIL PROTECTED]" source="ognl:{0,1,2,3,4,5,6,7,8,9,10}">
<a jwcid="@DirectLink" parameters="ognl:components.for.value"
listener="listener:onClick">click me</a>
</span>
in .java file:
public void onClick(int value)
{
System.out.println("link#" + value + " is clicked!");
}
(Of course this can be written nicer, I just wanted to give a short
example...)
BR,
Norbi
----- Original Message ----- From: "tapestry" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, January 30, 2006 12:09 PM
Subject: [NEWB]How to get the current link
I generaty some Links dynamicly like this:
protected void renderComponent ( IMarkupWriter writer ,IRequestCycle
cycle) {
int n = 10;
for( int i = 1; i <= n ; i++ ){
writer.begin("component");
writer.attribute("name","showSiteLink");
writer.begin("a");
writer.attribute("href","link"+i);
writer.end();
writer.end();
}
}
So How can I get the current link I clicked, at runtime? I need it,
because I want to do diffrent thinks for.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: 2006.
01. 31.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: 2006. 01.
31.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]