I've become stuck on this one:
<rich:dataTable id="tabA" value="#{m.a}" rowKeyVar="nr" var="ex">
<rich:column><h:outputText value="Exercise #{nr + 1}:" /></rich:column>
<rich:column><h:inputText value="#{ex}" /></rich:column>
</rich:dataTable>
<h:panelGrid columns="2">
<a4j:commandButton value="+" title="new" ajaxSingle="true"
action="#{m.createNewExercise}" reRender="tabA"/>
<a4j:commandButton value="-" title="remove last" ajaxSingle="true"
action="#{m.deleteExercise}" reRender="tabA"/>
</h:panelGrid>
Because this is part of a bigger form, I have set ajaxSingle="true"
.
The value I'm iterating over is a List of Strings, defined like this:
@Entity
public class M {
...
private List<String> a = Lists.newArrayList();
@CollectionOfElements
public List<String> getA() { return a; }
public void setA(List<String> a) { this.a = a; }
}
This fails to update the backing list a
when submitted (submit is done via a simple <h:commandButton>
). Since the content from the inputText
elements is submitted, JSF seems failing to apply the values. Maybe someone can shed light on whether this is because of the @CollectionOfElements
storage type in M
.
So what I'm looking for is a way to save the ex
values when calling createNewExercise
or deleteExercise
, either by not having to reRender the complete table or by sending them to the server first.
I can probably make it work via a binding like suggested here, but I'm interested in a way to avoid the overhead of a binding.