I'm an idiot. I have since learned that getRowData is the correct method
to use, and sure enough there is a ".getRowData()" on that line, after
about 200 spaces, so I didn't see it.

 

Here's to using code formatters.

 

________________________________

From: Hannum, Daniel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 01, 2007 3:20 PM
To: MyFaces Discussion
Subject: Determining which row in a table was clicked

 

(This relates to Trinidad/ADF, but may be of interest to general users)

 

I have a table backed by a list. Each row in the table becomes a link
and all the links fire the same action method in my backing bean. I
would like a way to know which row in the list I clicked the link of

 

<af:table value="#{bean.list}" var="row" binding="#{bean.table}">

      <af:column>

            <f:facet name="header"><af:outputText
value="Type"/></f:facet>

            <af:commandLink text="#{row.text}"
action="#{bean.doSomething}"/>

      </af:column>

</af:table>

 

Now, I found some old code that will do it, but it blows my mind. It
looks like this (assume that Foo is the class)

 

In the Bean class

 

public class Bean {

 

private List<Foo> list;

 

public String doSomething()

{

Foo selectedItem = (Foo)table;

....

}

 

....

 

}

 

That's right. You simply cast the CoreTable to the type of the list
element and it magically gives you the one that was selected. Now I
watched it happen in the debugger, but I still don't believe my eyes.
Shouldn't that have caused a ClassCastException because CoreTable and my
Foo class are unrelated classes?

 

Am I crazy? Is that really the correct way to do this?

 

Thanks.

Dan

________________________________

***Note:The information contained in this message may be privileged and
confidential and protected from disclosure. If the reader of this
message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you
are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you have received this
communication in error, please notify the Sender immediately by replying
to the message and deleting it from your computer. Thank you. Premier
Inc. 




-----------------------------------------
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer. Thank you. Premier Inc.  

Reply via email to