aspose file tools*
The moose likes JSF and the fly likes Identifying Selected Row in Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Identifying Selected Row in Table" Watch "Identifying Selected Row in Table" New topic
Author

Identifying Selected Row in Table

Trey Brown
Greenhorn

Joined: Apr 08, 2004
Posts: 5
I am fairly new to JSF, and I am struggling with identifying which table row I have selected out of the Woodstock Basic Table component in NetBeans 6.1.

I have an EJB that returns a list that I successfully display in my table component. Each row has a Hyperlink component (or in some cases a Button component). When I click the Hyperlink or Button, I need to identify which row this was from in order to correctly display the related data on the next page.

I would think this would be a fairly standard requirement, but I am having problems. Any help would be appreciated.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Bind the table component with an UIData property in the backing bean and use UIData#getRowData() in the action method.
Trey Brown
Greenhorn

Joined: Apr 08, 2004
Posts: 5
I gave this a try and am still having difficulty. When I bind to the UIData property, I end up with a blank screen instead of data. I should note that I am using the Visual JSF Table Component, so maybe this is making a difference?

Here is a snippet from the JSF:

<webuijsf:table augmentTitle="false" binding="#{NameList.uiNames}" id="tblNames" title="Table" width="672">

<webuijsf:tableRowGroup id="tableRowGroup1" rows="10" sourceData="#{NameList.nameListEJB}" sourceVar="currentRow">

The associated java:

private UIData uiNames = new UIData();
public UIData getUiNames()
{
return uiNames ;
}

public void setUiNames(UIData uiNames )
{
this.uiNames = uiNames ;
}
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Don't create the component yourself. Otherwise that instance would be used rather than the one already declared in the JSF page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Identifying Selected Row in Table
 
Similar Threads
Highlighting a row in a table
RADIO BUTTON WITH ROW IN DATA TABLE
selecting a row from table using radio buttons
Find "who triggered" from actionListener
getting data from a dynamic table in one JSP to another JSP