Option A:
<h:table>
<h:column>
<h:commandLink id="link1"
action="actionA" actionListener="processClick" />
</h:column>
<h:column>
<h:commandLink id="link2" action="actionB"
actionListener="processClick">
</h:column>
</h:table>
public void processClick(ActionEvent event)
{
System.out.println(event.getComponent().getId()); // link1 or link2
}
Option B:
<h:table>
<h:column>
<h:commandLink action="actionA" actionListener="processClick">
<f:attribute name="actionId" value="A" />
</h:commandLink>
</h:column>
<h:column>
<h:commandLink action="actionB" actionListener="processClick">
<f:attribute name="actionId" value="B" />
</h:commandLink>
</h:column>
</h:table>
public void processClick(ActionEvent event)
{
System.out.println(event.getComponent()
.getAttributes().get("actionId")); // A or B
}
On Fri, Dec 19, 2008 at 12:10 PM, Anton Gavazuk <[email protected]> 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 <[email protected]>:
>> 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)
>>
>>
>