hi
I have a Table in my Database called Recipient, in that table is
stored a list of potential newsletter recipients
the website admin can send throug website a mail to a person in the
list asking for his authorization to receive newsletter.
the email contain tho links: one for accepting authorization and one
other for denying, both are DirectActions.
The deny action works perfectly, the :
here my code:
public WOActionResults removeSubscriptionAction() { //DENY ACTION
String code = (String)request().formValueForKey("code");
if ( ( code != null ) && ( code.length() > 2 ) ) {
submissionResult nextPage = (submissionResult)pageWithName
("submissionResult");
nextPage.setCode(new Integer(code).intValue()); //code is used for
search the user in database
nextPage.setConfirmation(false);
return nextPage;
} else {
//CODE FOR RETURNING TO HOME PAGE
}
}
public WOActionResults confirmAuthorizationAction() { //AUTHORIZE
ACTION
String code = (String)request().formValueForKey("code");
if ( ( code != null ) && ( code.length() > 2 ) ) {
submissionResult nextPage = (submissionResult)pageWithName
("submissionResult");
nextPage.setCode(new Integer(code).intValue()); //code is used
for search the user in database
nextPage.setConfirmation(true);
return nextPage;
} else {
//CODE FOR RETURNING TO HOME PAGE
}
}
the submissionResult code:
public void appendToResponse(WOResponse response, WOContext context)
{
EOEditingContext ec=session().defaultEditingContext();
EOFetchSpecification fetchSpec;
NSMutableDictionary dict = new NSMutableDictionary();
dict.takeValueForKey(code,"code");
fetchSpec = new EOFetchSpecification().fetchSpecificationNamed
("authorizingRecipient","Recipient");
fetchSpec =
fetchSpec.fetchSpecificationWithQualifierBindings(dict);
recipientList = ec.objectsWithFetchSpecification(fetchSpec);
System.out.println("session="+this.hasSession());
if ( ( recipientList != null ) && ( recipientList.count() == 1 ) &&
confirmation ) {
System.out.println("AUTHORIZING");
theRecipient =
(Recipient)recipientList.objectAtIndex(0);
theRecipient.authorize(); //THIS SIMPLY CHANGE A COLUMNS VALUE,
SEE CODE BELOW
ec.saveChanges(); //ABSOLUTELY DON'T WORK ! RECORD ARE
NOT UPDATED
}
if ( ( recipientList != null ) && ( recipientList.count() == 1 )
&& !confirmation ) {
System.out.println("DELETING");
theRecipient =
(Recipient)recipientList.objectAtIndex(0);
ec.deleteObject(theRecipient);
ec.saveChanges(); //THIS CODE WORKS PERFECTLY, RECORD
IS DELETED
}
super.appendToResponse(response, context);
}
Recipient class authorize() method
public void authorize() {
setAuthorization(new Integer(1));
}
Now I'm thinking on a workaround based on direct SQL command, but I
would like to know why this is not working.
Tha database engine is openbase.
Thank you for support
Amedeo Mantica
http://www.se30.it
_______________________________________________
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]