Ah. So in that case, Andrew understood your question correctly and I did
not. You really *did* mean "which link in table row"...

Yes, you *can* add an id to each of the commandLink components; there is
only one instance of each column no matter how many rows there are in
the table (table components uses the "flyweight" pattern). Note that the
"clientId" is different for each row, as the table automatically ensures
that components have clientId values of
  tableId:rownum:componentId

So just go ahead and add the ids, then as you (and Andrew) point out,
the ActionEvent passed to the processClick method will return the
component whose id (not clientId) you can then check.

By the way, I normally ignore emails that have mixed posting style (see
my original sig). But as it's Christmas...

Regards,
Simon

On Fri, 2008-12-19 at 21:10 +0200, Anton Gavazuk wrote:
> Hi Simon, Andrew
> 
> thanks for the answers,
> 
> sure, my question is confusing - I meant how to do something like:
> 
> <h:table>
> <!-- its link1 -->
>    <h:column>
>   <h:commandLink action="actionA" actionListener="processClick">
>    </h:column>
> 
> <!-- its link2 -->
>    <h:column>
>   <h:commandLink action="actionB" actionListener="processClick">
>    </h:column>
> </h:table>
> 
> So my question was how to define in processClick that user clicks on
> link1 or on click 2?
> 
> you cannot put certain Id in link component - its table, so id must be
> unique and its  generated by component,
> and actionEvent.getComponent() returns something like "id_lnk_141413"
> - sure, not very meaningful :)
> 
> So for now I have gone with separate methods for every actionListener.
> 
> Cheers,
> Anton
> 
> 
> 
> 2008/12/19 Simon Kitching <skitch...@apache.org>:
> > Anton Gavazuk schrieb:
> >> Hi all,
> >>
> >> I"m making the master-detail scenario via ActionListeners and want to
> >> use the same ActionListener
> >>
> >> is there any "easy" way to know which link in table row performs the 
> >> action?
> >>
> > This should be covered by most JSF textbooks.
> >
> > There is also a page on the myfaces wiki. This page:
> >   http://wiki.apache.org/myfaces/
> > has a link to here:
> >  http://wiki.apache.org/myfaces/ExecutingMethodsFromLinkButtonParameters
> > which hopefully answers your question.
> >
> > Regards,
> > Simon
> >
> > --
> > -- Emails in "mixed" posting style will be ignored
> > -- (http://en.wikipedia.org/wiki/Posting_style)
> >
> >

Reply via email to