Easiest way to do is use the "ValidationDeligate" . Where you declare this
validation deligate in your html page might not be that imp. But it has to
be declared as a bean. In your jave class when you are iterating through the
list of persons and when you find the red color there itself get the
ValidationDeligate and record the error message in it. Rest of the things
will be done by tapestry.
First thing is you have to declare the deligate in the "Form" component.
To get the validation deligate in your java code :-
// getBeans() method is in AbstractComponent.
ValidationDeligate vd=(ValidationDeligate)getBeans().getBean("nameOfThe
ValidationDeligate bean");
To record the message :-
// there are three methods to record the error use one according to your
convenience.
Vd.setFormComponent(IFormComponent component);
Vd.record(String message, ValidationConstraint constraint);
In your html after propertyselction don't forget to write the following code
:-
Use "Conditional" component and the codition is
ognl:beans.NameOfTheValidationDeligate.hasErrors and use your
own decoration like "***" or images or anything.
Does this solve your problem?
Muralidhar Y
Software Engineer,
Adastrum technologies-Nikai groups,
EmiratesGroup-I.T Division,
Dubai, UAE.
Mobile : 00971-50-2256149.
http://www.adastrumtech.com
http://www.mercator.aero
(Keep Smiling. Be happy All The Time.)
-----Original Message-----
From: Larry Sherrill [mailto:[EMAIL PROTECTED]
Sent: 03 October 2005 20:17
To: Tapestry users
Subject: Re: validating PropertySelection in each row of a table
Thanks for the reply. I will move to Tapestry 4 soon but for now I need to
implement in Tapestry 3.
I have placed the Delegator component after the PropertySelection component
within the TD tag. I don't understand how MyDelegate accesses the component
that it needs to validate. Here is what I have so far:
<pre>
<td>
<select jwcid="[EMAIL PROTECTED]"
model="ognl:colors" value="ognl:color"></select>
<span jwcid="@Delegator"
delegate="ognl:myDelegate"/>
</td>
public class MyDelegate implements IRender {
public void render(IMarkupWriter w, IRequestCycle
c) {
if (c.isRewinding()) {
// validate component
// - if user selected red then print "***"
}
}
}
Home.java has a getMyDelegate method.
</pre>
1. How does the render method get access to the component it needs to valid
to validate?
2. If I am in rewind then how does the *** ever get printed in case of error
since output is swallowed.
I am currently digging thru the source for ValidationDelegate for clues as
well as looking thru Tapestry in Action and EnjoyWebDevWithTapestry.
Thank you very much,
Larry Sherrill
--- Kent Tong <[EMAIL PROTECTED]> wrote:
> Larry Sherrill <larrypsherrill <at> yahoo.com>
> writes:
>
> > In my submit method I loop through the list of
> Persons
> > to validate that the favoriteColor is not the
> choice
> > "Red". If it is, then I want to mark the
> corresponding
> > propertySelection field with a "**" to the right
> of
> > the PropertySelection drop down.
>
> The cleanest solution is to upgrade to Tapestry 4 where you can
> provide a validator to validate your PropertySelection component.
>
> If you must stick to tapestry 3, you may add a Delegator component
> just after your PropertySelection, implement IRender in code.
> In that code you can perform the check if it's a rewind.
>
> --
> Author of a book for learning Tapestry
> (http://www.agileskills2.org/EWDT)
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]