Hi George, I've recreated the problem, but I can't spend more time on it until next week. In the meantime, this may solve all or part of it:
- Add a zone around the form. - Add the zone parameter to the form. - Modify the OnValidateFromYourForm method to return an Object. - Change the final return in OnValidateFromYourForm to return null. - Change all the other returns in OnValidateFromYourForm to return the zone.getBody(). eg. <div style="margin: 20px;" t:type="zone" t:id="myZone" id="myZone"> <form t:type="form" t:id="personsedit" t:zone="myZone"> @InjectComponent private Zone wow; Object onValidateFromPersonsEdit() { : return wow.getBody(); : return null; } This will not be enough if the rows have a "remove" action, but otherwise might be OK. Sorry, I wish I could spend more time on it now. Regards, Geoff On 05/01/2012, at 6:27 AM, George Christman wrote: > Hello, I'm using the ajaxformloop component with a value encoder similar to > jumpstarts AjaxFormLoop Tailored version. The component works flawlessly > when there is no server side errors to return, however when server side > errors exist and the form is returned, my main pr object looses all the > ajaxformloop values that haven't yet been committed to the db. > > Is there way for the onValidate method to return my pr object without losing > the lineItem values and without persisting any of the data? > > Please see code below. > > <t:AjaxFormLoop t:id="lineItem" element="ul" > source="pr.lineItems" value="lineItem" addRow="block:addRow" show="show" > encoder="encoderLineItem"> > <t:Label > for="quanity">QTY</t:Label><t:TextField disabled="roleManager.disabled" > title="Quantity" t:id="quanity" class="number qty" > value="lineItem.quanity"/> > </t:AjaxFormLoop> > > > @OnEvent(EventConstants.ACTIVATE) > void setupRender() { > if (this.pr == null) { > this.pr = new PurchaseRequest(); > } > } > > void onValidateFromPR() throws Exception { > //errors to return > form.recordError(message + fieldName); > } > > @CommitAfter > Object onSuccess() { > session.saveOrUpdate(pr); > } > > @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 lineItem = null; > Long id = null; > > if (!idAsString.equals(NEW_OBJ)) { > id = new Long(idAsString); > } > > // If new obj, return an empty obj. > if (id == null) { > lineItem = new LineItem(); > > if (!request.isXHR()) { > pr.getLineItems().add(lineItem); > } > } // Else, return existing obj > else { > lineItem = (LineItem) session.get(LineItem.class, id); > } > > // AjaxFormLoop will overwrite several fields of the obj > returned. > // AjaxFormLoop can't handle null obj, so if null we return > a new empty obj. > lineItem = lineItem == null ? new LineItem() : lineItem; > lineItem.setPurchaseRequest(pr); > > return lineItem; > } > }; > } > > > Thanks. > > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5120576.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 >