ajax submit quesiton
Greetings, I am using ajax4jsf,jsf, I have a Collection of value objects as property of a JSF backing bean.
I would like to use the elements in this collection to pre-populate input fields in the jsf page, also, each input
field needs to be AJAX anabled to submit with onchange event.
Question is, on AJAX submit, how do we find out which element in the collection was changed?
(i guess we could have the original copy and compare the list, but what are the other alternatives?)
Regards,
[529 byte] By [
gnavala] at [2007-11-27 9:17:19]

# 1
Greetings,
For example,
<h:inputText id="myField" size="1" maxlength="3" value="#{myBean.MyList[index].myItem}" >
<a4j:support event="onchange" />
</h:inputText>
this input field needs to change only the myItem based on the index, but all the myItem in the list gets updated. Is there a way to avoid this?
Regards,
# 3
Thanks sergey, this approach is partially working, (still not getting the events as expected for some of the indexes)..
JSF
======
..
<td>
<a4j:region id="region_0_#{index}">
<h:inputText id="_#{index}" valueChangeListener="#{myBean.processEvent}" size="1" maxlength="3"
immediate="true" value="#{myBean.myList[index].myItem}" >
<a4j:support event="onchange" />
</h:inputText>
</a4j:region>
</td>
..
Backing Bean
==========
public void processEvent(ValueChangeEvent event) {
if (event.getPhaseId().equals(PhaseId.ANY_PHASE)) {
event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
event.queue();
}
else if (event.getPhaseId().equals(PhaseId.UPDATE_MODEL_VALUES)) {
int index = new Integer(event.getComponent().getId().substring(1)).intValue();....
}
}