The problem is that you must give action link something
to identify your object.

in the page you mentioned you have only one instance of
the MatchInfo component that get's rendered multiple times with different
data.
So when your action is called, you have the last element passed as
parameter.

you shoud link it like this:

<t:actionlink t:id="changedMind" context="match.id">Changed Your
Mind</t:actionlink>

       public void onActionFromChangedMind(Long id)
       {
              //load match from database by the id
              System.out.println(match.getName());
       }

-----------------------------------------------------------------------------------------------------
if in you AppModule you make following TypeCoercers :
String->DateeeMatch
and
DateeeMatch -> String


above code can look like this:


<t:actionlink t:id="changedMind" context="match">Changed Your
Mind</t:actionlink>

       public void onActionFromChangedMind(DateeeMatch match)
       {
              //load match from database by the id
              System.out.println(match.getName());
       }



Davor Hrg




On 9/17/07, Charles Mason <[EMAIL PROTECTED]> wrote:
>
> On 9/17/07, Francois Armand <[EMAIL PROTECTED]> wrote:
> > Well, I'm not sure that I understand what you do correctly, may you
> > provide the actual code ?
> > As far as I can tell, you persists a field that is used as value for the
> > loop, and so it's always the last MacthInfo that is persists.
> >
> > You may want to have a look at
> > http://tapestry.apache.org/tapestry5/tapestry-core/guide/pagenav.html
> > and look how Tapestry deals with context and onActivate/onPassivate
> methods.
>
> Thanks for your reply however, I don't think was very clear about what
> I'm trying to do.
>
> I was trying to avoid posting code from lots of different files but. I
> think I can find the relevant snippets, which should make things
> clearer.
>
> So here goes:
>
> From Start.html:
>
>        <t:loop source="Matches" value="CurrentMatch">
>              <t:MatchInfo match="CurrentMatch" />
>        </t:loop>
>
> From Start.java:
>
>     @Persist
>     private List<DateeeMatch> matches;
>
>     @Persist
>     private DateeeMatch currentMatch;
>
> matches is filled from a long DB query.
>
> The action link in MatchInfo.html:
>
>     <td class="matchLink">
>         <t:actionlink t:id="changedMind">Changed Your Mind</t:actionlink>
>     </td>
>
> From MatchInfo.java
>
>         @Parameter(required=true)
>         private DateeeMatch match;
>
>
>         public void onActionFromChangedMind()
>         {
>                 System.out.println(match.getName());
>         }
>
>
> My problem is when you click the action link on any of the MatchInfo
> components on the start page. The console shows the name of the last
> match not the one clicked on. The MatchInfo component also correctly
> displays lots of info from the match parameter, so that is defiantly
> OK.
>
> Can anyone shed some light on this for me?
>
> Charlie M
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to