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


Andy Pahne-7 wrote:
> 
> 
>   public class VehicleValueEncoder implements ValueEncoder<Vehicle>{
> 
>         private static final String SEP = "|";
> 
>         @Override
>         public String toClient(Vehicle value) {
>             StringBuffer result = new StringBuffer();
>             result.append("vehicle");
>             result.append(SEP);
>             result.append(value.getType().name());
>             result.append(SEP);
>             result.append(value.getModel());
>             result.append(SEP);
>             result.append(value.getLicenseNumber());
>             result.append(SEP);
>             result.append(value.getLengthCentimeter());
>             result.append(SEP);
>             result.append(value.getHeightCentimeter());
>             result.append(SEP);
>             return result.toString();
>         }
> 
>        
>         @Override
>         public Vehicle toValue(String clientValue) {
>            
>             String[] splitted = clientValue.split("\\" + SEP);  // use a 
> regex
>            
>             Vehicle vehicle = new Vehicle();
>             vehicle.setType(VehicleType.valueOf(splitted[1]));
>             vehicle.setModel(splitted[2]);
>             vehicle.setLicenseNumber(splitted[3]);
>             vehicle.setLengthCentimeter(Integer.valueOf(splitted[4]));
>             vehicle.setHeightCentimeter(Integer.valueOf(splitted[5]));
>            
>             return vehicle;
>            
>         }
>        
>     }
> 

-- 
View this message in context: 
http://www.nabble.com/AjaxFormLoop%3A-property-changes-have-no-effect-tp24754470p24812971.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to