This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Identifying Selected Row in Table  RSS feed

 
Trey Brown
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bind the table component with an UIData property in the backing bean and use UIData#getRowData() in the action method.
 
Trey Brown
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't create the component yourself. Otherwise that instance would be used rather than the one already declared in the JSF page.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!