Hi,
I had the same problem and then I've tried changing the code using your
solution.
But the solution won't work for the last row of the list.
So when I change the value of the enabled (checkbox) in last row, the record
won't change?
This problem didn't happen for other previous rows.
why could it be?
thanks,
shelly
When form submission occurs Tapestry5 do not look at binding that was
used during render phase. Instead it use ValueEncoder to restore object
from String id. If you do not provide an ValueEncoder (I think you
don't, do you?) tapestry will use default. Default ValueEncoder use java
serialization mechanism for conversion from and to object. So when your
form is submitted _new_ objects are deserialized from serialization
data. Those object are not the same objects as in actorList (equals will
return true, but == will return false).
To solve the problem you need to provide your own ValueEncoder.
Something similar to follow.
<tr t:type="Loop" source="displayActorList" value="actor"
encoder="encoder">
<td><t:checkbox t:value="actor.enabled"/></td>
<td>${actor.name}</td>
</tr>
public ValueEncoder getEncoder() {
return new ValueEncoder() {
public String toClient(Object value) {
// TODO: indexOf is not very effective operation
return String.valueOf(getDisplayActorList().indexOf(value));
}
public Object toValue(String clientValue) {
return getDisplayActorList().get(Integer.parseInt(clientValue));
}
};
}
With code above you do not ever need to persist actorList, because it is
restored from getStoredActorList every request.
Tim Sawyer пишет:
> Hi Folks,
>
> I have a list of checkboxes on a page:
--
View this message in context:
http://www.nabble.com/T5-Checkbox-Problem-tp16470624p16698258.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]