You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by tapestry <ta...@gmx.de> on 2006/01/30 12:09:51 UTC
[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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: [NEWB]How to get the current link
Posted by ET <ta...@gmx.de>.
Can you tell me where I can find a tutorial on iteration in Tapestry?
Ernst
Inge Solvoll wrote:
> You can use the For component to iterate through a set of objects that
> contain parameters, link text or other things that you need. Read a tutorial
> on iteration in Tapestry, and you can achieve what you want here very
> smoothly! The java-file and the html-file cooperate in a nice way.
>
> Inge
>
> On 2/1/06, tapestry <ta...@gmx.de> wrote:
>
>>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="for@For" 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" <ta...@gmx.de>
>>>To: <ta...@jakarta.apache.org>
>>>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: tapestry-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>--
>>>>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: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: [NEWB]How to get the current link
Posted by Inge Solvoll <in...@gmail.com>.
You can use the For component to iterate through a set of objects that
contain parameters, link text or other things that you need. Read a tutorial
on iteration in Tapestry, and you can achieve what you want here very
smoothly! The java-file and the html-file cooperate in a nice way.
Inge
On 2/1/06, tapestry <ta...@gmx.de> wrote:
>
> 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="for@For" 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" <ta...@gmx.de>
> > To: <ta...@jakarta.apache.org>
> > 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: tapestry-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >>
> >> --
> >> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
Re: [NEWB]How to get the current link
Posted by Norbert Sándor <de...@erinors.com>.
Then use the Insert component:
<span jwcid="for@For" 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" <ta...@gmx.de>
To: <ta...@jakarta.apache.org>
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="for@For" 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" <ta...@gmx.de>
>> To: <ta...@jakarta.apache.org>
>> 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: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>> --
>>> 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: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
>
> --
> 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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: [NEWB]How to get the current link
Posted by tapestry <ta...@gmx.de>.
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="for@For" 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" <ta...@gmx.de>
> To: <ta...@jakarta.apache.org>
> 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: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>> --
>> 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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: [NEWB]How to get the current link
Posted by Norbert Sándor <de...@erinors.com>.
Why can't you use For and DirectLink? I mean something like:
in .html file:
<span jwcid="for@For" 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" <ta...@gmx.de>
To: <ta...@jakarta.apache.org>
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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
>
> --
> 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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org