You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Thiago H. de Paula Figueiredo" <th...@gmail.com> on 2011/12/10 13:37:42 UTC

Fwd: Issue with AjaxFormLoop


------- Forwarded message -------
From: susnata@gmail.com
To: thiagohp@gmail.com
Cc:
Subject: Issue with AjaxFormLoop
Date: Fri, 09 Dec 2011 21:39:07 -0200

I've been stuck on ajaxformloop construct now - the issue is with
AddNewRow event, it add's the new row and initialized them but during form
submit, the onSuccess() method doesn't pick up those values. It's simply
getting the values used during initialization (0's in my case). I suspect
the value encoder is returning the right value but those are not getting
overwritten. Here's the code for the valueencoder

	public ValueEncoder<Promotion> getPromotionEncoder() {

		return new ValueEncoder<Promotion>() {

			@Log
			public String toClient(Promotion promo) {

				if (promo.getId() == 0) {
					return null;
				}
				return new Long(promo.getId()).toString();
			}
			@Log
			public Promotion toValue(String id) {
				Promotion promotion = null;
				if (id == null) {
					promotion = new Promotion();
					if (!request.isXHR())
						newPromotions.add(promotion);
					return promotion;
				} else {
					promotion = crudService.findUniqueWithNamedQuery(
							Promotion.BY_ID,
							QueryParameters
									.with("id", new Long(id).longValue())
									.parameters());
				}
				return promotion == null ? new Promotion() : promotion;
			}
		};
	}


-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
http://www.arsmachina.com.br

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