I'm not familiar worth T4.1 but it seems to me that you could put something
in the submit or success handler that validates.

Take a look here -
http://tapestry.apache.org/tapestry5/guide/validation.html and find the
following snippet:

public class Login
{
    ....

*    String onSuccess()
    {
        if (!authenticator.isValid(userName, password))
        {
            form.recordError(passwordField, "Invalid user name or
password.");
            return null;
        }*

        return "PostLogin";
    }


Oddly enough, it is NOT the validation handler I want to bring to your
attention to (here on this validation.html page :) and again, obviously,
this is Tapestry 5 - but notice how authentication is done in the SUCCESS
handler. I would try to do something similar (albeit validation) to look at
the fields you are processing.

It'd be manual ... but notice here - an error is returned and associated
with T5 fields ...

Again - you'll need to find T4s parallel.

-Luther



On Mon, Mar 9, 2009 at 10:04 AM, Elmer Smith <esm...@venterraliving.com>wrote:

> Ivano,
>
> I'm pretty sure what you want to do is provide an onValidate method in
> your page class.  That method gets called expressly for doing more
> complicated validation.  If you have more than one form, you'll have to
> further specify it e.g. onValidateFromMyFormName (or use @OnEvent
> annotation).  Here's some abbreviated code:
>
> @InjectComponent("fielda")
> private TextField fieldaComponent;
>
> @InjectComponent
> private Form formComponent;
> ...
>
> Object onValidate() {
>    If (fielda == null)
>        formComponent.recordError(fieldaComponent, "Example error
> message for fielda");
>
>    if (fielda=="") && (fieldb=="" || fieldc=="")
>       throw new RuntimeException();
>
>    return null;  // this will keep you on the same page
>
> //    return NewPage.class; // this will goto the NewPage page, etc.
> etc.
> }
>
> You may just want to provide a validation message.  I've shown an
> example using fielda in the preceding code.
>
> Read the docs on the Form component, and see the examples in the user
> guide.
>
> Cheers
> -----Original Message-----
> From: Ivano Luberti [mailto:lube...@archicoop.it]
> Sent: Monday, March 09, 2009 8:30 AM
> To: Tapestry users
> Subject: cross field validation with empty fields
>
> Sorry to ask for this again, but I have seen no answer.
> I will get no answer again I will stop asking for this, of course.
>
> TIA
>
> ----------------
> Hello, we are using T4.1
> We have to validate a form and we don't want to do it client side.
> Let say we have three text fields.
> The validation should implement the following rule:
> if (fielda="") && (fieldb="" || fieldc="")
>  then throw new Exception("");
>
> The problem is that we cannot link the validation to neither field
> because they can be empty and the custom validator we are trying to
> implement is nevere called if the field is empty.
> We tried to  follow the Identity validator but it is also not called
> when the field to which is associated is empty.
>
> Is there another way to accomplish cross field validation ?
>
> It seems to us that in T4.1  lacks a validator attribute for the form
> component.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>
> This message (including any attachments) is intended only for the use of
> the individual or entity to whom it is addressed and may contain information
> that is non-public, proprietary, privileged, confidential, and exempt from
> disclosure under applicable law or may constitute attorney work product. If
> you are not the intended recipient, you are hereby notified that any use,
> dissemination, distribution, or copying of this communication is strictly
> prohibited. If you have received this communication in error, please notify
> us immediately by telephone and (i) destroy this message if a facsimile or
> (ii) delete this message immediately if an electronic communication.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to