Re: Help! Have array of EOs. Need convert to CSV (selected key paths)

2014-12-14 Thread Robert B. Hanviriyapunt
Just to give a more complete description of what I implemented:



Unless anyone knows that something already does this (something useful to add 
to the frameworks someday?).

--
Robert B. Hanviriyapunt

On Dec 14, 2014, at 2:28 PM, Robert B. Hanviriyapunt  
wrote:

> That's funny. After I sent my help message I just thought about it some and I 
> ended up doing exactly as you mentioned. I found the headers settings 
> somewhere and follow that as well.  I also felt something in wonder to quote 
> values as necessary for excel friendly CSV files.
> 
> Sometimes I freak out too early and send a help message and then find my 
> answers right after on my own.
> 
> Sent from my iPhone
> 
>> On Dec 14, 2014, at 9:41 AM, CHRISTOPH WICK | i4innovation GmbH, Bonn 
>>  wrote:
>> 
>> Hi Robert,
>> 
>> Maybe this helps:
>> 
>> 1. create a ordinary WOComponent, e.g. MyCSVComponent.wo 
>> 
>> In the HTML part, you don't write HTML (skip the whole " ... 
>> " stuff), but the CSV content you need:
>> 
>> 
>> "", "> value="$myItem.property2" />" ...
>> 
>> 
>> 2. in MyCSVComponent.java you override the method "appendToResponse" like 
>> this:
>> 
>> public class MyCSVComponent extends ERXComponent {
>> 
>>   public String fileName;
>>   public NSArray myList;
>>   public MyObject item;
>> 
>>   // override appendToResponse to let the browser make a download, 
>>   // instead of displaying the result in a brwoser window
>>   public void appendToResponse(WOResponse response, WOContext context) {
>>   // set the mimetype to csv
>>   response.setHeader("text/comma-separated-values", "content-type");
>>   // tell the browser to download the file instead of showing it in a 
>> window
>>   response.setHeader("attachment; filename=\""+fileName+"\"", 
>> "Content-Disposition");
>> 
>>   // create the response
>>   super.appendToResponse(response, context);
>>   }
>> }
>> 
>> where "fileName" is the name of the file you will give the download.
>> 
>> In your master page, create a link like this:
>> 
>> download CSV
>> 
>> and in the Java-Code of your master page
>> 
>>   public WOActionResults downloadCSVAction() {
>>   MyCSVComponent nextPage = (MyCSVComponent) 
>> pageWithName(MyCSVComponent.class);
>>   nextPage.myList = ... // set the list to an NSArray of whatever you 
>> need
>>   nextPage.fileName = ... // set the fileName to whatever you need
>>   return nextPage;
>>   }
>> 
>> 
>> Does this answer your question?
>> 
>> C.U.CW
>> -- 
>> The three great virtues of a programmer are Laziness, Impatience and Hubris. 
>> (Randal Schwartz)
>> 
>>> On 13.12.2014, at 21:59, Robert B. Hanviriyapunt  
>>> wrote:
>>> 
>>> Help!  I need some advise on how to EASILY accomplish the following:
>>> 
>>> have array of ERXKey(Path)s for columns to report
>>> have array of EOs
>>> must make wo:link's action respond with CSV (browser to download, not 
>>> display in browser)
>>> 
>>> what is the easiest way (i’m hoping it’s not D2W unless it make it really 
>>> easier)
>>> 
>>> please a quick demo solution somewhere would be awesome!
>>> 
>>> = Robert =
>>> ___
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/cw%40i4innovation.de
>>> 
>>> This email sent to c...@i4innovation.de
>> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Help! Have array of EOs. Need convert to CSV (selected key paths)

2014-12-14 Thread Robert B. Hanviriyapunt
That's funny. After I sent my help message I just thought about it some and I 
ended up doing exactly as you mentioned. I found the headers settings somewhere 
and follow that as well.  I also felt something in wonder to quote values as 
necessary for excel friendly CSV files.

Sometimes I freak out too early and send a help message and then find my 
answers right after on my own.

Sent from my iPhone

> On Dec 14, 2014, at 9:41 AM, CHRISTOPH WICK | i4innovation GmbH, Bonn 
>  wrote:
> 
> Hi Robert,
> 
> Maybe this helps:
> 
> 1. create a ordinary WOComponent, e.g. MyCSVComponent.wo 
> 
> In the HTML part, you don't write HTML (skip the whole " ... 
> " stuff), but the CSV content you need:
> 
> 
> "", " value="$myItem.property2" />" ...
> 
> 
> 2. in MyCSVComponent.java you override the method "appendToResponse" like 
> this:
> 
> public class MyCSVComponent extends ERXComponent {
> 
>public String fileName;
>public NSArray myList;
>public MyObject item;
> 
>// override appendToResponse to let the browser make a download, 
>// instead of displaying the result in a brwoser window
>public void appendToResponse(WOResponse response, WOContext context) {
>// set the mimetype to csv
>response.setHeader("text/comma-separated-values", "content-type");
>// tell the browser to download the file instead of showing it in a 
> window
>response.setHeader("attachment; filename=\""+fileName+"\"", 
> "Content-Disposition");
>
>// create the response
>super.appendToResponse(response, context);
>}
> }
> 
> where "fileName" is the name of the file you will give the download.
> 
> In your master page, create a link like this:
> 
> download CSV
> 
> and in the Java-Code of your master page
> 
>public WOActionResults downloadCSVAction() {
>MyCSVComponent nextPage = (MyCSVComponent) 
> pageWithName(MyCSVComponent.class);
>nextPage.myList = ... // set the list to an NSArray of whatever you 
> need
>nextPage.fileName = ... // set the fileName to whatever you need
>return nextPage;
>}
> 
> 
> Does this answer your question?
> 
> C.U.CW
> -- 
> The three great virtues of a programmer are Laziness, Impatience and Hubris. 
> (Randal Schwartz)
> 
>> On 13.12.2014, at 21:59, Robert B. Hanviriyapunt  
>> wrote:
>> 
>> Help!  I need some advise on how to EASILY accomplish the following:
>> 
>> have array of ERXKey(Path)s for columns to report
>> have array of EOs
>> must make wo:link's action respond with CSV (browser to download, not 
>> display in browser)
>> 
>> what is the easiest way (i’m hoping it’s not D2W unless it make it really 
>> easier)
>> 
>> please a quick demo solution somewhere would be awesome!
>> 
>> = Robert =
>> ___
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/cw%40i4innovation.de
>> 
>> This email sent to c...@i4innovation.de
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Help! Have array of EOs. Need convert to CSV (selected key paths)

2014-12-14 Thread CHRISTOPH WICK | i4innovation GmbH, Bonn
Hi Robert,

Maybe this helps:

1. create a ordinary WOComponent, e.g. MyCSVComponent.wo 

In the HTML part, you don't write HTML (skip the whole " ... 
" stuff), but the CSV content you need:


"", "" ...


2. in MyCSVComponent.java you override the method "appendToResponse" like this:

public class MyCSVComponent extends ERXComponent {

public String fileName;
public NSArray myList;
public MyObject item;

// override appendToResponse to let the browser make a download, 
// instead of displaying the result in a brwoser window
public void appendToResponse(WOResponse response, WOContext context) {
// set the mimetype to csv
response.setHeader("text/comma-separated-values", 
"content-type");
// tell the browser to download the file instead of showing it 
in a window
response.setHeader("attachment; filename=\""+fileName+"\"", 
"Content-Disposition");

// create the response
super.appendToResponse(response, context);
}
}

where "fileName" is the name of the file you will give the download.

In your master page, create a link like this:

download CSV

and in the Java-Code of your master page

public WOActionResults downloadCSVAction() {
MyCSVComponent nextPage = (MyCSVComponent) 
pageWithName(MyCSVComponent.class);
nextPage.myList = ... // set the list to an NSArray of whatever 
you need
nextPage.fileName = ... // set the fileName to whatever you need
return nextPage;
}


Does this answer your question?

C.U.CW
-- 
The three great virtues of a programmer are Laziness, Impatience and Hubris. 
(Randal Schwartz)

On 13.12.2014, at 21:59, Robert B. Hanviriyapunt  
wrote:

> Help!  I need some advise on how to EASILY accomplish the following:
> 
> have array of ERXKey(Path)s for columns to report
> have array of EOs
> must make wo:link's action respond with CSV (browser to download, not display 
> in browser)
> 
> what is the easiest way (i’m hoping it’s not D2W unless it make it really 
> easier)
> 
> please a quick demo solution somewhere would be awesome!
> 
> = Robert =
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/cw%40i4innovation.de
> 
> This email sent to c...@i4innovation.de



smime.p7s
Description: S/MIME cryptographic signature
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Help! Have array of EOs. Need convert to CSV (selected key paths)

2014-12-13 Thread Robert B. Hanviriyapunt
Help!  I need some advise on how to EASILY accomplish the following:

have array of ERXKey(Path)s for columns to report
have array of EOs
must make wo:link's action respond with CSV (browser to download, not display 
in browser)

what is the easiest way (i’m hoping it’s not D2W unless it make it really 
easier)

please a quick demo solution somewhere would be awesome!

= Robert =
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com