Why don't you use onPrepareFromQuantity(Integer quantity) instead? Does
this validation require other fields to be checked?
On Wed, 02 Feb 2011 12:49:58 -0200, Benny Law <benny.mk....@gmail.com>
wrote:
The following code illustrates what I am doing:
<t:form t:id="form" ...>
<t:loop source="items" value="item" ...>
<t:textfield t:id="quantity" value="item.quantity" .../>
</t:loop>
</t:form>
@InjectComponent private Form form;
@InjectComponent private TextField quantity;
@Property private Item item;
void onValidateForm() {
for (Item i: getItems()) {
if (...cross-field check...) {
form.recordError( quantity, "Error message");
}
}
}
What I find is that when I get to onValidateForm(), the injected quantity
field is always the last instance (the one bound to the last item). I
need a
way to get the instance that matches the current item in the for loop.
Hope that clarifies my question. Thanks.
Benny
On Wed, Feb 2, 2011 at 6:21 AM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:
On Wed, 02 Feb 2011 02:26:45 -0200, Benny Law <benny.mk....@gmail.com>
wrote:
Hi,
Hi!
I have a loop inside a form that renders a textfield and some other
controls. When I am doing cross field validations in the ValidateForm
event while iterating over a collection (the source of the loop), I
would
like to record error messages against the form with the field in error
to
get the
normal error highlighting. How can I get to the field in this case
since I
can't use normal injection?
Why not? Even when inside a loop, you don't have more than one instance
of
a given component. Example:
<t:loop ...>
<t:textfield t:id="title".../>
</t:loop>
You have only one instance of the TextField with t:id "title",
regardless
of the number of iterations.
I don't know if this solves your problem, but at least I'm trying to
help
you figure it out. ;)
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
--
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
Coordenador e professor da Especialização em Engenharia de Software com
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org