You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Edward Scanzano <es...@yahoo.com> on 2005/05/25 21:58:41 UTC

Foreach and links

Hi all,

I have a situtation where I am looking over a
Collection and for each item I build a @DirectLink
which shows a property of the value
(currentVariable)variable in the loop.

Now, when I click on the link it fires a method which
references currentVariable and I am assuming that
currentVariable is set to object that was used by the
link I am clicking on.

To be clearer:

A collection of 10 Facility objects

loop:
      DirectLink1 (gets Facility object 1)
      DirectLink2 (gets Facility object 2)
      DirectLink3 (gets Facility object 3)
      DirectLink4 (gets Facility object 4)
      DirectLink5 (gets Facility object 5)
      DirectLink6 (gets Facility object 6)
      DirectLink7 (gets Facility object 7)
      DirectLink8 (gets Facility object 8)
      DirectLink9 (gets Facility object 9)
      DirectLink10 (gets Facility object 10)
end

Now when I click on direct link 5 and I reference
currentVariable will I see Facility object 5 in the
method that gets called?

I just tried this and I get Facility object 10. This
is not good.

Ideas?

Ed





---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Foreach and links

Posted by Robert Zeigler <ro...@scazdl.org>.
Edward Scanzano wrote:
> Hi all,
> 
> I have a situtation where I am looking over a
> Collection and for each item I build a @DirectLink
> which shows a property of the value
> (currentVariable)variable in the loop.
> 
> Now, when I click on the link it fires a method which
> references currentVariable and I am assuming that
> currentVariable is set to object that was used by the
> link I am clicking on.

you'll want to do something like:
html:
<a href="#" jwcid="@DirectLink" parameters="currentVariable"
listener="ognl:listeners.showObj">show object</a>

java:

public void showObj(IRequestCycle cycle) {
    Object[] params = cycle.getServiceParameters();
    MyObj obj = (MyObj) params[0];
}

Robert
> 
> To be clearer:
> 
> A collection of 10 Facility objects
> 
> loop:
>       DirectLink1 (gets Facility object 1)
>       DirectLink2 (gets Facility object 2)
>       DirectLink3 (gets Facility object 3)
>       DirectLink4 (gets Facility object 4)
>       DirectLink5 (gets Facility object 5)
>       DirectLink6 (gets Facility object 6)
>       DirectLink7 (gets Facility object 7)
>       DirectLink8 (gets Facility object 8)
>       DirectLink9 (gets Facility object 9)
>       DirectLink10 (gets Facility object 10)
> end
> 
> Now when I click on direct link 5 and I reference
> currentVariable will I see Facility object 5 in the
> method that gets called?
> 
> I just tried this and I get Facility object 10. This
> is not good.
> 
> Ideas?
> 
> Ed
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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