• 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: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship]


  • Subject: Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship]
  • From: Dev WO <email@hidden>
  • Date: Tue, 26 Jul 2005 23:58:29 +0200

Hi Chuck, and I'm really sorry about keeping on asking question about this...
We're getting really closer, here's the latest "problem":
when I add or update, the product previously in the form is still filling the textfields. Everything is ok on the database side.
So I think the creation of an empty object isn't fully working:
here the setup:
-no creation of productGeneric Object on initialisation
-the addOrUpdate method is:
public WOComponent addOrUpdateProductGeneric()
{
awakeFromInsertionProductGeneric(ec);
ec.saveChanges();
return context().page();
}
-the awakeFromInsertionProductGeneric method is:
public void awakeFromInsertionProductGeneric (EOEditingContext ec) {
if (productGeneric.datePosted() == null) {
productGeneric.setDatePosted(new NSTimestamp());
productGeneric.setEmployeePosted(session.employee());
productGeneric.setStockStatus(new Integer(0));
}
else {
productGeneric.setDateUpdated(new NSTimestamp());
productGeneric.setEmployeeUpdated(session.employee());
editMode = false; // to get back to adding mode
}
}
-I've added:
if (editMode) {
setProductToBeEdited(null);
}
to the appendToResponse method.


the append to response method to:
if (!editMode) {
setProductToBeEdited(null);
}
I've got an empty form after every "add", and everything works fine in the database. But, there's a but;)
If I edit a previous productGeneric, I got a ghost inserted in the database when "update" (and get an empty form to add another product).
So here's my edit method:
public WOComponent editProductGeneric()
{
productGeneric = aProductGeneric;
editMode = true;
return context().page();
}


editMode is really only used to hide or display some part of the page, there's nothing "intelligent" in it.

So it gets closer, but now the problem has moved from the "adding" to the "update";)
I'm pretty lost in fact as I'm not sure to fully understand all this;)


Thanks again for your valuable support Chuck:)

Xavier



Le 26 juil. 05 à 18:58, Chuck Hill a écrit :

I'm not sure what you don't understand. :-) This is the code I meant:

public WOComponent addOrUpdateProductGeneric()
{
awakeFromInsertionProductGeneric(ec); //setting the date posted/updated
if (!productGenericList.containsObject(productGeneric))
{
productGeneric.setStockStatus(new Integer(0));
}
else
{
editMode = false;
}
ec.saveChanges();


        // If we just created a new object and saved it,
        // reset object so that another new object will be created
        // for next time
        if (editMode) {
            setProductToBeEdited(null);
        }

        return context().page();
    }


Chuck

On Jul 23, 2005, at 9:20 AM, Dev WO wrote:




-----
public WOComponent addOrUpdateProductGeneric()
{
awakeFromInsertionProductGeneric(ec); //setting the date posted/updated
if (!productGenericList.containsObject(productGeneric))
{
productGeneric.setStockStatus(new Integer(0));
}
else
{
editMode = false;
}
ec.saveChanges();




Replace the code below with something like: // We just created a new object and saved it. // Reset page so that another new object will be created if (editMode) { setProductToBeEdited(null); }



        productGeneric = new ProductGeneric();
        ec.insertObject(productGeneric);
        productGeneric.setCommentaryAllowed(new Boolean(true));
        productGeneric.setIsAvailable(new Boolean(true));
        productGeneric.setSalesPrice(new Integer(0));
        return context().page();
    }






--
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: This email sent to email@hidden
  • Follow-Ups:
    • Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship]
      • From: Chuck Hill <email@hidden>
References: 
 >Debuging WOManyToManyRelationship (From: Dev WO <email@hidden>)
 >Re: Debuging WOManyToManyRelationship (From: Dev WO <email@hidden>)
 >Re: Debuging WOManyToManyRelationship (From: Chuck Hill <email@hidden>)
 >Re: Debuging WOManyToManyRelationship (From: Dev WO <email@hidden>)
 >Re: Debuging WOManyToManyRelationship (From: Chuck Hill <email@hidden>)
 >Re: Debuging WOManyToManyRelationship (From: Dev WO <email@hidden>)
 >EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship] (From: Dev WO <email@hidden>)
 >Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship] (From: Chuck Hill <email@hidden>)
 >Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship] (From: Dev WO <email@hidden>)
 >Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship] (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: many-to-many with attributes?
  • Next by Date: Re: RR loop confusion....
  • Previous by thread: Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship]
  • Next by thread: Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship]
  • Index(es):
    • Date
    • Thread