Re: Changing value of a WOConditional binding inside WORepetition
Re: Changing value of a WOConditional binding inside WORepetition
- Subject: Re: Changing value of a WOConditional binding inside WORepetition
- From: Chuck Hill <email@hidden>
- Date: Tue, 30 Aug 2005 14:49:31 -0700
On Aug 30, 2005, at 2:37 PM, David Holt wrote:
Hi Ken,
Thanks for your response. Your idea works great, but the UI is
still not updating. My WORepetition is bound to a WODisplayGroup
and I am beginning to wonder if that is another factor complicating
things. Have you used a WODisplayGroup and marked records for
deletion? The code I am using is below. Maybe I am doing something
wrong? Thanks,
David
public void appendToResponse(WOResponse aResponse, WOContext
aContext) {
if (documentToUndelete != null) {
EOEditingContext ec = session().defaultEditingContext();
To make this safer for future changes,
EOEditingContext ec = documentToUndelete.editingContext();
Integer i = new Integer(0);
documentToUndelete.takeValueForKey(i,"deleted");
Why not bury this particular nastiness in the EO where it belongs:
documentToUndelete.undelete();
DeletedLookup aDeletedLookup = (DeletedLookup)
documentToUndelete.valueForKey("deletedLookup");
I'm not at all sure what this is.
documentToUndelete.addObjectToBothSidesOfRelationshipWithKey
(aDeletedLookup,"deletedLookup");
Both delete and undelete
use .addObjectToBothSidesOfRelationshipWithKey
(aDeletedLookup,"deletedLookup"); Should one of them be using
removeObject...?
Chuck
ec.saveChanges();
}
if (documentToDelete != null) {
EOEditingContext ec = session().defaultEditingContext();
Integer i = new Integer(1);
documentToDelete.takeValueForKey(i,"deleted");
DeletedLookup aDeletedLookup = (DeletedLookup)
documentToDelete.valueForKey("deletedLookup");
documentToDelete.addObjectToBothSidesOfRelationshipWithKey
(aDeletedLookup,"deletedLookup");
ec.saveChanges();
}
super.appendToResponse(aResponse,aContext);
}
public WOComponent deleteDocument()
{
documentToDelete=itemDocument;
return context().page();
}
public WOComponent undeleteDocument()
{
documentToUndelete=itemDocument;
return context().page();
}
// used to bind to the WOConditional
public boolean markedForDeletion()
{
DeletedLookup aDeletedLookup = (DeletedLookup)
valueForKeyPath("itemDocument.deletedLookup");
String deletedFlag = (String)aDeletedLookup.deleted_desc();
return deletedFlag.equals(thisIsMarked);
}
On 30 Aug 2005, at 1:56 PM, Ken Anderson wrote:
Since you are directly modifying an attribute that is determining
the structure of the page, things are getting messed up (WO
doesn't like this). What I usually do is have the hyperlink put
the record to modify into a temporary variable (or something),
then update the EO's flag in appendToResponse(). Something like
this (just pseudocode here)
public WOComponent flipDeletedFlag() {
recordToDelete = currentRecord;
return context().page();
}
public void appendToResponse(WOResponse aResponse, WOContext
aContext) {
if (recordToDelete != null) {
recordToDelete.setDeleted(true);
recordToDelete = null;
super.appendToReponse(aResponse, aContext);
}
Ken
On Aug 30, 2005, at 3:11 PM, David Holt wrote:
I have a conditional that wraps a hyperlink for marking documents
for deletion. The binding is set to the value of the deletion flag.
If a document has already been marked, the hyperlink allows an
"undelete" and resets the flag. Clicking the link changes the
underlying variable, but it doesn't immediately affect the
WOConditional until I log out and then log back in. What am I
doing wrong?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anderhome.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
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