On Oct 11, 2010, at 4:48 PM, Ramsey Gurley wrote:
>
> On Oct 11, 2010, at 4:28 PM, David Avendasora wrote:
>
>> Hey Ramsey,
>>
>> I'm using the branch delegate in other places where the user is given a
>> choice of what the next page should be, but I thought that since I'm
>> figuring it out on-the-fly during the request that nextPageDelegate was the
>> way to go. I've revised my NPD and here's what it looks like now:
>>
>> public WOComponent nextPage(WOComponent sender) {
>> WOComponent nextPage;
>> if (((ERD2WQueryPage) sender).queryDataSource()
>> .fetchObjects()
>> .count() == 1) {
>> InspectPageInterface ipi =
>> D2W.factory().inspectPageForEntityNamed(Student.ENTITY_NAME,
>> sender.session());
>> ((ERD2WInspectPage) ipi).setObject((Student) ((ERD2WQueryPage)
>> sender).queryDataSource().fetchObjects().lastObject());
>
> You may want to consider getting your object first, then using
> object.entityName() in your factory method to make this more generally
> reusable.
See, now that's just genius. This can be a delegate that works for any EO, not
just Student. Brilliant!
>> nextPage = (WOComponent) ipi;
>> } else {
>> nextPage = ((ERD2WQueryPage) sender).nextPage();
>
> Does that last line work? I would have thought the logic in your original
> would be required.
Yep! Works great. :-) When I wrote it I was worried that it would end up in an
endless loop with sender.nextPage() simply calling this delegate, but it works
perfectly. Maybe I'm just lucky.
Dave
>
> Ramsey
>
>> }
>> return nextPage;
>> }
>>
>>
>> Dave
>>
>> On Oct 11, 2010, at 9:55 AM, Ramsey Gurley wrote:
>>
>>> Looks good to me Dave. I think any "better" way than something that works
>>> will be a matter of opinion (^_^) Personally I like branch delegates, but
>>> in this case, the next page delegate is only called by the queryAction. So
>>> you know the call to next page comes from the find button.
>>>
>>> Ramsey
>>>
>>> On Oct 11, 2010, at 6:57 AM, David Avendasora wrote:
>>>
>>>> Okay, after a nights sleep, I got it working, but how I did it seems
>>>> hackish (shocking, I know). Is the nextPage() method below from my
>>>> delegate the best way to do this?
>>>>
>>>> public WOComponent nextPage(WOComponent sender) {
>>>> WOComponent nextPage;
>>>> if (((ERD2WQueryPage) sender).queryDataSource()
>>>> .fetchObjects()
>>>> .count() == 1) {
>>>> InspectPageInterface ipi = D2W.factory()
>>>>
>>>> .inspectPageForEntityNamed(Student.ENTITY_NAME,
>>>>
>>>> sender.session());
>>>> ((ERD2WInspectPage) ipi).setObject((EOEnterpriseObject)
>>>> ((ERD2WQueryPage) sender).queryDataSource()
>>>>
>>>> .fetchObjects()
>>>>
>>>> .lastObject());
>>>> nextPage = (WOComponent) ipi;
>>>> } else {
>>>> ListPageInterface lpi = D2W.factory()
>>>>
>>>> .listPageForEntityNamed(Student.ENTITY_NAME,
>>>>
>>>> sender.session());
>>>> ((ERD2WListPage) lpi).setDataSource(((ERD2WQueryPage)
>>>> sender).queryDataSource());
>>>> nextPage = (WOComponent) lpi;
>>>>
>>>> }
>>>> return nextPage;
>>>> }
>>>>
>>>> On Oct 10, 2010, at 8:39 PM, David Avendasora wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> When a user performs a query, if the results contain exactly one object I
>>>>> want to return an Inspect page for that object instead of a List page.
>>>>>
>>>>> I assume I'm going to want to implement a NextPageDelegate, but I'm not
>>>>> sure how to do that. I've looked around but I can't seem to find a good
>>>>> example. Does anyone have an example NextPageDelegate that I can use as a
>>>>> starting point?
>>>>>
>>>>> I promise to create a Wiki page documenting how to do this for future mes.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> Dave _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Webobjects-dev mailing list ([email protected])
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com
>>>>>
>>>>> This email sent to [email protected]
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list ([email protected])
>>>> Help/Unsubscribe/Update your Subscription:
>>>> http://lists.apple.com/mailman/options/webobjects-dev/ramsey%40xeotech.com
>>>>
>>>> This email sent to [email protected]
>>>>
>>>
>>>
>>>
>>
>>
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]