Indeed.
you make perfect sense - 1) create a concrete file in a web-accessible folder first and then, after testing it, 2) forward the request to that file. The process #1 should be done independent of application context, reused. Just me - but I do not want to touch code that is already working (i.e. the page code). If I could somehow getaway with building a wrapper to it...or inject mock application context - as allowed (architecturally) in Spring Framework...perhaps some sort of test harness? The "something" that creates the PDF (or any other stream) is the tapestry page. In fact, there is no create, per se - it is the very page itself! By default browser behavior it manifests as a file download for content type PDF.. Now the customer wants that exact "file" to be just stored on the server periodically...and also retain the request time rendering feature, of course, with all the graphics logos etc. Obviously they do not comprehend streaming, to them it is just a file (as you also put it) should have been created first, streamed next...and not the other way around! On Saturday, June 7, 2014 3:52 PM, Geoff Callender <geoff.callender.jumpst...@gmail.com> wrote: I'm confused. I would have the streamer use something else first to create or find the PDF, then it streams it. That "something" is the part that is common and could be shared, not the streamer. Am I off track? Cheers, Geoff On 8 Jun 2014, at 6:49 am, Net Dawg <net.d...@yahoo.com.INVALID> wrote: > Would like to reuse a page event handler function to render that specific > response on server as a file. > > > Generally, how does one make an service wrapper to tapestry pages? > > > Specifically, how can tapestry application context be injected in stand-alone > java program? > > > Use-Case: > > > There is a PDF button on my page that renders the content at request time as > a file download. I would like to periodically create that file on the > server instead. The catch: would like to use the exact same process, > not have to write any duplicate code. In other words, should a user > happen to download the pdf by clicking the button at exactly the same > time as the cron job created the file on the server, the two files would be > identical. > > > I have a submit button on a page that renders PDF. Works fine. Basically, > there is a button on the form in the page > > <t:submit t:id="pdf" name="Run Report" value="PDF" /> > > > Within the page class I have an onSelectedFromPdf handler that returns > PDFStreamResponse > (http://wiki.apache.org/tapestry/Tapestry5HowToCreateADynamicPDF) > > > I would like to reuse the exact same onSelectFromPdf page handler from > the command line instead, streaming the response to a file. I tried > injecting the page into services, works (compiles) just fine. But get > null response when calling onSelect function - obviously not getting any > tapestry management, (application context). > > <code> > public class PDFLogger > { > > @Inject > private Page page; // THIS DOES NOT WORK (NULL) > > public PDFStreamResponse getLogs() > { > return page.onSelectedFromPdf(); // null pointer exception > } > > public static void main(String [] args) > { > > >////////////////////////////////////////////////////////////////////////////// > // this is the problem/question..................... > > PDFLoggger logger = new PDFLogger(); // how to instantiate page >correctly...in application context etc??????? > > PDFStreamResponse response = (PDFStreamResponse) logger.getLogs(); > try > { > IOUtils.copy(response.getStream(), System.out); > } > catch (IOException ioe) > { > throw new RuntimeException("error reading stream", ioe); > } > } > > </code> > > > Hope this is useful to someone with same type of question. Thanks in advance > to the experts... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org