Re: EditingContext problem, ghost entry in datastore [ was Debuging WOManyToManyRelationship]
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