Hi
I'm using ADF 11g table, but use ArrayList instead of ViewObject. For each row, I have an outputText, an inputText and a delete button, which will remove the current row if clicked. If the delete button has immediate="true" attribute, then after clicking it, somehow it looks like it delete the next row (actually the current row get deleted, but the inputText value of the current row get populated in the inputText of the next row, non-editable component like outputText shows correctly).
For example, I have 2 rows:
Row 1: outputText value = "Row 1", inputText value = 1
Row 2: outputText value = "Row 2", inputText value = 2
After clicking delete on row 1, it shows one row with:
outputText value = "Row 2", inputText value = 1
when it supposes to show:
outputText value = "Row 2", inputText value = 2
Every thing works fine if i don't use immediate attribute OR use ViewObject instead. I also debug, and the model seems to be correct after delete the row. I try to use oracle.adf.view.faces.model.CollectionModel, but no help.
I think because the Update Model Phase is skipped, so UIComponent and model are not synchronized and the value in model is not reflected in editable UI component.
Is there anyway to workaround? Thanks in advance.
Here is my JSFF
<af:table id="table" binding="#{backingBeanScope.uiBean.table}"
var="row" contentDelivery="immediate"
value="#{pageFlowScope.handler.collectionModel}"
selectionListener="#{backingBeanScope.uiBean.makeCurrent}"
rowSelection="single">
<af:column width="250" headerText="Name" id="c1"
rowHeader="unstyled">
<af:outputText id="ot1" value="#{row.label}"/>
<af:commandButton id="cb1" text="Delete" immediate="true"
actionListener="#{backingBeanScope.uiBean.delete}"/>
</af:column>
<af:column rowHeader="unstyled" id="c11" width="180" headerText="Value">
<af:inputText id="it1" simple="true"
label="#{row.label}"
value="#{row.value}">
</af:inputText>
</af:column>
</af:table>
Backing Bean for handling event
public void delete(ActionEvent event) {
handler.delete();
if (getTable() != null)
AdfFacesContext.getCurrentInstance().addPartialTarget(getTable());
FacesContext.getCurrentInstance().renderResponse();
}
public void makeCurrent(SelectionEvent event) {
RowKeySet addedSet = event.getAddedSet();
if (addedSet.isEmpty())
return;
int i = (Integer)addedSet.toArray()[0];
handler.setCurRow(i);
}
Page Flow Bean for storing data
private ArrayList<Row> collectionModel = new ArrayList<>();
public HandlerBean() {
for (int i = 0; i < 2; i++)
collectionModel.add(new Row());
}
public void delete() {
collectionModel.remove(curRow);
}
public void setCurRow(int curRow) {
this.curRow = curRow;
}
Row data structure
public class Row {
private static int counter = 0;
private String label;
private BigDecimal value;
public Row() {
counter++;
label = "Row " + counter;
value = BigDecimal.valueOf(counter);
}
/** getters and setters */
}