Re: Display Groups
Re: Display Groups
- Subject: Re: Display Groups
- From: Sam Barnum <email@hidden>
- Date: Sun, 25 Jul 2004 10:11:27 -0700
no, calling insert() doesn't overwrite anything, it appends the newly
inserted object after the currently selected object, and selects the
newly inserted object. So the code isn't so ugly:
public WOComponent addObjectAction() {
userDisplayGroup.insert();
EOEnterpriseObject newObject = userDisplayGroup.selectedObject();
WOComponent nextPage = pageWithName("WidgetEditPage");
nextPage.takeValueForKey(newObject, "widget");
return nextPage;
}
I'm sure the reason WODisplayGroup's insert method works the way it
does is so you can bind a WOHyperlink directly to the insert method on
the display group. But if you want to take the user directly to the
edit page, you need to do something like the above. Just a little
misleading at time, is all.
On Jul 23, 2004, at 9:47 AM, Nathan Dumar wrote:
One big gripe: insertObject() does NOT return the object being
inserted! It returns null. Get the inserted object by callinng
selectedObject().
Do you mean the method insert()?
When reading the API, it sounded to me like it would overwrite an
existing object if I did not first clear the selection. I also didn't
see anything about the inserted object automatically being selected.
So here's what I did:
userDisplayGroup.clearSelection(); // clears selection so index is at
end of display group
userDisplayGroup.insert(); // inserts the new object at the end,
because selection is cleared
Integer i = (Integer)userDisplayGroup.indexOfLastDisplayedObject() -
1; // get number of new object
userDisplayGroup.setSelectionIndexes(new NSArray(i); // set selection
to i - the new object
This is according to my understanding of the display group. I may
have done more work than was necessary.
Yet, it's a fine illustration of what Lotsa means when he says,
_______________________________________________
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.