• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: takeValuesFromRequest question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: takeValuesFromRequest question


  • Subject: Re: takeValuesFromRequest question
  • From: Arturo Perez <email@hidden>
  • Date: Tue, 20 Sep 2005 09:49:37 -0400

Miguel Arroz wrote:
Hi!

First, sorry about posting so many basic question on this list... i'm really enjoying learning WO, and I want to know some details about the framework! :)

I'm trying to define a component (called ErrorLabel) that might (or not) display an error. The ideia is to put an instance of ErrorLabel next to a TextField, button, etc, so that when the value the user introduces is wrong, and error label appears next to that element.

I've learned that a component gets the values from the interface and sets them on the model object during the execution of takeValuesFromRequest. My ideia was to build validators on the model class, and catch the exceptions on the component.

The problem is that the takeValuesFromRequest is catching all the exceptions, and printing error messages on the console, like "[2005-09-20 13:41:29 WEST] <WorkerThread3> Validation failed on an object [null] with keypath = publicTicket.email and exception: The email property of Ticket is not allowed to be null."

How can I catch this exceptions, so that I may turn on the visibility of the error labels? Of course, I may redefine takeValuesFromRequest so that I grab all the values manually, and surround the code with a try/catch, but that looks lot a lot of pointless work, and lack of abstraction (if I need to add or remove a component, I will have to change that code manually). Following the "If you are writing code, you are doing something wrong" WebObjects non-official slogan, is there a better way to do this?

  Yours

Miguel Arroz



An important method for this is validationFailedWithException. I think that's the one printing on the console. This method handles all the exceptions thrown by the variable valueFor<KEY> methods.

So, for example,  you do

public void validateEmail(...) {
	if (email == good) return;
	else throw new NSValidation.ValidationException("email is bad"...);
}

then validationFailedWithException captures all of that.

There's an article on StepWise that covers it: http://www.stepwise.com/Articles/Technical/2001-06-13.01.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: takeValuesFromRequest question
      • From: Michael Warner <email@hidden>
References: 
 >takeValuesFromRequest question (From: Miguel Arroz <email@hidden>)

  • Prev by Date: Re: takeValuesFromRequest question
  • Next by Date: Implement or avoid LEFT JOIN in EOF?
  • Previous by thread: Re: takeValuesFromRequest question
  • Next by thread: Re: takeValuesFromRequest question
  • Index(es):
    • Date
    • Thread