You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nathan Beemer <na...@gmail.com> on 2009/07/25 17:05:33 UTC

T4.1: rendering a page to alternate OutputStream

I want to direct the render of a Page to a specific OutputStream.

Is it possible to do this?


I'm trying to use an IEngineService to accomplish this. Seems I'm  
close, but getting:

"Component UClients/a requires rendering support, but no  
PageRenderSupport object has been stored into the request cycle. This  
object is typically provided by a Body component. You should add a  
Body component to your template."


I'm injecting RequestGlobals service into my Pages and then doing:

  ((AbstractMyPage) homePage).getRequestGlobals().store(builder);

But this doesn't seem to be what Tapestry is looking for during the  
render:

Stack Trace:
   
org 
.apache.tapestry.TapestryUtils.getPageRenderSupport(TapestryUtils.java: 
124)
   
org 
.apache 
.tapestry 
.dojo.form.DropdownDatePicker.renderFormWidget(DropdownDatePicker.java: 
120)
   
org 
.apache 
.tapestry 
.dojo 
.form.AbstractFormWidget.renderFormComponent(AbstractFormWidget.java:66)



Re: T4.1: rendering a page to alternate OutputStream

Posted by Nathan Beemer <na...@gmail.com>.
I implemented this in a Page rather than IEngineService, same error:

"Component UClients/a requires rendering support, but no  
PageRenderSupport object has been stored into the request cycle. This  
object is typically provided by a Body component. You should add a  
Body component to your template."


Would this have anything to do with the fact that I'm using Border  
components?



On Jul 27, 2009, at 3:47 PM, Norman Franke wrote:

> In that case, someone posted how to get HTML from a page for sending  
> email a long time ago. This is what I distilled. I do this in a  
> page, but it doesn't use PageRenderSupport:
>
> 		MyPageToRender p = get MyPageToRender();
> 		p.setSomeParameter(value);
>
> 		MarkupFilter filter = new AsciiMarkupFilter();
> 		ByteArrayOutputStream bos = new ByteArrayOutputStream();
> 		PrintWriter writer = new PrintWriter(bos);
>
> 		RequestCycleFactory factory = getRequestCycleFactory();
> 		IRequestCycle cycle =  
> factory.newRequestCycle(getRequestCycle().getEngine());
>
> 		MarkupWriterImpl mw = new MarkupWriterImpl("text/html", writer,  
> filter);
> 		DefaultResponseBuilder rb = new DefaultResponseBuilder(mw);
>
> 		cycle.activate(p);
> 		cycle.renderPage(rb);
> 		
> 		writer.flush();
> 		byte [] html = bos.toByteArray();
>
>
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
>
>
>
> On Jul 27, 2009, at 4:27 PM, Nathan Beemer wrote:
>
>> Unfortunately, I need to render a Page and capture that output to  
>> feed into my PDF lib.
>>
>> And its the rendering to someplace-other-than-the-web browser that  
>> is fighting me.
>>
>> Thanks for your help though!
>>
>>
>> On Jul 27, 2009, at 3:02 PM, Norman Franke wrote:
>>
>>> Mine is rather long owning to having it create a PDF. In short, I  
>>> don't use PageRenderSupport since you don't really need it and  
>>> it's likely usable only by pages, which this isn't. In my case,  
>>> I'm filling in a form then flattening it (removing the forms, but  
>>> leaving the filled in data.) Using iText, I get a Reader (which  
>>> reads PDFs) and then create a Stamper that writes them, and it  
>>> uses a FileOutputStream to send the data.
>>>
>>> If your lib can't use a FileOutputStream, create an  
>>> ByteArrayOutputStream or copy from a local file (I do that as well  
>>> for PDFs that just stream out as-is.)
>>>
>>> Here is an excerpted part:
>>>
>>> public class PDFExport implements IEngineService {
>>>
>>> 	public static final String MIME_TYPE = "application/pdf";
>>>
>>> 	private WebResponse response;
>>>
>>> 	private LinkFactory linkFactory;
>>>
>>> 	private HttpServletRequest request;
>>> 	
>>> 	public PDFExport() {
>>> 	}
>>> 	
>>> 	public PDFExport(MapMailbox inMailbox) {
>>> 		mailbox = inMailbox;
>>> 	}
>>>
>>> 	public WebResponse getResponse() {
>>> 		return response;
>>> 	}
>>>
>>> 	public void setResponse(WebResponse response) {
>>> 		this.response = response;
>>> 	}
>>>
>>> 	public LinkFactory getLinkFactory() {
>>> 		return linkFactory;
>>> 	}
>>>
>>> 	public void setLinkFactory(LinkFactory linkFactory) {
>>> 		this.linkFactory = linkFactory;
>>> 	}
>>>
>>> 	public HttpServletRequest getRequest() {
>>> 		return request;
>>> 	}
>>>
>>> 	public void setRequest(HttpServletRequest request) {
>>> 		this.request = request;
>>> 	}
>>>
>>> 	@Override
>>> 	public void service(IRequestCycle cycle) throws IOException {
>>> 		WebResponse w = getResponse();
>>> 		ContentType ct = new ContentType(MIME_TYPE);
>>>
>>> 		String formIdParam = cycle.getParameter("formId");
>>>
>>> 		// Set special headers to work around a bug in IE with https.
>>> 		w.setHeader("Cache-Control", "max-age=0");
>>> 		w.setHeader("Pragma", "public");
>>>
>>> 		Integer formId = Integer.parseInt(formIdParam);
>>> 		Form f = FormManager.getForms(true).get(formId);
>>>
>>> 		// Set the file name of the exported file.
>>> 		w.setHeader("Content-Disposition", "inline; attachment;  
>>> filename=" + f.getFileName());
>>> 		
>>> 		Map<String, Object> baseFieldMap =  
>>> FormManager.getFieldMap(getMailbox(), f);
>>>
>>> 		servicePdf(f, baseFieldMap, w.getOutputStream(ct));
>>> 	}
>>>
>>> 	/**
>>> 	 * Output a dynamically modified PDF form.
>>> 	 *
>>> 	 * @param f					The form to output.
>>> 	 * @param baseFieldMap		The data to put on the form.
>>> 	 * @param theOutStream		The stream to output the form to.
>>> 	 * @throws IOException
>>> 	 */
>>> 	public void servicePdf(Form f, Map<String, Object> baseFieldMap,  
>>> OutputStream theOutStream) throws IOException {
>>> 		// Set up an output stream
>>> 		OutputStream webOut = theOutStream;
>>> 		PdfReader reader = null;
>>> 		 FileInputStream fis = new FileInputStream(f.getFile());
>>>
>>> 		reader = new PdfReader(fis);
>>>
>>> 		// Write PDF to webOut
>>> 		PdfStamper stamp = new PdfStamper(reader, out);
>>> 		...
>>> 	}
>>>
>>>
>>>
>>> <service-point id="PDFExport"  
>>> interface="org.apache.tapestry.engine.IEngineService">
>>>    <invoke-factory model="threaded">
>>>      <construct class="com.myasd.util.PDFExport">
>>>        <set-object property="response"  
>>> value="infrastructure:response"/>
>>>        <set-object property="linkFactory"  
>>> value="infrastructure:linkFactory"/>
>>>        <set-service property="request" service- 
>>> id="tapestry.globals.HttpServletRequest"/>
>>>      </construct>
>>>    </invoke-factory>
>>> </service-point>
>>>
>>> <contribution configuration- 
>>> id="tapestry.services.ApplicationServices">
>>>    <service name="PDFExport" object="service:PDFExport"/>
>>> </contribution>
>>>
>>>
>>> Norman Franke
>>> Answering Service for Directors, Inc.
>>> www.myasd.com
>>>
>>>
>>>
>>> On Jul 27, 2009, at 3:45 PM, Nathan Beemer wrote:
>>>
>>>> Sorry, my response wasn't put together very well.
>>>>
>>>> The specific problem I'm having is with the rendering from with  
>>>> my IEngineService.service(IRequestCycle) implementation
>>>>
>>>> The latest problem is with the PageRenderSupport error. I've  
>>>> tried a few different approaches, but they all end up with some  
>>>> Exception thrown during Tapestry's render process.
>>>>
>>>> Would you mind posting your implementation of  
>>>> IEngineService.service(..) ?
>>>>
>>>> Thanks
>>>>
>>>> On Jul 27, 2009, at 2:34 PM, Norman Franke wrote:
>>>>
>>>>> I am using an IEngineService. I get an output stream from the  
>>>>> response and use that to send the data. I don't know what PD4ML  
>>>>> expects, but I'd hope it can take an OutputStream.
>>>>>
>>>>> Norman Franke
>>>>> Answering Service for Directors, Inc.
>>>>> www.myasd.com
>>>>>
>>>>>
>>>>>
>>>>> On Jul 27, 2009, at 1:49 PM, Nathan Beemer wrote:
>>>>>
>>>>>> I need to have a "Download as PDF" link on some of my pages  
>>>>>> that will render the given page to PDF and send to client.
>>>>>>
>>>>>> I'm not familiar with iText, but everything you said sounds  
>>>>>> good, except the "blast out the data". My trouble is getting a  
>>>>>> handle on "the data".
>>>>>>
>>>>>> I'm using PD4ML, but I can't hook onto the rendered Tapestry  
>>>>>> output to pipe into PD4ML.
>>>>>>
>>>>>> Are you not using a IEngineService for this?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:
>>>>>>
>>>>>>> I do this for PDF exporting from iText. I inject the (Http)  
>>>>>>> request and (WebResponse) response along with a linkFactory  
>>>>>>> via hivemind.xml. Then WebResponse.setHeader("Content- 
>>>>>>> Description", "inline; attachment; filename=whatever"); Then  
>>>>>>> just blast out the data to getResponse().getOutputStream().
>>>>>>>
>>>>>>> Perhaps PageRenderSupport can't be used in services? What do  
>>>>>>> you need it for?
>>>>>>>
>>>>>>> Norman Franke
>>>>>>> Answering Service for Directors, Inc.
>>>>>>> www.myasd.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>>>>>>>
>>>>>>>> I want to direct the render of a Page to a specific  
>>>>>>>> OutputStream.
>>>>>>>>
>>>>>>>> Is it possible to do this?
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm trying to use an IEngineService to accomplish this. Seems  
>>>>>>>> I'm close, but getting:
>>>>>>>>
>>>>>>>> "Component UClients/a requires rendering support, but no  
>>>>>>>> PageRenderSupport object has been stored into the request  
>>>>>>>> cycle. This object is typically provided by a Body component.  
>>>>>>>> You should add a Body component to your template."
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm injecting RequestGlobals service into my Pages and then  
>>>>>>>> doing:
>>>>>>>>
>>>>>>>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>>>>>>>
>>>>>>>> But this doesn't seem to be what Tapestry is looking for  
>>>>>>>> during the render:
>>>>>>>>
>>>>>>>> Stack Trace:
>>>>>>>> org 
>>>>>>>> .apache 
>>>>>>>> .tapestry 
>>>>>>>> .TapestryUtils.getPageRenderSupport(TapestryUtils.java:124)
>>>>>>>> org 
>>>>>>>> .apache 
>>>>>>>> .tapestry 
>>>>>>>> .dojo 
>>>>>>>> .form 
>>>>>>>> .DropdownDatePicker.renderFormWidget(DropdownDatePicker.java: 
>>>>>>>> 120)
>>>>>>>> org 
>>>>>>>> .apache 
>>>>>>>> .tapestry 
>>>>>>>> .dojo 
>>>>>>>> .form 
>>>>>>>> .AbstractFormWidget 
>>>>>>>> .renderFormComponent(AbstractFormWidget.java:66)
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4.1: rendering a page to alternate OutputStream

Posted by Nathan Beemer <na...@gmail.com>.
My implementation is based on (what I suspect) is the same post you're  
referring to. But somewhere I'm missing the mark.

I'll try from scratch in a Page rather than via IEngineService and  
check my mileage.

I'll let you know.. Thanks again.


On Jul 27, 2009, at 3:47 PM, Norman Franke wrote:

> In that case, someone posted how to get HTML from a page for sending  
> email a long time ago. This is what I distilled. I do this in a  
> page, but it doesn't use PageRenderSupport:
>
> 		MyPageToRender p = get MyPageToRender();
> 		p.setSomeParameter(value);
>
> 		MarkupFilter filter = new AsciiMarkupFilter();
> 		ByteArrayOutputStream bos = new ByteArrayOutputStream();
> 		PrintWriter writer = new PrintWriter(bos);
>
> 		RequestCycleFactory factory = getRequestCycleFactory();
> 		IRequestCycle cycle =  
> factory.newRequestCycle(getRequestCycle().getEngine());
>
> 		MarkupWriterImpl mw = new MarkupWriterImpl("text/html", writer,  
> filter);
> 		DefaultResponseBuilder rb = new DefaultResponseBuilder(mw);
>
> 		cycle.activate(p);
> 		cycle.renderPage(rb);
> 		
> 		writer.flush();
> 		byte [] html = bos.toByteArray();
>
>
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
>
>
>
> On Jul 27, 2009, at 4:27 PM, Nathan Beemer wrote:
>
>> Unfortunately, I need to render a Page and capture that output to  
>> feed into my PDF lib.
>>
>> And its the rendering to someplace-other-than-the-web browser that  
>> is fighting me.
>>
>> Thanks for your help though!
>>
>>
>> On Jul 27, 2009, at 3:02 PM, Norman Franke wrote:
>>
>>> Mine is rather long owning to having it create a PDF. In short, I  
>>> don't use PageRenderSupport since you don't really need it and  
>>> it's likely usable only by pages, which this isn't. In my case,  
>>> I'm filling in a form then flattening it (removing the forms, but  
>>> leaving the filled in data.) Using iText, I get a Reader (which  
>>> reads PDFs) and then create a Stamper that writes them, and it  
>>> uses a FileOutputStream to send the data.
>>>
>>> If your lib can't use a FileOutputStream, create an  
>>> ByteArrayOutputStream or copy from a local file (I do that as well  
>>> for PDFs that just stream out as-is.)
>>>
>>> Here is an excerpted part:
>>>
>>> public class PDFExport implements IEngineService {
>>>
>>> 	public static final String MIME_TYPE = "application/pdf";
>>>
>>> 	private WebResponse response;
>>>
>>> 	private LinkFactory linkFactory;
>>>
>>> 	private HttpServletRequest request;
>>> 	
>>> 	public PDFExport() {
>>> 	}
>>> 	
>>> 	public PDFExport(MapMailbox inMailbox) {
>>> 		mailbox = inMailbox;
>>> 	}
>>>
>>> 	public WebResponse getResponse() {
>>> 		return response;
>>> 	}
>>>
>>> 	public void setResponse(WebResponse response) {
>>> 		this.response = response;
>>> 	}
>>>
>>> 	public LinkFactory getLinkFactory() {
>>> 		return linkFactory;
>>> 	}
>>>
>>> 	public void setLinkFactory(LinkFactory linkFactory) {
>>> 		this.linkFactory = linkFactory;
>>> 	}
>>>
>>> 	public HttpServletRequest getRequest() {
>>> 		return request;
>>> 	}
>>>
>>> 	public void setRequest(HttpServletRequest request) {
>>> 		this.request = request;
>>> 	}
>>>
>>> 	@Override
>>> 	public void service(IRequestCycle cycle) throws IOException {
>>> 		WebResponse w = getResponse();
>>> 		ContentType ct = new ContentType(MIME_TYPE);
>>>
>>> 		String formIdParam = cycle.getParameter("formId");
>>>
>>> 		// Set special headers to work around a bug in IE with https.
>>> 		w.setHeader("Cache-Control", "max-age=0");
>>> 		w.setHeader("Pragma", "public");
>>>
>>> 		Integer formId = Integer.parseInt(formIdParam);
>>> 		Form f = FormManager.getForms(true).get(formId);
>>>
>>> 		// Set the file name of the exported file.
>>> 		w.setHeader("Content-Disposition", "inline; attachment;  
>>> filename=" + f.getFileName());
>>> 		
>>> 		Map<String, Object> baseFieldMap =  
>>> FormManager.getFieldMap(getMailbox(), f);
>>>
>>> 		servicePdf(f, baseFieldMap, w.getOutputStream(ct));
>>> 	}
>>>
>>> 	/**
>>> 	 * Output a dynamically modified PDF form.
>>> 	 *
>>> 	 * @param f					The form to output.
>>> 	 * @param baseFieldMap		The data to put on the form.
>>> 	 * @param theOutStream		The stream to output the form to.
>>> 	 * @throws IOException
>>> 	 */
>>> 	public void servicePdf(Form f, Map<String, Object> baseFieldMap,  
>>> OutputStream theOutStream) throws IOException {
>>> 		// Set up an output stream
>>> 		OutputStream webOut = theOutStream;
>>> 		PdfReader reader = null;
>>> 		 FileInputStream fis = new FileInputStream(f.getFile());
>>>
>>> 		reader = new PdfReader(fis);
>>>
>>> 		// Write PDF to webOut
>>> 		PdfStamper stamp = new PdfStamper(reader, out);
>>> 		...
>>> 	}
>>>
>>>
>>>
>>> <service-point id="PDFExport"  
>>> interface="org.apache.tapestry.engine.IEngineService">
>>>    <invoke-factory model="threaded">
>>>      <construct class="com.myasd.util.PDFExport">
>>>        <set-object property="response"  
>>> value="infrastructure:response"/>
>>>        <set-object property="linkFactory"  
>>> value="infrastructure:linkFactory"/>
>>>        <set-service property="request" service- 
>>> id="tapestry.globals.HttpServletRequest"/>
>>>      </construct>
>>>    </invoke-factory>
>>> </service-point>
>>>
>>> <contribution configuration- 
>>> id="tapestry.services.ApplicationServices">
>>>    <service name="PDFExport" object="service:PDFExport"/>
>>> </contribution>
>>>
>>>
>>> Norman Franke
>>> Answering Service for Directors, Inc.
>>> www.myasd.com
>>>
>>>
>>>
>>> On Jul 27, 2009, at 3:45 PM, Nathan Beemer wrote:
>>>
>>>> Sorry, my response wasn't put together very well.
>>>>
>>>> The specific problem I'm having is with the rendering from with  
>>>> my IEngineService.service(IRequestCycle) implementation
>>>>
>>>> The latest problem is with the PageRenderSupport error. I've  
>>>> tried a few different approaches, but they all end up with some  
>>>> Exception thrown during Tapestry's render process.
>>>>
>>>> Would you mind posting your implementation of  
>>>> IEngineService.service(..) ?
>>>>
>>>> Thanks
>>>>
>>>> On Jul 27, 2009, at 2:34 PM, Norman Franke wrote:
>>>>
>>>>> I am using an IEngineService. I get an output stream from the  
>>>>> response and use that to send the data. I don't know what PD4ML  
>>>>> expects, but I'd hope it can take an OutputStream.
>>>>>
>>>>> Norman Franke
>>>>> Answering Service for Directors, Inc.
>>>>> www.myasd.com
>>>>>
>>>>>
>>>>>
>>>>> On Jul 27, 2009, at 1:49 PM, Nathan Beemer wrote:
>>>>>
>>>>>> I need to have a "Download as PDF" link on some of my pages  
>>>>>> that will render the given page to PDF and send to client.
>>>>>>
>>>>>> I'm not familiar with iText, but everything you said sounds  
>>>>>> good, except the "blast out the data". My trouble is getting a  
>>>>>> handle on "the data".
>>>>>>
>>>>>> I'm using PD4ML, but I can't hook onto the rendered Tapestry  
>>>>>> output to pipe into PD4ML.
>>>>>>
>>>>>> Are you not using a IEngineService for this?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:
>>>>>>
>>>>>>> I do this for PDF exporting from iText. I inject the (Http)  
>>>>>>> request and (WebResponse) response along with a linkFactory  
>>>>>>> via hivemind.xml. Then WebResponse.setHeader("Content- 
>>>>>>> Description", "inline; attachment; filename=whatever"); Then  
>>>>>>> just blast out the data to getResponse().getOutputStream().
>>>>>>>
>>>>>>> Perhaps PageRenderSupport can't be used in services? What do  
>>>>>>> you need it for?
>>>>>>>
>>>>>>> Norman Franke
>>>>>>> Answering Service for Directors, Inc.
>>>>>>> www.myasd.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>>>>>>>
>>>>>>>> I want to direct the render of a Page to a specific  
>>>>>>>> OutputStream.
>>>>>>>>
>>>>>>>> Is it possible to do this?
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm trying to use an IEngineService to accomplish this. Seems  
>>>>>>>> I'm close, but getting:
>>>>>>>>
>>>>>>>> "Component UClients/a requires rendering support, but no  
>>>>>>>> PageRenderSupport object has been stored into the request  
>>>>>>>> cycle. This object is typically provided by a Body component.  
>>>>>>>> You should add a Body component to your template."
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm injecting RequestGlobals service into my Pages and then  
>>>>>>>> doing:
>>>>>>>>
>>>>>>>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>>>>>>>
>>>>>>>> But this doesn't seem to be what Tapestry is looking for  
>>>>>>>> during the render:
>>>>>>>>
>>>>>>>> Stack Trace:
>>>>>>>> org 
>>>>>>>> .apache 
>>>>>>>> .tapestry 
>>>>>>>> .TapestryUtils.getPageRenderSupport(TapestryUtils.java:124)
>>>>>>>> org 
>>>>>>>> .apache 
>>>>>>>> .tapestry 
>>>>>>>> .dojo 
>>>>>>>> .form 
>>>>>>>> .DropdownDatePicker.renderFormWidget(DropdownDatePicker.java: 
>>>>>>>> 120)
>>>>>>>> org 
>>>>>>>> .apache 
>>>>>>>> .tapestry 
>>>>>>>> .dojo 
>>>>>>>> .form 
>>>>>>>> .AbstractFormWidget 
>>>>>>>> .renderFormComponent(AbstractFormWidget.java:66)
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4.1: rendering a page to alternate OutputStream

Posted by Norman Franke <no...@myasd.com>.
In that case, someone posted how to get HTML from a page for sending  
email a long time ago. This is what I distilled. I do this in a page,  
but it doesn't use PageRenderSupport:

		MyPageToRender p = get MyPageToRender();
		p.setSomeParameter(value);

		MarkupFilter filter = new AsciiMarkupFilter();
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		PrintWriter writer = new PrintWriter(bos);

		RequestCycleFactory factory = getRequestCycleFactory();
		IRequestCycle cycle =  
factory.newRequestCycle(getRequestCycle().getEngine());

		MarkupWriterImpl mw = new MarkupWriterImpl("text/html", writer,  
filter);
		DefaultResponseBuilder rb = new DefaultResponseBuilder(mw);

		cycle.activate(p);
		cycle.renderPage(rb);
		
		writer.flush();
		byte [] html = bos.toByteArray();


Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Jul 27, 2009, at 4:27 PM, Nathan Beemer wrote:

> Unfortunately, I need to render a Page and capture that output to  
> feed into my PDF lib.
>
> And its the rendering to someplace-other-than-the-web browser that  
> is fighting me.
>
> Thanks for your help though!
>
>
> On Jul 27, 2009, at 3:02 PM, Norman Franke wrote:
>
>> Mine is rather long owning to having it create a PDF. In short, I  
>> don't use PageRenderSupport since you don't really need it and it's  
>> likely usable only by pages, which this isn't. In my case, I'm  
>> filling in a form then flattening it (removing the forms, but  
>> leaving the filled in data.) Using iText, I get a Reader (which  
>> reads PDFs) and then create a Stamper that writes them, and it uses  
>> a FileOutputStream to send the data.
>>
>> If your lib can't use a FileOutputStream, create an  
>> ByteArrayOutputStream or copy from a local file (I do that as well  
>> for PDFs that just stream out as-is.)
>>
>> Here is an excerpted part:
>>
>> public class PDFExport implements IEngineService {
>>
>> 	public static final String MIME_TYPE = "application/pdf";
>>
>> 	private WebResponse response;
>>
>> 	private LinkFactory linkFactory;
>>
>> 	private HttpServletRequest request;
>> 	
>> 	public PDFExport() {
>> 	}
>> 	
>> 	public PDFExport(MapMailbox inMailbox) {
>> 		mailbox = inMailbox;
>> 	}
>>
>> 	public WebResponse getResponse() {
>> 		return response;
>> 	}
>>
>> 	public void setResponse(WebResponse response) {
>> 		this.response = response;
>> 	}
>>
>> 	public LinkFactory getLinkFactory() {
>> 		return linkFactory;
>> 	}
>>
>> 	public void setLinkFactory(LinkFactory linkFactory) {
>> 		this.linkFactory = linkFactory;
>> 	}
>>
>> 	public HttpServletRequest getRequest() {
>> 		return request;
>> 	}
>>
>> 	public void setRequest(HttpServletRequest request) {
>> 		this.request = request;
>> 	}
>>
>> 	@Override
>> 	public void service(IRequestCycle cycle) throws IOException {
>> 		WebResponse w = getResponse();
>> 		ContentType ct = new ContentType(MIME_TYPE);
>>
>> 		String formIdParam = cycle.getParameter("formId");
>>
>> 		// Set special headers to work around a bug in IE with https.
>> 		w.setHeader("Cache-Control", "max-age=0");
>> 		w.setHeader("Pragma", "public");
>>
>> 		Integer formId = Integer.parseInt(formIdParam);
>> 		Form f = FormManager.getForms(true).get(formId);
>>
>> 		// Set the file name of the exported file.
>> 		w.setHeader("Content-Disposition", "inline; attachment;  
>> filename=" + f.getFileName());
>> 		
>> 		Map<String, Object> baseFieldMap =  
>> FormManager.getFieldMap(getMailbox(), f);
>>
>> 		servicePdf(f, baseFieldMap, w.getOutputStream(ct));
>> 	}
>>
>> 	/**
>> 	 * Output a dynamically modified PDF form.
>> 	 *
>> 	 * @param f					The form to output.
>> 	 * @param baseFieldMap		The data to put on the form.
>> 	 * @param theOutStream		The stream to output the form to.
>> 	 * @throws IOException
>> 	 */
>> 	public void servicePdf(Form f, Map<String, Object> baseFieldMap,  
>> OutputStream theOutStream) throws IOException {
>> 		// Set up an output stream
>> 		OutputStream webOut = theOutStream;
>> 		PdfReader reader = null;
>> 		 FileInputStream fis = new FileInputStream(f.getFile());
>>
>> 		reader = new PdfReader(fis);
>>
>> 		// Write PDF to webOut
>> 		PdfStamper stamp = new PdfStamper(reader, out);
>> 		...
>> 	}
>>
>>
>>
>>  <service-point id="PDFExport"  
>> interface="org.apache.tapestry.engine.IEngineService">
>>     <invoke-factory model="threaded">
>>       <construct class="com.myasd.util.PDFExport">
>>         <set-object property="response"  
>> value="infrastructure:response"/>
>>         <set-object property="linkFactory"  
>> value="infrastructure:linkFactory"/>
>>         <set-service property="request" service- 
>> id="tapestry.globals.HttpServletRequest"/>
>>       </construct>
>>     </invoke-factory>
>>  </service-point>
>>
>>  <contribution configuration- 
>> id="tapestry.services.ApplicationServices">
>>     <service name="PDFExport" object="service:PDFExport"/>
>>  </contribution>
>>
>>
>> Norman Franke
>> Answering Service for Directors, Inc.
>> www.myasd.com
>>
>>
>>
>> On Jul 27, 2009, at 3:45 PM, Nathan Beemer wrote:
>>
>>> Sorry, my response wasn't put together very well.
>>>
>>> The specific problem I'm having is with the rendering from with my  
>>> IEngineService.service(IRequestCycle) implementation
>>>
>>> The latest problem is with the PageRenderSupport error. I've tried  
>>> a few different approaches, but they all end up with some  
>>> Exception thrown during Tapestry's render process.
>>>
>>> Would you mind posting your implementation of  
>>> IEngineService.service(..) ?
>>>
>>> Thanks
>>>
>>> On Jul 27, 2009, at 2:34 PM, Norman Franke wrote:
>>>
>>>> I am using an IEngineService. I get an output stream from the  
>>>> response and use that to send the data. I don't know what PD4ML  
>>>> expects, but I'd hope it can take an OutputStream.
>>>>
>>>> Norman Franke
>>>> Answering Service for Directors, Inc.
>>>> www.myasd.com
>>>>
>>>>
>>>>
>>>> On Jul 27, 2009, at 1:49 PM, Nathan Beemer wrote:
>>>>
>>>>> I need to have a "Download as PDF" link on some of my pages that  
>>>>> will render the given page to PDF and send to client.
>>>>>
>>>>> I'm not familiar with iText, but everything you said sounds  
>>>>> good, except the "blast out the data". My trouble is getting a  
>>>>> handle on "the data".
>>>>>
>>>>> I'm using PD4ML, but I can't hook onto the rendered Tapestry  
>>>>> output to pipe into PD4ML.
>>>>>
>>>>> Are you not using a IEngineService for this?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:
>>>>>
>>>>>> I do this for PDF exporting from iText. I inject the (Http)  
>>>>>> request and (WebResponse) response along with a linkFactory via  
>>>>>> hivemind.xml. Then WebResponse.setHeader("Content-Description",  
>>>>>> "inline; attachment; filename=whatever"); Then just blast out  
>>>>>> the data to getResponse().getOutputStream().
>>>>>>
>>>>>> Perhaps PageRenderSupport can't be used in services? What do  
>>>>>> you need it for?
>>>>>>
>>>>>> Norman Franke
>>>>>> Answering Service for Directors, Inc.
>>>>>> www.myasd.com
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>>>>>>
>>>>>>> I want to direct the render of a Page to a specific  
>>>>>>> OutputStream.
>>>>>>>
>>>>>>> Is it possible to do this?
>>>>>>>
>>>>>>>
>>>>>>> I'm trying to use an IEngineService to accomplish this. Seems  
>>>>>>> I'm close, but getting:
>>>>>>>
>>>>>>> "Component UClients/a requires rendering support, but no  
>>>>>>> PageRenderSupport object has been stored into the request  
>>>>>>> cycle. This object is typically provided by a Body component.  
>>>>>>> You should add a Body component to your template."
>>>>>>>
>>>>>>>
>>>>>>> I'm injecting RequestGlobals service into my Pages and then  
>>>>>>> doing:
>>>>>>>
>>>>>>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>>>>>>
>>>>>>> But this doesn't seem to be what Tapestry is looking for  
>>>>>>> during the render:
>>>>>>>
>>>>>>> Stack Trace:
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .tapestry 
>>>>>>> .TapestryUtils.getPageRenderSupport(TapestryUtils.java:124)
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .tapestry 
>>>>>>> .dojo 
>>>>>>> .form 
>>>>>>> .DropdownDatePicker.renderFormWidget(DropdownDatePicker.java: 
>>>>>>> 120)
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .tapestry 
>>>>>>> .dojo 
>>>>>>> .form 
>>>>>>> .AbstractFormWidget 
>>>>>>> .renderFormComponent(AbstractFormWidget.java:66)
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


Re: T4.1: rendering a page to alternate OutputStream

Posted by Nathan Beemer <na...@gmail.com>.
Unfortunately, I need to render a Page and capture that output to feed  
into my PDF lib.

And its the rendering to someplace-other-than-the-web browser that is  
fighting me.

Thanks for your help though!


On Jul 27, 2009, at 3:02 PM, Norman Franke wrote:

> Mine is rather long owning to having it create a PDF. In short, I  
> don't use PageRenderSupport since you don't really need it and it's  
> likely usable only by pages, which this isn't. In my case, I'm  
> filling in a form then flattening it (removing the forms, but  
> leaving the filled in data.) Using iText, I get a Reader (which  
> reads PDFs) and then create a Stamper that writes them, and it uses  
> a FileOutputStream to send the data.
>
> If your lib can't use a FileOutputStream, create an  
> ByteArrayOutputStream or copy from a local file (I do that as well  
> for PDFs that just stream out as-is.)
>
> Here is an excerpted part:
>
> public class PDFExport implements IEngineService {
>
> 	public static final String MIME_TYPE = "application/pdf";
>
> 	private WebResponse response;
>
> 	private LinkFactory linkFactory;
>
> 	private HttpServletRequest request;
> 	
> 	public PDFExport() {
> 	}
> 	
> 	public PDFExport(MapMailbox inMailbox) {
> 		mailbox = inMailbox;
> 	}
>
> 	public WebResponse getResponse() {
> 		return response;
> 	}
>
> 	public void setResponse(WebResponse response) {
> 		this.response = response;
> 	}
>
> 	public LinkFactory getLinkFactory() {
> 		return linkFactory;
> 	}
>
> 	public void setLinkFactory(LinkFactory linkFactory) {
> 		this.linkFactory = linkFactory;
> 	}
>
> 	public HttpServletRequest getRequest() {
> 		return request;
> 	}
>
> 	public void setRequest(HttpServletRequest request) {
> 		this.request = request;
> 	}
>
> 	@Override
> 	public void service(IRequestCycle cycle) throws IOException {
> 		WebResponse w = getResponse();
> 		ContentType ct = new ContentType(MIME_TYPE);
>
> 		String formIdParam = cycle.getParameter("formId");
>
> 		// Set special headers to work around a bug in IE with https.
> 		w.setHeader("Cache-Control", "max-age=0");
> 		w.setHeader("Pragma", "public");
>
> 		Integer formId = Integer.parseInt(formIdParam);
> 		Form f = FormManager.getForms(true).get(formId);
>
> 		// Set the file name of the exported file.
> 		w.setHeader("Content-Disposition", "inline; attachment; filename="  
> + f.getFileName());
> 		
> 		Map<String, Object> baseFieldMap =  
> FormManager.getFieldMap(getMailbox(), f);
>
> 		servicePdf(f, baseFieldMap, w.getOutputStream(ct));
> 	}
>
> 	/**
> 	 * Output a dynamically modified PDF form.
> 	 *
> 	 * @param f					The form to output.
> 	 * @param baseFieldMap		The data to put on the form.
> 	 * @param theOutStream		The stream to output the form to.
> 	 * @throws IOException
> 	 */
> 	public void servicePdf(Form f, Map<String, Object> baseFieldMap,  
> OutputStream theOutStream) throws IOException {
> 		// Set up an output stream
> 		OutputStream webOut = theOutStream;
> 		PdfReader reader = null;
> 		 FileInputStream fis = new FileInputStream(f.getFile());
>
> 		reader = new PdfReader(fis);
>
> 		// Write PDF to webOut
> 		PdfStamper stamp = new PdfStamper(reader, out);
> 		...
> 	}
>
>
>
>   <service-point id="PDFExport"  
> interface="org.apache.tapestry.engine.IEngineService">
>      <invoke-factory model="threaded">
>        <construct class="com.myasd.util.PDFExport">
>          <set-object property="response"  
> value="infrastructure:response"/>
>          <set-object property="linkFactory"  
> value="infrastructure:linkFactory"/>
>          <set-service property="request" service- 
> id="tapestry.globals.HttpServletRequest"/>
>        </construct>
>      </invoke-factory>
>   </service-point>
>
>   <contribution configuration- 
> id="tapestry.services.ApplicationServices">
>      <service name="PDFExport" object="service:PDFExport"/>
>   </contribution>
>
>
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
>
>
>
> On Jul 27, 2009, at 3:45 PM, Nathan Beemer wrote:
>
>> Sorry, my response wasn't put together very well.
>>
>> The specific problem I'm having is with the rendering from with my  
>> IEngineService.service(IRequestCycle) implementation
>>
>> The latest problem is with the PageRenderSupport error. I've tried  
>> a few different approaches, but they all end up with some Exception  
>> thrown during Tapestry's render process.
>>
>> Would you mind posting your implementation of  
>> IEngineService.service(..) ?
>>
>> Thanks
>>
>> On Jul 27, 2009, at 2:34 PM, Norman Franke wrote:
>>
>>> I am using an IEngineService. I get an output stream from the  
>>> response and use that to send the data. I don't know what PD4ML  
>>> expects, but I'd hope it can take an OutputStream.
>>>
>>> Norman Franke
>>> Answering Service for Directors, Inc.
>>> www.myasd.com
>>>
>>>
>>>
>>> On Jul 27, 2009, at 1:49 PM, Nathan Beemer wrote:
>>>
>>>> I need to have a "Download as PDF" link on some of my pages that  
>>>> will render the given page to PDF and send to client.
>>>>
>>>> I'm not familiar with iText, but everything you said sounds good,  
>>>> except the "blast out the data". My trouble is getting a handle  
>>>> on "the data".
>>>>
>>>> I'm using PD4ML, but I can't hook onto the rendered Tapestry  
>>>> output to pipe into PD4ML.
>>>>
>>>> Are you not using a IEngineService for this?
>>>>
>>>>
>>>>
>>>>
>>>> On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:
>>>>
>>>>> I do this for PDF exporting from iText. I inject the (Http)  
>>>>> request and (WebResponse) response along with a linkFactory via  
>>>>> hivemind.xml. Then WebResponse.setHeader("Content-Description",  
>>>>> "inline; attachment; filename=whatever"); Then just blast out  
>>>>> the data to getResponse().getOutputStream().
>>>>>
>>>>> Perhaps PageRenderSupport can't be used in services? What do you  
>>>>> need it for?
>>>>>
>>>>> Norman Franke
>>>>> Answering Service for Directors, Inc.
>>>>> www.myasd.com
>>>>>
>>>>>
>>>>>
>>>>> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>>>>>
>>>>>> I want to direct the render of a Page to a specific OutputStream.
>>>>>>
>>>>>> Is it possible to do this?
>>>>>>
>>>>>>
>>>>>> I'm trying to use an IEngineService to accomplish this. Seems  
>>>>>> I'm close, but getting:
>>>>>>
>>>>>> "Component UClients/a requires rendering support, but no  
>>>>>> PageRenderSupport object has been stored into the request  
>>>>>> cycle. This object is typically provided by a Body component.  
>>>>>> You should add a Body component to your template."
>>>>>>
>>>>>>
>>>>>> I'm injecting RequestGlobals service into my Pages and then  
>>>>>> doing:
>>>>>>
>>>>>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>>>>>
>>>>>> But this doesn't seem to be what Tapestry is looking for during  
>>>>>> the render:
>>>>>>
>>>>>> Stack Trace:
>>>>>> org 
>>>>>> .apache 
>>>>>> .tapestry.TapestryUtils.getPageRenderSupport(TapestryUtils.java: 
>>>>>> 124)
>>>>>> org 
>>>>>> .apache 
>>>>>> .tapestry 
>>>>>> .dojo 
>>>>>> .form 
>>>>>> .DropdownDatePicker.renderFormWidget(DropdownDatePicker.java:120)
>>>>>> org 
>>>>>> .apache 
>>>>>> .tapestry 
>>>>>> .dojo 
>>>>>> .form 
>>>>>> .AbstractFormWidget.renderFormComponent(AbstractFormWidget.java: 
>>>>>> 66)
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4.1: rendering a page to alternate OutputStream

Posted by Norman Franke <no...@myasd.com>.
Mine is rather long owning to having it create a PDF. In short, I  
don't use PageRenderSupport since you don't really need it and it's  
likely usable only by pages, which this isn't. In my case, I'm filling  
in a form then flattening it (removing the forms, but leaving the  
filled in data.) Using iText, I get a Reader (which reads PDFs) and  
then create a Stamper that writes them, and it uses a FileOutputStream  
to send the data.

If your lib can't use a FileOutputStream, create an  
ByteArrayOutputStream or copy from a local file (I do that as well for  
PDFs that just stream out as-is.)

Here is an excerpted part:

public class PDFExport implements IEngineService {

	public static final String MIME_TYPE = "application/pdf";

	private WebResponse response;

	private LinkFactory linkFactory;

	private HttpServletRequest request;
	
	public PDFExport() {
	}
	
	public PDFExport(MapMailbox inMailbox) {
		mailbox = inMailbox;
	}

	public WebResponse getResponse() {
		return response;
	}

	public void setResponse(WebResponse response) {
		this.response = response;
	}

	public LinkFactory getLinkFactory() {
		return linkFactory;
	}

	public void setLinkFactory(LinkFactory linkFactory) {
		this.linkFactory = linkFactory;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	@Override
	public void service(IRequestCycle cycle) throws IOException {
		WebResponse w = getResponse();
		ContentType ct = new ContentType(MIME_TYPE);

		String formIdParam = cycle.getParameter("formId");

		// Set special headers to work around a bug in IE with https.
		w.setHeader("Cache-Control", "max-age=0");
		w.setHeader("Pragma", "public");

		Integer formId = Integer.parseInt(formIdParam);
		Form f = FormManager.getForms(true).get(formId);

		// Set the file name of the exported file.
		w.setHeader("Content-Disposition", "inline; attachment; filename=" +  
f.getFileName());
		
		Map<String, Object> baseFieldMap =  
FormManager.getFieldMap(getMailbox(), f);

		servicePdf(f, baseFieldMap, w.getOutputStream(ct));
	}

	/**
	 * Output a dynamically modified PDF form.
	 *
	 * @param f					The form to output.
	 * @param baseFieldMap		The data to put on the form.
	 * @param theOutStream		The stream to output the form to.
	 * @throws IOException
	 */
	public void servicePdf(Form f, Map<String, Object> baseFieldMap,  
OutputStream theOutStream) throws IOException {
		// Set up an output stream
		OutputStream webOut = theOutStream;
		PdfReader reader = null;
		 FileInputStream fis = new FileInputStream(f.getFile());

		reader = new PdfReader(fis);

		// Write PDF to webOut
		PdfStamper stamp = new PdfStamper(reader, out);
		...
	}



    <service-point id="PDFExport"  
interface="org.apache.tapestry.engine.IEngineService">
       <invoke-factory model="threaded">
         <construct class="com.myasd.util.PDFExport">
           <set-object property="response"  
value="infrastructure:response"/>
           <set-object property="linkFactory"  
value="infrastructure:linkFactory"/>
           <set-service property="request" service- 
id="tapestry.globals.HttpServletRequest"/>
         </construct>
       </invoke-factory>
    </service-point>

    <contribution configuration- 
id="tapestry.services.ApplicationServices">
       <service name="PDFExport" object="service:PDFExport"/>
    </contribution>


Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Jul 27, 2009, at 3:45 PM, Nathan Beemer wrote:

> Sorry, my response wasn't put together very well.
>
> The specific problem I'm having is with the rendering from with my  
> IEngineService.service(IRequestCycle) implementation
>
> The latest problem is with the PageRenderSupport error. I've tried a  
> few different approaches, but they all end up with some Exception  
> thrown during Tapestry's render process.
>
> Would you mind posting your implementation of  
> IEngineService.service(..) ?
>
> Thanks
>
> On Jul 27, 2009, at 2:34 PM, Norman Franke wrote:
>
>> I am using an IEngineService. I get an output stream from the  
>> response and use that to send the data. I don't know what PD4ML  
>> expects, but I'd hope it can take an OutputStream.
>>
>> Norman Franke
>> Answering Service for Directors, Inc.
>> www.myasd.com
>>
>>
>>
>> On Jul 27, 2009, at 1:49 PM, Nathan Beemer wrote:
>>
>>> I need to have a "Download as PDF" link on some of my pages that  
>>> will render the given page to PDF and send to client.
>>>
>>> I'm not familiar with iText, but everything you said sounds good,  
>>> except the "blast out the data". My trouble is getting a handle on  
>>> "the data".
>>>
>>> I'm using PD4ML, but I can't hook onto the rendered Tapestry  
>>> output to pipe into PD4ML.
>>>
>>> Are you not using a IEngineService for this?
>>>
>>>
>>>
>>>
>>> On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:
>>>
>>>> I do this for PDF exporting from iText. I inject the (Http)  
>>>> request and (WebResponse) response along with a linkFactory via  
>>>> hivemind.xml. Then WebResponse.setHeader("Content-Description",  
>>>> "inline; attachment; filename=whatever"); Then just blast out the  
>>>> data to getResponse().getOutputStream().
>>>>
>>>> Perhaps PageRenderSupport can't be used in services? What do you  
>>>> need it for?
>>>>
>>>> Norman Franke
>>>> Answering Service for Directors, Inc.
>>>> www.myasd.com
>>>>
>>>>
>>>>
>>>> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>>>>
>>>>> I want to direct the render of a Page to a specific OutputStream.
>>>>>
>>>>> Is it possible to do this?
>>>>>
>>>>>
>>>>> I'm trying to use an IEngineService to accomplish this. Seems  
>>>>> I'm close, but getting:
>>>>>
>>>>> "Component UClients/a requires rendering support, but no  
>>>>> PageRenderSupport object has been stored into the request cycle.  
>>>>> This object is typically provided by a Body component. You  
>>>>> should add a Body component to your template."
>>>>>
>>>>>
>>>>> I'm injecting RequestGlobals service into my Pages and then doing:
>>>>>
>>>>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>>>>
>>>>> But this doesn't seem to be what Tapestry is looking for during  
>>>>> the render:
>>>>>
>>>>> Stack Trace:
>>>>> org 
>>>>> .apache 
>>>>> .tapestry.TapestryUtils.getPageRenderSupport(TapestryUtils.java: 
>>>>> 124)
>>>>> org 
>>>>> .apache 
>>>>> .tapestry 
>>>>> .dojo 
>>>>> .form 
>>>>> .DropdownDatePicker.renderFormWidget(DropdownDatePicker.java:120)
>>>>> org 
>>>>> .apache 
>>>>> .tapestry 
>>>>> .dojo 
>>>>> .form 
>>>>> .AbstractFormWidget.renderFormComponent(AbstractFormWidget.java: 
>>>>> 66)
>>>>>
>>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


Re: T4.1: rendering a page to alternate OutputStream

Posted by Nathan Beemer <na...@gmail.com>.
Sorry, my response wasn't put together very well.

The specific problem I'm having is with the rendering from with my  
IEngineService.service(IRequestCycle) implementation

The latest problem is with the PageRenderSupport error. I've tried a  
few different approaches, but they all end up with some Exception  
thrown during Tapestry's render process.

Would you mind posting your implementation of  
IEngineService.service(..) ?

Thanks

On Jul 27, 2009, at 2:34 PM, Norman Franke wrote:

> I am using an IEngineService. I get an output stream from the  
> response and use that to send the data. I don't know what PD4ML  
> expects, but I'd hope it can take an OutputStream.
>
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
>
>
>
> On Jul 27, 2009, at 1:49 PM, Nathan Beemer wrote:
>
>> I need to have a "Download as PDF" link on some of my pages that  
>> will render the given page to PDF and send to client.
>>
>> I'm not familiar with iText, but everything you said sounds good,  
>> except the "blast out the data". My trouble is getting a handle on  
>> "the data".
>>
>> I'm using PD4ML, but I can't hook onto the rendered Tapestry output  
>> to pipe into PD4ML.
>>
>> Are you not using a IEngineService for this?
>>
>>
>>
>>
>> On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:
>>
>>> I do this for PDF exporting from iText. I inject the (Http)  
>>> request and (WebResponse) response along with a linkFactory via  
>>> hivemind.xml. Then WebResponse.setHeader("Content-Description",  
>>> "inline; attachment; filename=whatever"); Then just blast out the  
>>> data to getResponse().getOutputStream().
>>>
>>> Perhaps PageRenderSupport can't be used in services? What do you  
>>> need it for?
>>>
>>> Norman Franke
>>> Answering Service for Directors, Inc.
>>> www.myasd.com
>>>
>>>
>>>
>>> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>>>
>>>> I want to direct the render of a Page to a specific OutputStream.
>>>>
>>>> Is it possible to do this?
>>>>
>>>>
>>>> I'm trying to use an IEngineService to accomplish this. Seems I'm  
>>>> close, but getting:
>>>>
>>>> "Component UClients/a requires rendering support, but no  
>>>> PageRenderSupport object has been stored into the request cycle.  
>>>> This object is typically provided by a Body component. You should  
>>>> add a Body component to your template."
>>>>
>>>>
>>>> I'm injecting RequestGlobals service into my Pages and then doing:
>>>>
>>>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>>>
>>>> But this doesn't seem to be what Tapestry is looking for during  
>>>> the render:
>>>>
>>>> Stack Trace:
>>>> org 
>>>> .apache 
>>>> .tapestry.TapestryUtils.getPageRenderSupport(TapestryUtils.java: 
>>>> 124)
>>>> org 
>>>> .apache 
>>>> .tapestry 
>>>> .dojo 
>>>> .form.DropdownDatePicker.renderFormWidget(DropdownDatePicker.java: 
>>>> 120)
>>>> org 
>>>> .apache 
>>>> .tapestry 
>>>> .dojo 
>>>> .form 
>>>> .AbstractFormWidget.renderFormComponent(AbstractFormWidget.java:66)
>>>>
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4.1: rendering a page to alternate OutputStream

Posted by Norman Franke <no...@myasd.com>.
I am using an IEngineService. I get an output stream from the response  
and use that to send the data. I don't know what PD4ML expects, but  
I'd hope it can take an OutputStream.

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Jul 27, 2009, at 1:49 PM, Nathan Beemer wrote:

> I need to have a "Download as PDF" link on some of my pages that  
> will render the given page to PDF and send to client.
>
> I'm not familiar with iText, but everything you said sounds good,  
> except the "blast out the data". My trouble is getting a handle on  
> "the data".
>
> I'm using PD4ML, but I can't hook onto the rendered Tapestry output  
> to pipe into PD4ML.
>
> Are you not using a IEngineService for this?
>
>
>
>
> On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:
>
>> I do this for PDF exporting from iText. I inject the (Http) request  
>> and (WebResponse) response along with a linkFactory via  
>> hivemind.xml. Then WebResponse.setHeader("Content-Description",  
>> "inline; attachment; filename=whatever"); Then just blast out the  
>> data to getResponse().getOutputStream().
>>
>> Perhaps PageRenderSupport can't be used in services? What do you  
>> need it for?
>>
>> Norman Franke
>> Answering Service for Directors, Inc.
>> www.myasd.com
>>
>>
>>
>> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>>
>>> I want to direct the render of a Page to a specific OutputStream.
>>>
>>> Is it possible to do this?
>>>
>>>
>>> I'm trying to use an IEngineService to accomplish this. Seems I'm  
>>> close, but getting:
>>>
>>> "Component UClients/a requires rendering support, but no  
>>> PageRenderSupport object has been stored into the request cycle.  
>>> This object is typically provided by a Body component. You should  
>>> add a Body component to your template."
>>>
>>>
>>> I'm injecting RequestGlobals service into my Pages and then doing:
>>>
>>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>>
>>> But this doesn't seem to be what Tapestry is looking for during  
>>> the render:
>>>
>>> Stack Trace:
>>> org 
>>> .apache 
>>> .tapestry.TapestryUtils.getPageRenderSupport(TapestryUtils.java:124)
>>> org 
>>> .apache 
>>> .tapestry 
>>> .dojo 
>>> .form.DropdownDatePicker.renderFormWidget(DropdownDatePicker.java: 
>>> 120)
>>> org 
>>> .apache 
>>> .tapestry 
>>> .dojo 
>>> .form 
>>> .AbstractFormWidget.renderFormComponent(AbstractFormWidget.java:66)
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


Re: T4.1: rendering a page to alternate OutputStream

Posted by Nathan Beemer <na...@gmail.com>.
I need to have a "Download as PDF" link on some of my pages that will  
render the given page to PDF and send to client.

I'm not familiar with iText, but everything you said sounds good,  
except the "blast out the data". My trouble is getting a handle on  
"the data".

I'm using PD4ML, but I can't hook onto the rendered Tapestry output to  
pipe into PD4ML.

Are you not using a IEngineService for this?




On Jul 27, 2009, at 10:35 AM, Norman Franke wrote:

> I do this for PDF exporting from iText. I inject the (Http) request  
> and (WebResponse) response along with a linkFactory via  
> hivemind.xml. Then WebResponse.setHeader("Content-Description",  
> "inline; attachment; filename=whatever"); Then just blast out the  
> data to getResponse().getOutputStream().
>
> Perhaps PageRenderSupport can't be used in services? What do you  
> need it for?
>
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
>
>
>
> On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:
>
>> I want to direct the render of a Page to a specific OutputStream.
>>
>> Is it possible to do this?
>>
>>
>> I'm trying to use an IEngineService to accomplish this. Seems I'm  
>> close, but getting:
>>
>> "Component UClients/a requires rendering support, but no  
>> PageRenderSupport object has been stored into the request cycle.  
>> This object is typically provided by a Body component. You should  
>> add a Body component to your template."
>>
>>
>> I'm injecting RequestGlobals service into my Pages and then doing:
>>
>> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>>
>> But this doesn't seem to be what Tapestry is looking for during the  
>> render:
>>
>> Stack Trace:
>> org 
>> .apache 
>> .tapestry.TapestryUtils.getPageRenderSupport(TapestryUtils.java:124)
>> org 
>> .apache 
>> .tapestry 
>> .dojo 
>> .form.DropdownDatePicker.renderFormWidget(DropdownDatePicker.java: 
>> 120)
>> org 
>> .apache 
>> .tapestry 
>> .dojo 
>> .form 
>> .AbstractFormWidget.renderFormComponent(AbstractFormWidget.java:66)
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T4.1: rendering a page to alternate OutputStream

Posted by Norman Franke <no...@myasd.com>.
I do this for PDF exporting from iText. I inject the (Http) request  
and (WebResponse) response along with a linkFactory via hivemind.xml.  
Then WebResponse.setHeader("Content-Description", "inline; attachment;  
filename=whatever"); Then just blast out the data to  
getResponse().getOutputStream().

Perhaps PageRenderSupport can't be used in services? What do you need  
it for?

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Jul 25, 2009, at 11:05 AM, Nathan Beemer wrote:

> I want to direct the render of a Page to a specific OutputStream.
>
> Is it possible to do this?
>
>
> I'm trying to use an IEngineService to accomplish this. Seems I'm  
> close, but getting:
>
> "Component UClients/a requires rendering support, but no  
> PageRenderSupport object has been stored into the request cycle.  
> This object is typically provided by a Body component. You should  
> add a Body component to your template."
>
>
> I'm injecting RequestGlobals service into my Pages and then doing:
>
> ((AbstractMyPage) homePage).getRequestGlobals().store(builder);
>
> But this doesn't seem to be what Tapestry is looking for during the  
> render:
>
> Stack Trace:
> org 
> .apache 
> .tapestry.TapestryUtils.getPageRenderSupport(TapestryUtils.java:124)
> org 
> .apache 
> .tapestry 
> .dojo 
> .form.DropdownDatePicker.renderFormWidget(DropdownDatePicker.java:120)
> org 
> .apache 
> .tapestry 
> .dojo 
> .form.AbstractFormWidget.renderFormComponent(AbstractFormWidget.java: 
> 66)
>
>