• 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: Still hopeful for D2WList advice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Still hopeful for D2WList advice


  • Subject: Re: Still hopeful for D2WList advice
  • From: Justin Tocci <email@hidden>
  • Date: Wed, 25 Aug 2004 14:49:18 -0500

"Could not save your changes: updateValuesInRowDescribedByQualifier --
com.webobjects.jdbcadaptor.JDBCChannel method failed to update row in
database"

This is exactly the error I get. You described the situation perfectly. It is a locked object that is causing the conflict. I cannot unlock the problem column, I need the user to see the new data which has changed before they are allowed to make an update.

At this point I've gotten as far as copying the code below from the Enterprise Objects manual into my components .java file. I think it'll do what I need it to do. I'm stuck trying to find a rule to tell Direct to Web to use the save() method below instead of whatever it usually uses when a user clicks the submit button. I could use it with a hand built component, but I would really like to use Direct to Web.

justin tocci
fort wayne, in

import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.directtoweb.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;

public class Main extends WOComponent {
    public String username;
    public String password;
    public boolean wantsWebAssistant = false;
    public WODisplayGroup xwebuser1DisplayGroup;
    public Main(WOContext aContext) {
        super(aContext);

	}

    public WOComponent defaultPage() {
        if (isAssistantCheckboxVisible()) {
            D2W.factory().setWebAssistantEnabled(wantsWebAssistant);
        }
        return D2W.factory().defaultPage(session());
    }

public boolean isAssistantCheckboxVisible() {
String s = System.getProperty("D2WWebAssistantEnabled");
return s == null || NSPropertyListSerialization.booleanForString(s);
}

public void save() {
EOEditingContext editingContext = session().defaultEditingContext();
try {
editingContext.saveChanges();
//Thrown for each eo that fails to save.
} catch (EOGeneralAdaptorException saveException) { // 1
//Determine if the exception is an optimistic locking exception.
if (isOptimisticLockingFailure(saveException)) { // 2
//Deal with the optimistic locking exception.
handleOptimisticLockingFailureByRefaulting(saveException); // 3
} else {
//Don't know what went wrong so revert editing context to a stable state.
editingContext.revert(); // 4
}
}
}

//Determine if the exception thrown during a save is an optimistic locking exception.
public boolean isOptimisticLockingFailure(EOGeneralAdaptorException exceptionWhileSaving) {
//Get the info dictionary that is created when the exception is thrown.
NSDictionary exceptionInfo = exceptionWhileSaving.userInfo(); // 1
//Determine the type of the failure.
Object failureType = (exceptionInfo != null) ? exceptionInfo.objectForKey(EOAdaptorChannel.AdaptorFailureKey) : null; // 2
//Return depending on the type of failure.
if ((failureType != null) && (failureType.equals(EOAdaptorChannel.AdaptorOptimisticLockingFailure))) { // 3
return true;
} else {
return false;
}
}

//Deal with an optimistic locking failure.
public void handleOptimisticLockingFailureByRefaulting(EOGeneralAdaptorException lockingException) {
//Get the info dictionary that is created when the exception is thrown.
NSDictionary info = lockingException.userInfo(); // 1
//Determine the adaptor operation that triggered the optimistic locking failure.
EOAdaptorOperation adaptorOperation = (EOAdaptorOperation)info.objectForKey(EOAdaptorChannel.FailedAdaptorOper ationKey); // 2
int operationType = adaptorOperation.adaptorOperator(); // 3
//Determine the database operation that triggered the failure.
EODatabaseOperation dbOperation = (EODatabaseOperation)info.objectForKey(EODatabaseContext.FailedDatabaseO perationKey); // 4
//Retrieve the enterprise object that triggered the failure.
EOEnterpriseObject failedEO = (EOEnterpriseObject)dbOperation.object(); // 5
//Retrieve the dictionary of values involved in the failure.
//Take action based on the type of adaptor operation that triggered the optimistic locking failure.
if (operationType == EODatabaseOperation.AdaptorUpdateOperator) { // 6
//Recover by refaulting the enterprise object involved in the failure.
//This refreshes the eo's data and allows the user to enter changes again and resave.
session().defaultEditingContext().refaultObject(failedEO); // 7
} else { //The optimistic locking failure was caused by another type of adaptor operation, not an update.
throw new NSForwardException(lockingException, "Unknown adaptorOperator " + operationType + " in optimistic locking exception.");
}
session().defaultEditingContext().saveChanges();
}
}
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.



  • Prev by Date: java client mailing list
  • Next by Date: Re: Postgresql, booleans and EOM
  • Previous by thread: Re: Still hopeful for D2WList advice
  • Next by thread: Can't run WebServicesAssistant
  • Index(es):
    • Date
    • Thread