All very good comments Luther (np about the name :)) and everyone else. Here is 4.0 code that does the same thing:
public void onFormSubmit(IRequestCycle requestCycle) { IValidationDelegate delegate = getDelegate(); // this checks if the automatic validations you have on your // fields (like required) have recorded any errors; // if they have you can skip your manual logic if (!getDelegate().getHasErrors()) { // whatever test you want to make on the field value if (fielda == null) { delegate.setFormComponent(getFieldaComponent()); delegate.record("Example error message for fielda"); } // you can throw from here if you want if (fielda=="") && (fieldb=="" || fieldc=="") throw new RuntimeException(); // // you can use the requestCycle to forward to other pages // or throw a RedirectException } } I just thought the poster might still be pondering what to do in T4. Cheers, Elmer -----Original Message----- From: Luther Baker [mailto:lutherba...@gmail.com] Sent: Monday, March 09, 2009 1:49 PM To: Tapestry users Subject: Re: cross field validation with empty fields Oops sorry @Elmer, I mistyped your name in the previous post and meant @Ivano. Also, @Elmo, I think you're suggestion was perfect! but it looked like T5 code. Shows how little I know about T4 though. Sorry - I think your post was right on if all those annotations and events were in T4. -Luther I meant my latest suggestion to be @Ivano On Mon, Mar 9, 2009 at 12:44 PM, Luther Baker <lutherba...@gmail.com> wrote: > That's a fine point to clarify. > > My underlying suggestion wasn't meant to imply which was the correct, > well-defined event to handle. This is the second post ... no luck/help so > far? ... So my suggestion is that, if all else fails, you can do MANUAL > validation in, if nothing else, the MAIN event handler. Again, I didn't mean > to focus on the actual event as much as the ability to MANUALLY validate and > still send back field specific error messages. > > To Thiago's point, if taken too literally, yes, the example could be > misleading. But it is a minor point. The login example on the Tapestry > website happens to do AUTHENTICATION in the SUCCESS handler (oddly, as part > of a validation example) - and so it is a nice concrete example to send > around - but lest I am misunderstood, it is the general concept I'm trying > to shed some light on ... not whether it is authentication or validation or > onValidate or onSuccess. > > FWIW: since no one posted any response to the poster's original question > (per the poster) and this is the 2nd time he's asked - I assumed that what > he is doing must be out of the ordinary. I do nto know T4 and the fact that > (per the user) 'null' values in the form skipped validation - made me wonder > if the onValidate event was being skipped (as a part of T4). > > @Elmer: so conceptually, you could start by implementing this validation > MANUALLY in the MAIN method and work backwards from there. IE: start with > something you KNOW fires and keep moving that logic backwards until you get > it into a true, validation handler if at all possible. It is an iterative, > workable approach eh? > > But to Thiago's point, if T4 has specific validation events/handlers and > those fire in all cases - by all means, implement this logic there (dont' > need to start in the main event handler). You can still follow the general > logic/structure of the authentication example I linked to. > > Please excuse the rambling here ... hope the clarification was helpful. > > -Luther > > > > > On Mon, Mar 9, 2009 at 12:15 PM, Thiago H. de Paula Figueiredo < > thiag...@gmail.com> wrote: > >> Em Mon, 09 Mar 2009 14:08:43 -0300, Luther Baker <lutherba...@gmail.com> >> escreveu: >> >> 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. >>> >> >> Authentication is not validation. They're different things. Authentication >> is made at onSuccess() because it is only made after the form validation (ie >> the values of login and password are valid for that field). And you should >> do validation at onValidate(). >> >> -- >> Thiago H. de Paula Figueiredo >> Independent Java consultant, developer, and instructor >> http://www.arsmachina.com.br/thiago >> >> >> --------------------------------------------------------------------- >> 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