Dev - View and PDF file name generation exception

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Dev - View and PDF file name generation exception

Chris Juettner
I am creating a PDF file using a simple method defined in controller.xml
as follows:

<request-map uri="viewPackage.pdf">
<security https="true" auth="false"/>
<event type="simple" path="TheSimpleMethods.xml" invoke="generatePackage"/>
<response name="success" type="none"/>
<response name="error" type="view" value="error"/>
</request-map>

The creation of the PDF works fine and is displayed inside an IE browser
as long as you append the ".pdf" to the uri. By creating the PDF this way
IE defaults the PDF file name as the view uri (i.e. viewPackage.pdf).

However, I have a requirement to provide a unique file name to be used when
saving a copy of the PDF to a local disk.  As a workaround I changed the
uri to "viewPackage" and added another element (the file name to actually
save as) to the viewPackage hyperlink.  

For example:
<link target="viewPackage/${prName}_${nowDateTime}.pdf?projectId=${projectId}"
text="Preview Package" style="smallSubmit" target-window="preview"/>

The PDF is displayed correctly in its own browser page and the desired default
file name is created.

The problem with the workaround is an exception is thrown because the RequestHandler
thinks there is another view to process.  Here is a partial stack trace:

3752562 (http-0.0.0.0-8080-Processor2) [    ConfigXMLReader.java:411:INFO
] ViewMap Created: (27) records in 0.0s
3752562 (http-0.0.0.0-8080-Processor2) [     RequestHandler.java:360:INFO
] [RequestHandler.doRequest]: Response is a page [the_project_2006-01-19-114635.pdf]
3752578 (http-0.0.0.0-8080-Processor2) [     RequestHandler.java:486:INFO
] servletName=control, view=the_project_2006-01-19-114635.pdf
3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:200:WARN
] [RequestManager.getViewType] View with name "the_project_2006-01-19-114635.pdf"
not found
3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:188:WARN
] [RequestManager.getViewPage] View with name "the_project_2006-01-19-114635.pdf"
not found
3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:236:WARN
] [RequestManager.getViewInfo] View with name "the_project_2006-01-19-114635.pdf"
not found
3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:224:WARN
] [RequestManager.getViewInfo] View with name "the_project_2006-01-19-114635.pdf"
not found
3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:212:WARN
] [RequestManager.getViewInfo] View with name "the_project_2006-01-19-114635.pdf"
not found
3752578 (http-0.0.0.0-8080-Processor2) [ApplicationDispatcher.java:712:ERROR]
Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: getOutputStream() has already been called
for this response
        at org.apache.catalina.connector.Response.getWriter(Response.java:596)
        at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:186)
.
.
.
.


Is there a way to fix this or a better way to set the PDF file name?
FYI, I don't want to change any default preferences in Adobe.

Thanks for the help.

Chris Juettner
Integral Business Systems


 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Dev - View and PDF file name generation exception

David E. Jones

That is a pretty creative approach to the problem... I think to avoid  
the exception some sort of code change will be required...

-David


On Jan 19, 2006, at 11:03 AM, [hidden email] wrote:

> I am creating a PDF file using a simple method defined in  
> controller.xml
> as follows:
>
> <request-map uri="viewPackage.pdf">
> <security https="true" auth="false"/>
> <event type="simple" path="TheSimpleMethods.xml"  
> invoke="generatePackage"/>
> <response name="success" type="none"/>
> <response name="error" type="view" value="error"/>
> </request-map>
>
> The creation of the PDF works fine and is displayed inside an IE  
> browser
> as long as you append the ".pdf" to the uri. By creating the PDF  
> this way
> IE defaults the PDF file name as the view uri (i.e. viewPackage.pdf).
>
> However, I have a requirement to provide a unique file name to be  
> used when
> saving a copy of the PDF to a local disk.  As a workaround I  
> changed the
> uri to "viewPackage" and added another element (the file name to  
> actually
> save as) to the viewPackage hyperlink.
>
> For example:
> <link target="viewPackage/${prName}_${nowDateTime}.pdf?projectId=$
> {projectId}"
> text="Preview Package" style="smallSubmit" target-window="preview"/>
>
> The PDF is displayed correctly in its own browser page and the  
> desired default
> file name is created.
>
> The problem with the workaround is an exception is thrown because  
> the RequestHandler
> thinks there is another view to process.  Here is a partial stack  
> trace:
>
> 3752562 (http-0.0.0.0-8080-Processor2) [    ConfigXMLReader.java:
> 411:INFO
> ] ViewMap Created: (27) records in 0.0s
> 3752562 (http-0.0.0.0-8080-Processor2) [     RequestHandler.java:
> 360:INFO
> ] [RequestHandler.doRequest]: Response is a page  
> [the_project_2006-01-19-114635.pdf]
> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestHandler.java:
> 486:INFO
> ] servletName=control, view=the_project_2006-01-19-114635.pdf
> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
> 200:WARN
> ] [RequestManager.getViewType] View with name  
> "the_project_2006-01-19-114635.pdf"
> not found
> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
> 188:WARN
> ] [RequestManager.getViewPage] View with name  
> "the_project_2006-01-19-114635.pdf"
> not found
> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
> 236:WARN
> ] [RequestManager.getViewInfo] View with name  
> "the_project_2006-01-19-114635.pdf"
> not found
> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
> 224:WARN
> ] [RequestManager.getViewInfo] View with name  
> "the_project_2006-01-19-114635.pdf"
> not found
> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
> 212:WARN
> ] [RequestManager.getViewInfo] View with name  
> "the_project_2006-01-19-114635.pdf"
> not found
> 3752578 (http-0.0.0.0-8080-Processor2) [ApplicationDispatcher.java:
> 712:ERROR]
> Servlet.service() for servlet default threw exception
> java.lang.IllegalStateException: getOutputStream() has already been  
> called
> for this response
> at org.apache.catalina.connector.Response.getWriter(Response.java:
> 596)
> at org.apache.catalina.connector.ResponseFacade.getWriter
> (ResponseFacade.java:186)
> .
> .
> .
> .
>
>
> Is there a way to fix this or a better way to set the PDF file name?
> FYI, I don't want to change any default preferences in Adobe.
>
> Thanks for the help.
>
> Chris Juettner
> Integral Business Systems
>
>
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dev - View and PDF file name generation exception

Chris Juettner
I came up with a workaround to this issue.  It's not the most elegant but
it does the job without any changes to the Ofbiz codebase.

Add "none:" to the URL link so when the RequestHandler parses the next view
as "none:" it just returns to the caller.

Original:
<link target="viewPackage/${prName}_${nowDateTime}.pdf?projectId=${projectId}"
text="Preview Package" style="smallSubmit" target-window="preview"/>

Workaround:
<link target="viewPackage/none:/${prName}_${nowDateTime}.pdf?projectId=${projectId}"
text="Preview Package" style="smallSubmit" target-window="preview"/>

Chris Juettner
Integral Business Solutions


>-- Original Message --
>From: "David E. Jones" <[hidden email]>
>Date: Thu, 19 Jan 2006 23:18:24 -0700
>To: OFBiz Project Development Discussion <[hidden email]>
>Subject: Re: [OFBiz] Dev - View and PDF file name generation exception
>Reply-To: OFBiz Project Development Discussion <[hidden email]>
>
>
>
>That is a pretty creative approach to the problem... I think to avoid

>the exception some sort of code change will be required...
>
>-David
>
>
>On Jan 19, 2006, at 11:03 AM, [hidden email] wrote:
>
>> I am creating a PDF file using a simple method defined in  
>> controller.xml
>> as follows:
>>
>> <request-map uri="viewPackage.pdf">
>> <security https="true" auth="false"/>
>> <event type="simple" path="TheSimpleMethods.xml"  
>> invoke="generatePackage"/>
>> <response name="success" type="none"/>
>> <response name="error" type="view" value="error"/>
>> </request-map>
>>
>> The creation of the PDF works fine and is displayed inside an IE  
>> browser
>> as long as you append the ".pdf" to the uri. By creating the PDF  
>> this way
>> IE defaults the PDF file name as the view uri (i.e. viewPackage.pdf).
>>
>> However, I have a requirement to provide a unique file name to be  
>> used when
>> saving a copy of the PDF to a local disk.  As a workaround I  
>> changed the
>> uri to "viewPackage" and added another element (the file name to  
>> actually
>> save as) to the viewPackage hyperlink.
>>
>> For example:
>> <link target="viewPackage/${prName}_${nowDateTime}.pdf?projectId=$
>> {projectId}"
>> text="Preview Package" style="smallSubmit" target-window="preview"/>
>>
>> The PDF is displayed correctly in its own browser page and the  
>> desired default
>> file name is created.
>>
>> The problem with the workaround is an exception is thrown because  
>> the RequestHandler
>> thinks there is another view to process.  Here is a partial stack  
>> trace:
>>
>> 3752562 (http-0.0.0.0-8080-Processor2) [    ConfigXMLReader.java:
>> 411:INFO
>> ] ViewMap Created: (27) records in 0.0s
>> 3752562 (http-0.0.0.0-8080-Processor2) [     RequestHandler.java:
>> 360:INFO
>> ] [RequestHandler.doRequest]: Response is a page  
>> [the_project_2006-01-19-114635.pdf]
>> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestHandler.java:
>> 486:INFO
>> ] servletName=control, view=the_project_2006-01-19-114635.pdf
>> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
>> 200:WARN
>> ] [RequestManager.getViewType] View with name  
>> "the_project_2006-01-19-114635.pdf"
>> not found
>> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
>> 188:WARN
>> ] [RequestManager.getViewPage] View with name  
>> "the_project_2006-01-19-114635.pdf"
>> not found
>> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
>> 236:WARN
>> ] [RequestManager.getViewInfo] View with name  
>> "the_project_2006-01-19-114635.pdf"
>> not found
>> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
>> 224:WARN
>> ] [RequestManager.getViewInfo] View with name  
>> "the_project_2006-01-19-114635.pdf"
>> not found
>> 3752578 (http-0.0.0.0-8080-Processor2) [     RequestManager.java:
>> 212:WARN
>> ] [RequestManager.getViewInfo] View with name  
>> "the_project_2006-01-19-114635.pdf"
>> not found
>> 3752578 (http-0.0.0.0-8080-Processor2) [ApplicationDispatcher.java:
>> 712:ERROR]
>> Servlet.service() for servlet default threw exception
>> java.lang.IllegalStateException: getOutputStream() has already been

>> called
>> for this response
>> at org.apache.catalina.connector.Response.getWriter(Response.java:
>> 596)
>> at org.apache.catalina.connector.ResponseFacade.getWriter
>> (ResponseFacade.java:186)
>> .
>> .
>> .
>> .
>>
>>
>> Is there a way to fix this or a better way to set the PDF file name?
>> FYI, I don't want to change any default preferences in Adobe.
>>
>> Thanks for the help.
>>
>> Chris Juettner
>> Integral Business Systems
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>
>
>Attachment: smime.p7s
>
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev


 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev