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 protected])
>>>> Help/Unsubscribe/Update your Subscription:
>>>> http://lists.apple.com/mailman/options/webobjects-dev/programmingosx%40mac.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/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/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to