Hi Ken,I'm using the DA to activate the account (by setting a boolean to true) so that's why it saves. Sometimes, but very rarely. At least it happens now on my development machine, so only one instance was running. this type of object (accounts) could be updated using another application, but I'm sure it wasn't for now. Actually I'm creating a dedicated EC to manage this direct action: ===== public WOActionResults validateEmailAction(){ String email = (String)request().formValueForKey("email"); EOEditingContext emailEC = new EOEditingContext(); NSMutableArray args = new NSMutableArray(); args.addObject(email); EOQualifier qual = EOQualifier.qualifierWithQualifierFormat("(email = %@) and (deletedOn = null)", args); EOFetchSpecification spec = new EOFetchSpecification("Member",qual,null); NSArray results = emailEC.objectsWithFetchSpecification(spec); Main nextPage = (Main)pageWithName("Main"); if (results.count()==0){ nextPage.setDisplayString("le compte " + email + " n'existe pas!"); nextPage.setMessageBannerIsPositive(false); } else{ Member aMember = (Member)results.objectAtIndex(0); if ((aMember.emailValid().booleanValue()) && ((!aMember.activation().booleanValue()) || (aMember.activation() == null))) { nextPage.setDisplayString("Votre compte " + aMember.email() + " a été désactivé par un administrateur"); nextPage.setMessageBannerIsPositive(false); } if ((aMember.emailValid().booleanValue()) && (aMember.activation().booleanValue())) { nextPage.setDisplayString("Votre compte " + aMember.email() + " a déjà été activé"); nextPage.setMessageBannerIsPositive(false); } if (!aMember.emailValid().booleanValue()){ try { aMember.setEmailValid(new Boolean(true)); aMember.setActivation(new Boolean(true)); emailEC.lock(); emailEC.saveChanges(); emailEC.unlock(); //ec.saveChanges(); EOEditingContext ec = session().defaultEditingContext(); Person aPerson = (Person)EOUtilities.localInstanceOfObject(ec, (Person)aMember); emailEC.dispose(); //Person aPerson = (Person)aMember; ((Session)session()).setSessionPerson(aPerson); nextPage.setDisplayString("Votre compte " + aPerson.email() + " vient d'être activé"); nextPage.setMessageBannerIsPositive(true); } catch (Exception e){ e.printStackTrace(); } } } return nextPage; } ===== So I don't really know how come the update fails... Should I make everything will the EC is locked? Xavier
|
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]
