Re: Sorting Relationed Records
Re: Sorting Relationed Records
- Subject: Re: Sorting Relationed Records
- From: "A. Uchida" <email@hidden>
- Date: Thu, 22 Jul 2004 00:53:25 +0100
Dear Nathan,
Thanks for your kind word. I don't mind to send the code. I wanted to
avoid it to be too long.
In the previous page (ListPage), the aBizAction binded to an item of
WORepection was thrown with
nextPage.setABizAction(aBizAction);. (aBizAction is also available in
the previous Page).
bizAction (entity) has relationship called "expences (too many)" which
is expence entity.
In the WO Builder page of this DetailPage has aBizAction (entities are
binded to WOText fields) with
a WORepetition whose list is aBizAction.expences and whose item is
aExpence.
The method for sorting is called when the page is called as you can see
below.
public class DetailPage extends WOComponent {
protected expence aExpence;
protected bizAction aBizAction;
protected bizAction bBizAction;
protected expence bExpence;
public NSArray sortResult;
public DetailPage(WOContext context) {
super(context);
//sortExpences();
//System.out.println(aBizAction.actionTitle()); <- this also
gets the error.
}
public expence aExpence() {
return aExpence;
}
public void setAExpence(expence newAExpence) {
aExpence = newAExpence;
}
public bizAction aBizAction() {
return aBizAction;
}
public void setABizAction(bizAction newABizAction) {
aBizAction = newABizAction;
}
public ListPage actList() {
ListPage nextPage = (ListPage)pageWithName("ListPage");
// Initialize your component here
return nextPage;
}
public InputPage actNew() {
InputPage nextPage = (InputPage)pageWithName("InputPage");
bBizAction = new bizAction();
EOEditingContext ec = this.session().defaultEditingContext();
ec.insertObject((bizAction)bBizAction);
nextPage.setABizAction(bBizAction);
return nextPage;
}
public ListPage actDelete() {
ListPage nextPage = (ListPage)pageWithName("ListPage");
session().defaultEditingContext().deleteObject(aBizAction);
session().defaultEditingContext().saveChanges();
return null;
}
public InputPage actEdit() {
InputPage nextPage = (InputPage)pageWithName("InputPage");
session().defaultEditingContext().revert();
nextPage.setABizAction(aBizAction);
return nextPage;
}
public InputExpencePage actAddExpence() {
InputExpencePage nextPage =
(InputExpencePage)pageWithName("InputExpencePage");
session().defaultEditingContext().revert();
bExpence = new expence();
EOEditingContext ec = this.session().defaultEditingContext();
ec.insertObject((expence)bExpence);
nextPage.setAExpence(bExpence);
nextPage.setABizAction(aBizAction);
return nextPage;
}
public void sortExpences() {
NSArray ep = new NSArray();
ep = aBizAction.expences();
EOSortOrdering so1 =
EOSortOrdering.sortOrderingWithKey("ep_date",
EOSortOrdering.CompareAscending);
EOSortOrdering so2 =
EOSortOrdering.sortOrderingWithKey("ep_Category",
EOSortOrdering.CompareAscending);
NSArray soList = new NSArray(new Object[]{so1, so2});
sortResult = EOSortOrdering.sortedArrayUsingKeyOrderArray(ep,
soList);
}
}
On 21 Jul 2004, at 23:48, Nathan Dumar wrote:
A.,
On Jul 21, 2004, at 5:34 PM, A. Uchida wrote:
Thanks for your comment.
I tried it in my code but any attributes get NullPointerException.
This might mean the values are not successfully passed.
But when I disabled the System.out.println ...... from my code
all the proper recodes are shown in the next page.
I don't understand what you mean by this.
What I used for passing the records are nextPage.setAKeyOfEntity(aKey)
method in the previous page, which WebObject Builder automatically
generated,
just before calling the nextPage.
How should I pass the records to allow sorting?
You said that you're using a display group, and those can be pretty
tricky. It may be that you're passing correctly, but the value that
you're passing is a null value. Would you mind posting all of the
code for the two components? If you don't want to post it publicly,
you can just send to me.
Nathan
_______________________________________________
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.
_______________________________________________
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.