Hi David, after some testing I wanted to provide you with some updates based on some scenarios I ran into.
You'll notice in the !request.isHXR condition, I'm checking for a null lineItem id. This prevents duplicate objects from being added to the collection. @SuppressWarnings("unchecked") public ValueEncoder getEncoderLineItem() { return new ValueEncoder<LineItem>() { public String toClient(LineItem value) { Long id = value.getId(); return id == null ? NEW_OBJ : id.toString(); } public LineItem toValue(String idAsString) { lineItem = null; if (!idAsString.equals(NEW_OBJ)) { Long id = new Long(idAsString); lineItem = (LineItem) session.get(LineItem.class, id); } // AjaxFormLoop can't handle null obj, so if null we return a new empty obj. lineItem = lineItem == null ? new LineItem() : lineItem; if (!request.isXHR() && lineItem.getId() == null) { lineItem.setPurchaseRequest(pr); pr.getLineItems().add(lineItem); } return lineItem; } }; } I also found a cleaner way to copy the persisted data to the new session. void onActivate() { System.out.println("onActivate " + this.pr); if (this.pr == null) { this.pr = prPersist != null ? prPersist : new PurchaseRequest(); prPersist = null; } } Class<?> onActivate(Long prId) { PurchaseRequest purchaseRequest = prPersist != null ? prPersist : (PurchaseRequest) session.get(PurchaseRequest.class, prId); } If you have any better solutions, please feel free to share. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5586509.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