Re: sorting output
Re: sorting output
- Subject: Re: sorting output
- From: Wes James <email@hidden>
- Date: Thu, 19 Aug 2004 15:16:12 -0600
On Thu, 19 Aug 2004 16:19:29 -0400, Nathan Dumar <email@hidden> wrote:
> Sounds like you're using a WODisplayGroup. If you are, I think you
> have to do myDisplayGroup.updateDisplayedObjects(). Sorting isn't done
> automatically after modifications.
>
> Nathan
>
>
>
>
> On Aug 19, 2004, at 12:22 PM, Wes James wrote:
>
> > I have been working with the Web Applications manual that has some WO
> > tutorials. It has a section about databases and at the end it adds a
> > little info about how to sort the output. When I add the code to
> > main.java:
> >
> > in this method (is the main constructor called a method?):
> > public Main(WOContext context) {
> >
> > If there are any records it does sort the data, but If I add a record
> > it adds the data at the end of the list of data. Then when I run the
> > WOapp again, the data is sorted properly. Why isn't the data sorted
> > after each Add request?
> >
> > thanks,
> >
> > wj
>
>
In the main.wo there is are two forms and a worepetition
<form>
firstname <textfield>
lastname <textfield>
<update button> <add button>
</form>
<form>
<revert button> <save button>
</form>
<worepetition>
<edit link> <delete link> <lastname-text>, <firstname-text>
</worepetition>
When each record is added to the web output it is tacked on at the
bottom. If the web page is being refreshed, why doesn't it use the
fetchSpec to order it?
Here is the main section:
public Main(WOContext context) {
super(context);
// Sort ascending lastName ignoring case.
lastNameSort = new EOSortOrdering("lastName",
EOSortOrdering.CompareCaseInsensitiveAscending);
// Sort ascending by firstName ignoring case.
firstNameSort = new EOSortOrdering("firstName",
EOSortOrdering.CompareCaseInsensitiveAscending);
// Create an array with the two sort orderings.
sortOrderings = new NSMutableArray();
sortOrderings.addObject(lastNameSort);
sortOrderings.addObject(firstNameSort);
// Create the fetch specification.
fetchSpec = new EOFetchSpecification("Author", null, sortOrderings);
// Get the editing context.
editingContext = session().defaultEditingContext();
// Fetch authors.
authorList = new
NSMutableArray(editingContext.objectsWithFetchSpecification(fetchSpec));
// Get the Author class description from the Author Entity.
authorClassDescription =
EOClassDescription.classDescriptionForEntityName("Author");
// Create an Author object (where form data is stored).
author = new EOGenericRecord(authorClassDescription);
}
When is the main section run? Only at the beginning of the running web app?
Would I have to set the fetchSpec in the "Add" method to get the
sorted list each time?
thanks,
wj
_______________________________________________
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.