multiple ValueChangeListeners in a DataTable
Hi all,
I have 3 valueChangeListeners in a datatable on the JSP.
the first textbox will populate the entire row based on the textfield value.
The second and third valuechangelisteners update the costs of all the rows.
here is the jsp:
<h:dataTable border="0" cellpadding="2" cellspacing="2"
columnClasses="columnClass1" headerClass="headerClass"
footerClass="footerClass" rowClasses="rowClass1"
styleClass="dataTable" id="pms" width="200"
value="#{pmBO.model}"
binding="#{pmBO.modelTable}" var="item" rows="10">
<h:column>
<h:inputText styleClass="inputText" id="empNo"value="#{item.empNo}" size="10" valueChangeListener="#{pmBO.processValueChange}" immediate="true" onblur="submit();">
</h:inputText>
</h:column>
<h:column>
<h:inputText styleClass="inputText" id="dAmount value="#{item.dAmount}" valueChangeListener="#{pmBO.processAmountValueChange}" onblur="submit();" size="10" >
</h:inputText>
</h:column>
<h:column>
<h:inputText styleClass="inputText" id="pAmount" value="#{item.pAmount}" size="10" valueChangeListener="#{pmBO.processAmountValueChange}" onblur="submit();">
</h:inputText>
</h:column>
<h:column>
<h:selectOneMenu styleClass="selectOneMenu" id="PInd" value="#{item.pInd}">
<f:selectItems value="#{pmBO.pInds}"/>
</h:selectOneMenu>
</h:column>
<h:column id="column1">
<h:inputText styleClass="inputText" id="fAmt"value="#{item.fAmount}"size="10">
</h:inputText>
</h:column>
</h:dataTable>
After i populate the first row, i select pInd and fAmount...fields
and now, if i enter the empNo in the second row and populate it, the values i entered in pInd and fAmount for thefirst row are lost.
Are these not supposed to be in the modelTable that is bound to the Backing beant? Am i missing something here?
and here is the code in the valueChangeListener and the binded HtmlDataTable:
publicvoid processAmountValueChange(ValueChangeEvent ve){
double value = 0.0;
value = ((Double)ve.getNewValue()).doubleValue();
valueChangeSource = ((UIInput)ve.getSource()).getId();
setRowIndex(getModelTable().getRowIndex());
valueChange =true;
if (valueChangeSource.equalsIgnoreCase("dAmount"))
setDAmount(value);
elseif(valueChangeSource.equalsIgnoreCase("pAmount")){
setPAmount(value);
}
modify();//this is where the manipulation of the arraylist goes.
valueChange =false;
valueChangeSource ="";
}
/**
* @param modelTable The modelTable to set.
*/
publicvoid setModelTable(HtmlDataTable modelTable){
this.modelTable = modelTable;
pList =new ArrayList();
try{
for (int i=0; i < modelTable.getRows(); i++){
modelTable.setRowIndex(i);
Item item = (Item)modelTable.getRowData();
pList.add(i, item);
System.out.println("^^^^^^^^^^ in the for loop $$$$$$$$ = "+i+";"+item.getPType()+";"+item.getFAmount());
}
setPList(pList);
}catch(Exception e){
e.printStackTrace();
}
}
When i see the console for the changed values, the Modeltable doesn't show the values selected for the first row.
i know that value change listener doesn't update all the request values. But i want the values selected in the first row too.
The backing bean is in session scope.
is there a way to get around this?
Thank you

