I am trying to edit the properties of objects contained in a list by
using a loop in a form component. But it does not work, because the
objects in the list are not updated.
The list of passengers:
@Property @Persist
private List<Passenger> passengers;
This list is initialized like this:
@BeforeRenderTemplate
public void initialize() {
int passengersTotal = getQuery().getPassengersTotal();
if(passengers == null) {
passengers = new ArrayList<Passenger>(passengersTotal);
for (int i = 0; i < passengersTotal; i++) {
passengers.add(new Passenger());
}
}
}
I try to buid a form in order to edit the passengers like this:
<form t:type="Form"
t:id="search_accommodation"
t:clientValidation="false"
t:autofocus="false">
<t:loop source="passengers" value="passenger">
<fieldset class="column first">
<legend>${message:firstName-label}</legend>
<input type="text"
t:type="TextField"
t:value="passenger.firstName"
t:validate="required,minLength=2"
t:id="firstName"/>
</fieldset>
</t:loop>
</form>
Unfortunatly, after a successful submit, the firstName property is not
set for any of the passengers contained in that list. I veryify that by
the following logging statements:
public void onSuccess() {
int passengersTotal = getSearchOptions().getPassengersTotal();
for (int i = 0; i < passengersTotal; i++) {
System.out.println("Passenger '"+i+"'" + ": " +
passengers.get(i).getFirstName());
}
}
which always produces the output:
Passenger '0': null
Passenger '1': null
I thought that this would be the way to go, but I must be wrong somehow.
Could anybody tell me what's the correct pattern to use here?
Thank you,
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]