• 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: Reusable Subcomponent Dependent Form Values Validation Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reusable Subcomponent Dependent Form Values Validation Question


  • Subject: Re: Reusable Subcomponent Dependent Form Values Validation Question
  • From: Kieran Kelleher <email@hidden>
  • Date: Mon, 7 Feb 2005 06:52:35 -0500

Nathan,

I do something like this. I implement it in takeVakuesFromRequest calling super first. I have a generic superclass for my top level pages. It has a lazily initialized dictionary named pageErrors. Errors not related to individual values are stored here, for example
root().setPageError("The password and repeated password entered were not the same.")


[root() is just a generic method that crawls up the the top parent (the "page") and returns a reference to it.

setPageError() automatically sets a boolean _hasValidationErrors (exists in the Page component superclass) to true. By the way this same _hasValidationErrors is set to true when any component's validationFailedWithException is also called.[ root().setHasValidationErrors( true ); ]

In invokeAction, the first this I do is

if ( hasValidationErrors() == true ) {
	return null;
}

In appendToResponse, after super, I nullify any error message dictionaries (since their content has now been used in the page generation)

Thus the same page is returned and any field level validation errors are displayed in red beside the respective fields and overall page level (and interdependent object-level too) errors are displayed at the top of the page in red from the pageErrors dictionary. The user can now update the values and submit again.

-Kieran
________________________________________________________________
My hardware/software configurations (in case they are relevant to he problem):
Dev Config = OS X 10.3.5 / Java 1.4.2_05 / WO 5.2.3 / XCode v1.5 / MySQL 4.0.20 / Connector-J 3.0.11
Deploy Config = OS X 10.3.7 Server / Java 1.4.2_05 / WO 5.2.3 / MySQL 4.0.20 / Connector-J 3.0.11
Project Wonder Frameworks = ERJavaMail, ERJars, ERExtensions (Version 2.0 June 29, 2004 Binary)
My Development Notes Blog (so I don't forget stuff!): http://webobjects.webhop.org/



On Feb 6, 2005, at 4:39 PM, Nathan Hampton wrote:

Okay, this is cool: my exact question has already been answered.

BUT...  (Like you couldn't see that one coming a mile away...)

We need graceful error handling: if the validation fails, I need to notify the user so the user can take corrective action. The only way I can think of to do this is to override takeValuesFromRequest in the parent component so that the call to the superclass is within a try block. If the validation fails, I catch the exception thrown by the subcomponent and notify the user in my usual manner. This doesn't seem particularly elegant to me, which usually means I'm doing something wrong. Does anyone have a better idea?

--Nathan Hampton (email@hidden)

On 06 Dec 2004, at 10:15 AM, Chuck Hill wrote:

invokeAction may not work depending on (a) whether your action method returns null or no, and (b) the relative position (before or after) of the submit button. Neither makes for a good resuable component. Why not do it in takeValuesFromRequest after calling super? The validate and set logic seems more appropriate to setting values than performing an action.


Chuck


On Dec 2, 2004, at 12:45 PM, Kieran Kelleher wrote:

I have two Strings, password and passwordRepeated within a resuable UserEdit component with a binding to "User usr" in the parent component. The usr EO has an attribute hashedPassword where the final SHA hashed password is stored. The parent component has the Submit and form for the page.

Where would I validate and compare "password" and "passwordRepeated" within the reusable component and then hash and set the EO's attribute?

(Normally I would do this on the Submit action method, but this exists in the parent. Studying Chucks book, chapter 5, I am thinking I should over-ride invokeAction, call super.invokeAction() and afterward compare my two values and throw a validation exception if different, otherwise hash and store in the EO? ... would that be the proper approach?)


________________________________________________________________
Dev Config = OS X 10.3.5 / Java 1.4.2_05 / WO 5.2.3 / XCode v1.5 / MySQL 4.0.20 / Connector-J 3.0.11
Deploy Config = OS X 10.3.5 Server / Java 1.4.2_05 / WO 5.2.3 / MySQL 4.0.20 / Connector-J 3.0.11
My Blog: http://webobjects.webhop.org/


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ 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
References: 
 >Re: Reusable Subcomponent Dependent Form Values Validation Question (From: Nathan Hampton <email@hidden>)

  • Prev by Date: [Solved, sort of] Display Group not setting object array
  • Next by Date: JNDI/LDAP multi-value attributes just work
  • Previous by thread: Re: Reusable Subcomponent Dependent Form Values Validation Question
  • Next by thread: WO and Laszlo
  • Index(es):
    • Date
    • Thread