• 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: Yet Another Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet Another Question


  • Subject: Re: Yet Another Question
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 20 Mar 2008 13:57:07 -0700

Please keep replies on list.


On Mar 20, 2008, at 1:48 PM, Yury Peskin wrote:

Chuck,
So what you're saying is to move the validation into form action instead of the EO and throw the exception there?

No. Absolutely not! I am suggesting that ensuring this is unique is not trivial.


Chuck



Something like this:
public WOComponent formAction()
{
NSMutableArray args = new NSMutableArray();
args.addObject(project.orderNum);
Project newProject = EOUtilities.objectWithQualifierFormat(ec, "Project", "orderNum = %@", args);
if(newProject != null)
{
validationDictionary.setObjectForKey(Boolean.TRUE, "project.orderNum");
validationDictionary.setObjectForKey("This number is already in use.”, "project.orderNum" + "ValidationString");
return null;
}
else
return nextPage;
}
Thank you,


Yury Peskin

-----Original Message-----
From: Chuck Hill [mailto:email@hidden]
Sent: Thursday, March 20, 2008 3:38 PM
To: Yury Peskin
Cc: 'WebObjects Development'
Subject: Re: Yet Another Question


On Mar 20, 2008, at 1:33 PM, Yury Peskin wrote:
Hello List,
I have an order number in my EO and I need to have it be a unique
number.
How can I check that my users did not type in an identical number?
I’m trying to do validation and my validation right now looks like
this:

public String validateOrderNum(String value) throws
NSValidation.ValidationException
{
           // Check the order number is unique
           NSMutableArray args = new NSMutableArray();
           Args.addObject(value);
EOEditingContext ec = session().defaultEditingContext();

Remove

Project project = EOUtilities.objectWithQualifierFormat(ec,
“Project”, “orderNum = %@”, args);

Change to Project project = EOUtilities.objectWithQualifierFormat(editingContext(), “Project”, “orderNum = %@”, args);

           If(project != null)
                       Throw new
NSValidation.ValidationException(“This number is already in use.”);
}

I keep getting “cannot find symbol” on the ec and the EOUtilities
lines.
Is there a way I can get this type of validation to work

That will leave you with a race condition. It is NOT to be depended on. The ONLY way to be certain is to add a unique constraint in the database and and check for failures during save changes.

Chuck


--

Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects








--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific 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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Yet Another Question
      • From: Andrew Lindesay <email@hidden>
    • Re: Yet Another Question
      • From: Louis Demers <email@hidden>
References: 
 >Yet Another Question (From: "Yury Peskin" <email@hidden>)
 >Re: Yet Another Question (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Better start with Wonder than WO
  • Next by Date: Re: Better start with Wonder than WO
  • Previous by thread: Re: Yet Another Question
  • Next by thread: Re: Yet Another Question
  • Index(es):
    • Date
    • Thread