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}">
<h:outputText styleClass="outputText" value="LenderGroup Name"
id="text1"></h:outputText>
</h:commandLink>
</f:facet>
<h:commandLink styleClass="commandLink" id="link1"
actionListener="#{pc_LenderGroups.selectLenderGroup}">
<h:outputText id="text2" styleClass="outputText"
value="#{lenderGroup.name}"></h:outputText>
</h:commandLink>
</h:column>
</h:dataTable>
[ October 06, 2006: Message edited by: Mike Dingham ]