wood burning stoves 2.0*
The moose likes JSF and the fly likes Can not Invoke actionLister - DataTable of Links Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Can not Invoke actionLister - DataTable of Links" Watch "Can not Invoke actionLister - DataTable of Links" New topic
Author

Can not Invoke actionLister - DataTable of Links

Mike Dingham
Greenhorn

Joined: Oct 06, 2006
Posts: 8
I have a JSP page with <h:dataTable> with value as an "array of objects".
Each row of this table is defined with commandLink with defined action/actionListener method in the managed bean.

The problem is sometimes this this action is invoked and some times it
is not. Depending on how I instantiate my "array of objects" in the managedbean.

I am populating this array of objects in constructor of managed bean
by calling a service layer method. In this case JSF does not trigger
action when I click on the link. But if I create using
new Object() and add to the array (With out calling service method
some hardcoded values) it does invoke the actionListener and it behaves
exactly how I expect it should work.

I have no clue why it does not invoke in the first case?

I am using RAD6.0, IBM JSF implementation.

Code:

MagedBean:

public class LenderGroupsBean extends PageCodeBase
{

//Form data
private ILenderGroupService lenderGroupService;

private LenderGroup[] lenderGroups;

private LenderGroup selectedLenderGroup;

//Binding UIComponent Instances
private HtmlDataTable lenderGroupTable;

//Constructors
/**
* Constructor()
*/
public LenderGroupsBean()
{
lenderGroupService = (ILenderGroupService) beanFactory
.getBean("lenderGroupService");

lenderGroups = lenderGroupService.getLenderGroups();

// lenderGroups = new LenderGroup[3];
// LenderGroup lg = new LenderGroup();
// lg.setName("bb");
// lenderGroups[0] = lg;
// lg = new LenderGroup();
// lg.setName("aa");
// lenderGroups[1] = lg;
// lg = new LenderGroup();
// lg.setName("cc");
// lenderGroups[2] = lg;
}

//Actions

/**
*
* @param event
*/
public void selectLenderGroup(ActionEvent event)
{
LenderGroup selectedlg = (LenderGroup) lenderGroupTable.getRowData();
}





JSP Code:

<h:dataTable id="lgDataTable" width="750"
value="#{pc_LenderGroups.lenderGroups}" var="lenderGroup"
binding="#{pc_LenderGroups.lenderGroupTable}" border="1">
<h:column id="lgName">
<f:facet name="header">
<h:commandLink id="name" actionListener="#{pc_LenderGroups.sort}">
<hutputText styleClass="outputText" value="LenderGroup Name"
id="text1"></hutputText>
</h:commandLink>
</f:facet>
<h:commandLink styleClass="commandLink" id="link1"
actionListener="#{pc_LenderGroups.selectLenderGroup}">
<hutputText id="text2" styleClass="outputText"
value="#{lenderGroup.name}"></hutputText>
</h:commandLink>
</h:column>
</h:dataTable>
[ October 06, 2006: Message edited by: Mike Dingham ]
 
GeeCON Prague 2014
 
subject: Can not Invoke actionLister - DataTable of Links