You are right, that was a misunderstanding on my side.
Now I got it. Thanks. For the curious, here is the working code:
public ValueEncoder getVehicleEncoder(){
return new ValueEncoder() {
@Override public String toClient(Object value) {
return String.valueOf(vehicles.indexOf(value));
}
@Override public Object toValue(String clientValue) {
return vehicles.get(new Integer(clientValue));
}
};
}
Still I had to take a little care that my Vehicle' equal() method
returns some meaningfull value....
Thank you for your feedback.
Andy
Daniel Jones schrieb:
Hi Andy,
I think you are a bit confused regarding the ValueEncoder.
Your toClient method should provide a unique string identifier which can be
used to
retrieve that particular vehicle from your list.
Your toValue method should accept the unique string identifier provided by
the toClient method and use this to retrieve the SAME object from your list.
Currently, in your toValue method, you are just creating a new Vehicle
object, which is not the same object that is contained in your list (which
your loop is reading from). What you want to do in this method is search
your vehicles list for the correct object.
I hope this helps.
Regards,
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org