Re: D2W Question
Re: D2W Question
- Subject: Re: D2W Question
- From: Jesse Tayler <email@hidden>
- Date: Sat, 05 Mar 2011 11:24:08 -0500
Did you turn up the priority?
Oh, wait - you load in your D2W context from another page?
It's going to have that "sender" page's configuration, right? Is that what you want/expect?
I _think_ if you want a new D2WContext that is fired to the page and configuration you are currently on, then you want to ask for localContext or something? Or maybe just setEntity or setPageConfiguration to ensure your D2W context is firing the rules you expect?
Just grazin' your code and that question came to mind...maybe someone else knows better.
jess
On Mar 5, 2011, at 9:20 AM, Markus Ruggiero wrote:
> Something is really fishy here. Your explanation is clear and I think I really understand now what needs to be done. But my App does not.... There is simply nothing happening. Enabling rule tracing shows that the following rule does not fire:
>
> {
> author = 100;
> class = "com.webobjects.directtoweb.Rule";
> lhs = {
> class = "com.webobjects.eocontrol.EOAndQualifier";
> qualifiers = (
> {
> class = "com.webobjects.eocontrol.EOKeyValueQualifier";
> key = task;
> selectorName = isEqualTo;
> value = list;
> },
> {
> class = "com.webobjects.eocontrol.EOKeyValueQualifier";
> key = "entity.name";
> selectorName = isEqualTo;
> value = Textblock;
> }
> );
> };
> rhs = {
> class = "er.directtoweb.ERDDelayedObjectCreationAssignment";
> keyPath = pageController;
> value = TextblockListController;
> };
> }
>
> I have created a java class as follows:
>
> package com.xxx.admin;
>
> import com.xxx.admin.components.TextblockExcel;
> import com.webobjects.appserver.WOActionResults;
> import com.webobjects.appserver.WOComponent;
> import com.webobjects.directtoweb.*;
> import com.webobjects.eocontrol.EOEnterpriseObject;
>
> import er.directtoweb.delegates.ERDBranchDelegate;
> import er.directtoweb.pages.ERD2WListPage;
>
> public class TextblockListController extends ERDBranchDelegate {
>
> private WOComponent sender;
>
> // "Export To Excel"
> public WOActionResults exportToExcel(WOComponent sender) {
> setSender(sender);
> ListPageInterface lpi = (ListPageInterface) D2W.factory().pageForConfigurationNamed(TextblockExcel.class.getName(), sender().session());
> lpi.setDataSource(((ERD2WListPage) ERD2WUtilities.parentListPage(sender)).dataSource());
> lpi.setNextPage(sender());
> return (WOActionResults) lpi;
> }
>
> private WOComponent sender() {
> return sender;
> }
>
> private void setSender(WOComponent aSender) {
> sender = aSender;
> }
>
> private D2WContext d2wContext() {
> return (D2WContext) sender().valueForKey("d2wContext");
> }
>
> private EOEnterpriseObject object() {
> return (EOEnterpriseObject) d2wContext().valueForKey("object");
> }
>
> }
>
>
> I also have created an (empty) WOComponent "TextblockExcel.wo". I think that the rule should fire when I do a Textblock query, should it not? It does not and when I inspect the key pageController in the Wonder D2W debugger inside the running app there is no value assigned. Other keys like task or entity.name show values. To me it looks as if the application never even tries to find a pageController via. Why would that be? I then took my EOModel and created a new out-of-the-box ERD2WApplication and added just this key to the rule file. Even if the controller class does not exist, the app is supposed to at least fire the rule. The app might crash afterwards because the destination of the rule cannot be instantiated but not even this happens :-(.
>
> What could be wrong here? I feel so stupid and maybe I am but...
>
> Thanks for any ideas
> ---markus---
>
> On 04.03.2011, at 15:50, David Avendasora wrote:
>
>> Hi Markus,
>>
>> Keep the replies on the list - It helps everyone that way and others can point out any mistakes I make (yes, hello Anjo. I know you love to read my posts). :-)
>>
>> Here's my related code:
>>
>> 1) I have created a pageController for listing objects for my Entity "CCCommunicationIdentity" as documented here: http://webobjects.mdimension.com/hudson/job/Wonder54/javadoc/er/directtoweb/pages/ERD2WPage.html#pageController(). It is called ListCCCommunicationIdentityController.java
>>
>> 2) I added the following method to the controller class:
>> // "Export To Excel"
>> public WOActionResults exportToExcel(WOComponent sender) {
>> setSender(sender);
>> ListPageInterface lpi = (ListPageInterface) D2W.factory().pageForConfigurationNamed("ListExcelCCCommunicationIdentity", sender().session());
>> lpi.setDataSource(((ERD2WListPage) ERD2WUtilities.parentListPage(sender)).dataSource());
>> lpi.setNextPage(sender());
>> return (WOActionResults) lpi;
>> }
>>
>> 3) I added just the following two rules to the d2w.d2wmodel file to get the page-level button instead of a item-level button:
>> 100 : propertyKey = 'controllerAction' => componentName = ERDControllerButton [com.webobjects.directtoweb.Assignment]
>> 100 : (entity.name = 'CCCommunicationIdentity' and task = 'list') => pageController = com.my.app.ui.controllers.ListCCCommunicationIdentityController [er.directtoweb.ERDDelayedObjectCreationAssignment]
>>
>> 4) I added the following rules to define columns included in the Excel document, as they are different from the ones in the HTML page.
>> 100 : pageConfiguration = 'ListExcelCCCommunicationIdentity' => displayPropertyKeys = ( "firstAttribute", "anotherAttribute", "yetAnotherAttribute", "etc", "etc", "etc") [com.webobjects.directtoweb.Assignment]
>>
>> You will see that the call to pageForConfigurationNamed method in the Controller method above is the same as the pageConfiguration in this rule, i.e. "ListExcelCCCommunicationIdentity".
>>
>> I believe that's it.
>>
>> Basically here's the flow:
>> 1) The first rule tells the listing page for my Entity to show the page-level controller button
>> 2) The second rule associates my controller class with the listing page. D2W automatically populates the controllerAction popup button (via Java reflection) with all the public methods in the Controller class that return a WOActionResults object.
>> 3) The exportToExcel method in the controller tells D2W to create a new listing page for the Entity that is, in fact, an Excel file (instead of an HTML file).
>> 4) The last rule tells D2W what columns to include in the Excel file.
>>
>> With WebObjects, there are usually 4 or 5 ways to skin a cat. This is just one. Dave Holt has another way and I'm guessing Dave LeBer has yet another, and that probably still wouldn't be all the ways to do what you are asking. This method gets you a pop-up with the actions that can be taken by the controller. If you want actual individual buttons, then I believe the ERDActionBar is what you're going to want instead.\
>>
>> Dave
>>
>>
>> On Mar 4, 2011, at 7:50 AM, Markus Ruggiero wrote:
>>
>>> Hi David,
>>>
>>> After going through the mentioned wiki pages I am kind of more confused than before.... :-(
>>>
>>> If you could share the necessary rules and code pieces that would be really great for a start. I have been doing D2W quite a bit some years ago, before the Project Wonder days. The current project I am working on is a legacy thing that I have taken over to expand. The folks that have initially implemented the code did know a lot about java but had basically no clue about WO and D2W. So I have to find my way not only through ERD2W... but I also have to figure what and why something has been done the way it is. The programmers have already implemented the required functionality in some list pages by freezing an entity specific list page component and manually adding a hyperlink [download excel] between the list and the return-button.
>>
>>> On 02.03.2011, at 16:39, David Avendasora wrote:
>>>
>>>> Hi Markus,
>>>>
>>>> I've actually implemented exactly what you are asking for and it works great and is fully controlled by the rules engine.
>>>>
>>>> I've not looked into David(H)'s recommendation of ERDActionBar, but I've used the ERDBranchDelegate and ERDControllerButton solution outlined on the Wiki here: http://wiki.objectstyle.org/confluence/display/WO/D2W+Flow+Control.
>>>>
>>>> I get one drop-down on the page from which I can select Export To Excel to export the entire result set (not just the currently visible batch) into an excel file. The columns, column names, etc. included in the Excel file are completely independent of what is shown on the page and are controlled by a D2W rules just like the page is.
>>>>
>>>> Dave
>>>>
>>>>
>>>> On Mar 2, 2011, at 10:12 AM, David Holt wrote:
>>>>
>>>>> Hi Markus,
>>>>>
>>>>> You need to use the ERDActionBar. Jesse's method is a possibility but it will put the link in every row in the list. The ActionBar will allow you to put it in the topActions or bottomActions block. There is a wiki page that talks about PageFlow in D2W. You should find everything you need there. ModernLook definitely supports this, and I assume that NeutralLook does as well. I'll be at work shortly if you need more assistance with getting it going.
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>> On 2011-03-02, at 3:53 AM, Markus Ruggiero wrote:
>>>>>
>>>>>> Hi WO Developers, I need help with D2W,
>>>>>>
>>>>>> I want to provide a "Download as Excel" link on each list page. What is the best way to accomplish this? I know I can freeze a list page and modify it but this decouples me from the rule system. This is a plain out-of-the-box WonderD2W app.
>>>>>>
>>>>>> Thanks a lot
>>>>>> ---markus---
>>>>>>
>>>>>> PS: I am still very confused by the lack of documentation (or my not being able to find it). I do have the source to the Wonder Frameworks but even with that finding what I want to know is more or less like shooting with a shotgun into a large forest and hoping to hit something edible...
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
> _______________________________________________
> 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
>
_______________________________________________
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