Hitachi Vantara Pentaho Community Forums
Results 1 to 26 of 26

Thread: when saving a report as a different output type.

  1. #1
    Join Date
    Mar 2006
    Posts
    683

    Default when saving a report as a different output type.

    I have been able to get the whole changing reports based on user input for the different formats that it can display in. the thing that I have noticed though is that when you select a type such as xls and it promts you for a "save as" common dialog box the file name is "viewaction"

    My question is there a way to set the output file name so that the user doesn't have to rename the file? I'm assuming there is I just haven't discovered it.

    Thanks,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  2. #2
    Join Date
    Jan 2006
    Posts
    460

    Default Re:when saving a report as a different output type

    There isn't any way of doing that that I know of, the reason the report is called "ViewAction" is because that's the name of the servlet (or JSP) that's dishing out the content (there is no filename).

    In some cases we're not even writing the report to disk (temp) it is streamed directly back to the browser. I believe we should be able to 'trick' the output to the browser to have any name we want. But this requires code, so it's not something trivial like a simple setting in an action-sequence.

    -Mike

  3. #3
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Oh I see, so it'll be complicated. I was hoping I could just pass a special input into the action component and it would already have the functionality in it like most of the things I have alreadys tried to do have already been there. This is such a great product and is constintly evouling.

    I figured it would get the "ViewAction" from the first part of the URL of the address after the last // so a url rewright might trick it I would guess.

    Thanks for the reply. Atleast now I'll be able to explain to the users why it's that way.

    Thanks agian,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  4. #4
    Join Date
    Jan 2006
    Posts
    460

    Default Re:when saving a report as a different output type

    Nic-

    I've done some further investigation deeper into the platform and all you need to do is specify "mimefile=whatever.pdf" on the request. I've done some tinkering and I modified the JFreeReportComponent to use a mimefile parameter, so you can drive the value from an action-sequence. I'm probably not going to check this in yet, I want to implement this higher up in the component stack.

    Is using the request currently enough for your needs, or will you require this to be driven by action-sequence parameters?

    Thanks,
    -Mike

  5. #5
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Mike,

    Thanks for looking into this farther I really appricate it.

    So if I understand you correctly I can let's say use a JavaScriptCompent to concatinate some strings together and return and output that's mapped to minefile and then have an action-input for the JFreeReportCompent of minefile, which will cause the file name in the "Save as" common dialog to be the value of the minefile action-input for the JFreeReportCompent?

    If so then yes that will work well enough for me, currently.

    Thanks agian,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  6. #6
    Join Date
    Jan 2006
    Posts
    460

    Default Re:when saving a report as a different output type

    Yes that should work beautifully. Great idea.

    -Mike

  7. #7
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Thanks agian for thinking and working on this idea, Mike.

    I do have one question left regarding this. and that is when about will it be "checked in"? will it be avalible in the next SDK release, which seems to be released the most often or will it be down the road in the next milestone release?

    I feel this will be one of the first things that I'll get negitive feed back on when the Beta is released this week mostlikely Tuesday afternoon Indiana time.

    But either way you have given me the info so that I can say

    "Yes I'm aware of this and working with the pentaho team to get this resolved, which they already have a solution that needs to be forther tested before it's commited"

    This shows good peremtive messures and makes us all look good.

    Thanks agian Mike and the rest of the team for making such a Kick a$$ solution,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  8. #8
    Join Date
    Jan 2006
    Posts
    460

    Default Re:when saving a report as a different output type

    You're welcome!

    Is the JavaScriptRule a legitimate workaround for you to append the mimefile name?

    If not let me know and I'll try to get this to a state I'm happy with ASAP, I put it on the back burner since I felt we could get around the issue.

    Thanks,
    Mike

  9. #9
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Mike,

    So the minefile variable is already supported? for interaction between actions in an action sequence? i was confused, it sounded like it wasn't support yet.

    Yeah the javascriptrule workaround will be fine, I'll try it out shortly.

    That way I can findout if it works currently and I'll even grab the newest sdk and try it out in that. if it doesn't work.

    Thanks agian,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  10. #10
    Join Date
    Jan 2006
    Posts
    460

    Default Re:when saving a report as a different output type

    Yes, it absolutely should work right now! Simply add a parameter called "mimefile" to the url and set it to what you would like the content filename to be called instead of "ViewAction".

    If you want to test it out just hit one of the reports in the PCI demo and then change the URL to have a "&mimefile=MyFile.pdf" for example.

    Combining this with a JavaScriptRule you'll have all the tools needed to make it dynamic (within reason)..

    -Mike

  11. #11
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    I think I'm missing something small.

    B/c I can just as the mike mentioned add the &minefile=my.pdf and it works. but with my modified cust-param-page-example2 it's not seeing it for some reason. I have attached my modified.

    I just added some javescript mainly.

    Any suggestions?

    Thanks,

    Nic http://forums.pentaho.org/archived_a.../modifiedr.zip
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  12. #12
    Join Date
    Jan 2006
    Posts
    460

    Default Re:when saving a report as a different output type

    The parameter-template that this action-sequence uses doesn't know what to do with mimefile, so that is one issue.

    Another issue is that the parameter is called "mimefile" not "minefile" (although technically it is 'yourfile').

    Additionally the output-type parameter is not passed to the JFreeReportComponent.

    Enjoy the fixed version that doesn't even require a JavaScriptRule.

    -Mike

  13. #13
    Join Date
    Jan 2006
    Posts
    460

    Default Re:when saving a report as a different output type

    The parameter-template that this action-sequence uses doesn't know what to do with mimefile, so that is one issue.

    Another issue is that the parameter is called "mimefile" not "minefile" (although technically it is 'yourfile').

    Additionally the output-type parameter is not passed to the JFreeReportComponent.

    Enjoy the fixed version that doesn't even require a JavaScriptRule.

    -Mike http://forums.pentaho.org/archived_a...mefile.xaction

    Post edited by: mdamour, at: 05/30/2006 13:32

  14. #14
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Thanks Mike,

    Boy how I hate being dyslexic. Which some of you may have noticed in my posts.

    I'll check it out.

    This isn't the first time my spelling has been a stupid mistake.

    Thanks agian,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  15. #15
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Boy I hate to revisit this topic but for some reason I'm having troubles getting my dynamic file names working after the code upgrade.

    However I can add javascript to the parameter-template to append "&mimefile=asdf.pdf" and it shows up as expected. but that really doesn't do me a whole lot of good since the first part of the file names are going to change per each report. and I'm really not wanting to maintain 50 parameter-templates if at all possible.

    I have also tried the xaction that Mike posted back when we were talking about this issue I'm having agian and it doesn't appear to be working either. The "Save As" box shows up and it's got the good old ViewAction.

    I have noticed that the ViewAction does have the mimefile stuff in there right after the mimetype. but the report component, org.pentaho.plugin.jfreereport.JfreeReportComponent.java does not have anything to do with mimefile and that's what my action output of my JS rule is handing the mimefile too as an action input.

    Perhaps there was a bit of a communication brake down with me and mike a couple weeks ago. My understanding was that the mimefile var could be controlled in the xaction on in the parameter-template.

    I guess I just want to have a parameter-template that will work for more than one report that will get user input and pass it to the xaction, which appears to be working, but then I want to use a js rule in the action sequence to do something like this
    Code:
    <action-definition> 
          <action-inputs> 
            <EndMonth type="string"/>  
            <StartDay type="string"/>  
            <EndMinute type="string"/>  
            <StartHour type="string"/>  
            <EndHour type="string"/>  
            <EndYear type="string"/>  
            <StartYear type="string"/>  
            <StartMinute type="string"/>  
            <EndDay type="string"/>  
            <StartMonth type="string"/>  
            <type type="string" mapping="type-out"/>  
            <GroupBy type="string"/> 
          </action-inputs>  
          <component-name>org.pentaho.plugin.javascript.JavascriptRule</component-name>  
          <action-type>Generatemimefile</action-type>  
          <action-outputs> 
            <mimefile type="string"/> 
          </action-outputs>  
          <component-definition>
            <script><![CDATA[function getDynName() {
    		var filename;
    		filename = "RevenueSummary_Rev_Sum_w-o_recharges_"+StartMonth+"-"+StartDay+"-"+StartYear+"-"+StartHour+":"+StartMinute+"_TO_"+EndMonth+"-"+EndDay+"-"+EndYear+"-"+EndHour+":"+EndMinute+"."+type;
    		return filename;
    	}
    	getDynName();]]></script>
          </component-definition>
        </action-definition>
    then map the output to mimefile and then have the report compent or which ever compent takes that in and spit out a file with that mimefile name. Which is a similar idea to the resource-name concept to tell it which report-def to use.

    So far it only looks like you can set the mimefile name in the parameter-template so that'll mean the end user will have to set it and I would reather controll what name it gets download with for less confusion.

    Also if the input for the mimefile is on the parameter-template then you can't even view the report in the browser unless you save it first. or the end user could type in asdf.pdf and select xls as the output-type.

    So I.M.O. it's looking for and using the mimefile too early which appears to be at the beginning of the xaction sequence right after the parameter-template hands back results.

    I'm hoping I'm making sense since I'm also trying different things to while typing this.

    Thanks,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  16. #16
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    perhaps I jumped to consultions w/o a matt.

    but either way I did a Write Parameter component to see if it was actually getting through the java script and it was exectly how I wanted it formated and displayed, but when I added back in the report and viewed it in html the approperate mimefile was displaced at the end of the doc. as this
    RevenueSummary_Rev_Sum_w-o_recharges_01-01-2006-00:00_TO_01-01-2006-23:59.html
    and it's being stored in mimefile
    and the jfreeReport Component has an action input of mimefile.
    here is the code for the write parameter
    Code:
    <action-definition>
          <component-name>ContentOutputComponent</component-name>
          <component-definition>
            <mime-type>text/html</mime-type>
          </component-definition>
          <action-type>Write Parameter</action-type>
          <action-inputs>
            <CONTENTOUTPUT type="string" mapping="mimefile"/>
          </action-inputs>
        </action-definition>
    as you can see in the code jfreereport component it is taking in a mimefile parameter
    Code:
        </action-definition>  
           <action-definition> 
          <component-name>org.pentaho.plugin.jfreereport.JFreeReportComponent</component-name>  
          <action-type>report</action-type>  
          <action-inputs> 
            <EndMonth type="string"/>  
            <StartDay type="string"/>  
            <EndMinute type="string"/>  
            <StartHour type="string"/>  
            <mimefile type="string"/>  
            <EndHour type="string"/>  
            <EndYear type="string"/>  
            <StartYear type="string"/>  
            <StartMinute type="string"/>  
            <EndDay type="string"/>  
            <StartMonth type="string"/>  
            <resource-name type="string"/>  
            <type-out type="string"/>  
            <output-type type="string" mapping="type-out"/>  
            <GroupBy type="string"/> 
          </action-inputs>  
          <component-definition> 
            <source>sql</source>  
            <live>false</live>  
            <jndi>MySqlDS</jndi>  
            <xsl>parameter-template</xsl>  
            <query><![CDATA[Select Store_Description, sp.Category_Description as Category, nullif(Subscription,"Not Subscriptions"«») as "Subscription", SQL_Date_Stamp, tod.Time as Time, format(sum(Sales_Dollar_amount),2) as "Totel Sold"
    From Daily_Sales_Facts as DSF,  Date_of_Sale as dos, Time_of_Day as tod, Sales_Product as sp, Sales_Store as ss
    where 1=1
    and dos.Date_Key = DSF.Date_FK 
    and tod.Time_of_Day_Key=DSF.Time_of_Day_FK
    and DSF.Store_FK = ss.Store_Key 
    and DSF.Product_FK = sp.Product_Key
    and DSF.Recharge_Indicator="Not Recharged"
    and dos.SQL_Date_Stamp between  "{StartYear}-{StartMonth}-{StartDay}" and "{EndYear}-{EndMonth}-{EndDay}" 
    and tod.Time between "{StartHour}:{StartMinute}" and "{EndHour}:{EndMinute}"
    group by sp.Category_Description, Subscription, DSF.Store_FK, {GroupBy} 
    order by SQL_Date_Stamp, Time, DSF.Store_FK, sp.Category_Description, Subscription]]></query> 
          </component-definition> 
        </action-definition>
    verything works as to be expected except for the mimefile that gets output from the JS rule above.

    any suggestion would be appricated.

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  17. #17
    dmoran Guest

    Default Re:when saving a report as a different output type

    Nic,

    Have you gotten past this yet? I would like to help but I am confused as to what you are trying to do. I have made some changes to the template component and the output parameter processing that may help you.

    Doug

  18. #18
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Hey Doug,

    Thanks for the reply.

    but pretty much what I'm trying to is to prompt the use for a date range, time range, group by field, and an output type. then name a the file as that plus some other name associated with the file.

    so I would get something like StartMonth, StartDay, StartYear, StartHouse, StartMinute and the same withe EndMonth, EndDay.. etc
    group by Days
    and out put xls.

    so those would be what the user inputs.
    and which currently pop up a save as common dailog box for a save location but the name that's in there is ViewAction.

    I just want to add ReportSummaryName+varables.output type to appear in the save as box that way the user doesn't have to enter it in when they go to save it.

    Currently I can do some javascript in the parameter-template that does the connactiation of these strings and appends &mimefile=file Name and it works. but I want to move it internally in the xaction that way I just have to maintain the xactions and not 50 templates too. That way each xaction will have it's own ReportSummaryName then adds the rest of the strings and output type to it so that way the enduser can just click save in the location they want.

    I'll attach my xaction and parameter-template and you'll probably be able to see much better what I'm trying to do.

    Thanks agian,

    Nic


    EDIT: added new reply with attachment

    Post edited by: guzaldon, at: 06/12/2006 15:38
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  19. #19
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    grrr it didn' like my .tar

    this should be better

    Nic http://forums.pentaho.org/archived_a...ileName.tar.gz
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  20. #20
    dmoran Guest

    Default Re:when saving a report as a different output type

    Nic,

    I finally figured out what you were trying to do. The problem is that report content is being streamed to the browser from the JFreeReportComponent, then you are using the ContentOutputComponent to send the file name. The ContentOutputComponent also sends data to the output stream. All this is being sent to the browser as displayable content.

    In order to get the browser to pre set a filename, there is an HTTP header that needs to be set:

    Content-Disposition with a value of

    attachment; filename=myFilename

    The bad news - there is currently no way to set the headers of the response in your Pentaho BI Server.

    The good news - I added that capability to the attached HttpOutputHandler class. In the last couple releases we have added more capability to the <outputs> parameters that is not documented very well.

    Code:
      <outputs> 
        <mimefile type="string"> 
          <destinations> 
            <response>header</response> 
          </destinations> 
        </mimefile>  
        <report-output type="content"> 
          <destinations> 
            <response>content</response> 
          </destinations> 
        </report-output> 
      </outputs>
    The mimefile parameter is designated as an output, with a destination of "response" and a name of "header" If the parameter is of type string (which it is in your case), it is expected to be in the format name=value. The name will be used as the header to set, value would be the value to set that header to. If the parameter is of type property-map then all the key-value pairs will be set in the headers.

    The report-output parameter will have it's content streamed to the browser.


    I modified your xaction to build the correct header string and output it.

    Also - once content starts streaming from the report component, You can no longer set headers. I changed the xaction to have the report component stream to a content parameter, then it is set as an output to delay sending until the headers have been set.

    I modified the query to use our SampleData.

    It now seems to work as expected.

    IE/Windows doesn't like having colons ( in the filename so I changed that too.

    Please drop the class file in the org.pentaho.core.solution folder and try it with your server. My debugger configuration is set up for some other testing and I was hoping you could test it for me.

    Thanks,
    Doug

    BTW - I don't normally get into this much detail with a specific implementation but you have helped in so many forum posts and this is a good feature to add... http://forums.pentaho.org/archived_att/files/ng.zip

  21. #21
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Doug,

    Thanks so much for your help. I shall check it out and report back.

    I only do what I would expect any other good comunity member to do and that is help others to over come the same problems that I have faced so they can get over the learning curve so much quicker and enjoy the Best Open Source BI Solution in the market.

    I'll check out the modified xaction and the class you supplied and will return to give some feed back. I'll also tweak it to my needs and see if I get it working.

    Thanks agian,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  22. #22
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Alright I copied over the class into SDK/preconfigured-install/server/default/deploy/pentaho.war/WEB-INF/classes/org/pentaho/core/solution
    and I copied the xaction in the ng.zip
    and updated the jndi and the SQL and all looks ready to go. the file name was exactly what I was expecting.

    As far as errors I recieved I just got these.

    06:34:14,787 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
    and CONTENTLOCATION table doesn't exist. But that's probably my bunk data in mysql db. So I'll see what I can do about that. And rebuild by DB's a bit better and post some more info on the Purely Mysql topic.

    but the xaction with the class appears to be working well. I'll need to play a bit more with it b4 I'll get some questions but Definently the results I was looking for except for one thing see note at buttom. and I think the key is the minefile into the response header and the delay of the report-output for the content.

    Thanks agian Doug you and the PENTAHO team are the bomb,

    Nic

    NOTE: A side note is even when I selected as a HTML output type I still got the save as box with the file name.html. I'm assuming that the stream to the content parameter is forcing that to happening. which is a bit of a bugger but is much better than trying to deal with the end users typing in wrong filename and extenstions.
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  23. #23
    dmoran Guest

    Default Re:when saving a report as a different output type

    Nic,

    If you want the HTML output to go to the screen, change the content-disposition to inline:

    "content-disposition=inline; filename="...

    Since you are creating it in a javascript rule you can do some logic on the paramater "type-out" and set it how you want.

    Doug

  24. #24
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    Awesome thanks agian doug, things look like they are working great.

    And that knocks out my problems and issues with this as of now.

    also if anyone else needed to do this they now know what to do.

    Thanks agian,

    Nic

    Post edited by: guzaldon, at: 06/13/2006 23:09
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  25. #25
    Join Date
    Mar 2006
    Posts
    683

    Default Re:when saving a report as a different output type

    yep I was right the error that was being tossed which brought to my attention that the hibernate.cfg.xml was mis configed. So i fix that up and I don't get any errors at all. I even tried it w/o the up the dated class and it broke. then I copied the class over and it appears to work great.

    THanks agian for all your help,

    Nic
    Try not to have too much fun.
    - - - -
    Nic Guzaldo
    That guy who shows up here
    and there

  26. #26
    Join Date
    Dec 2006
    Posts
    4

    Smile Re:when saving a report as a different output type

    Dear All,

    I am very interesting about your topic and have tired that and it works well.Thank you for your contributions!

    mimefile = "content-disposition=";
    mimefile += (type_out=="html") ? "inline" : "attachment";
    mimefile += ";filename=" + report_title + "." + type_out;

    But now I have another problem. I want to generate some scheduled report like daily, weekly, monthly, rename the reports with date time,
    then locate all the reports to some directory on server, because another application will monitor all the reports and display to users.

    So the question is, can I directly save the report generated by JFreeReportComponent on local server after rename it,
    but without by the “Save as” common dialog box?


    Thanks&Regards
    Daney
    Last edited by daneyliu; 03-06-2007 at 12:43 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.