Hello Andreas,

are you calling FacesContext.getCurrentInstance().responseComplete() ?

Regards

Bernd


Andreas Niemeyer schrieb:
> Hello Bernd,
> 
> Thank you for response.
> 
> Unfortunatly I have to use this servlet as a pdf dynamic provider.
> 
> The redirect works fine so far, but another thing happened.
> 
> Due some validation rules in the same method, a previous custom
> FacesMessage stays displayed and only after a page reload it goes away.
> 
> Have someone an idea?
> 
> Regards,
> Andreas
> 
> 
> 
> Bernd Bohmann schrieb:
>> Hello Andreas,
>>
>> maybe this help:
>>
>> http://wiki.apache.org/myfaces/Sending_Files
>>
>> You don't need a Servlet for sending binary data from jsf.
>>
>> The magic is the responseComplete() method.
>>
>> Please look at the Section
>>
>> 2.1.3 Faces Request Generates Non-Faces Response
>>
>> of the jsf 1.1 spec.
>>
>> Regards
>>
>> Bernd
>>
>> Andreas Niemeyer schrieb:
>>> Hi,
>>>
>>> I would like to send form data from a JSF page for a servlet request
>>> with a navigation rule.
>>>
>>> The servlet returns a content type of "application/pdf" and is running
>>> in a context path.
>>>
>>> If I call it from within a action method, it works with following code:
>>>
>>> public String createPDFReport() {
>>> ...
>>>  FacesContext context = FacesContext.getCurrentInstance();
>>>  ExternalContext ext = context.getExternalContext();
>>>
>>>  String vServletPath = "/context_path/pdf-test";
>>>  ext.redirect(ext.encodeResourceURL(vServletPath));
>>>
>>>  ...
>>>  return "call_servlet";
>>> }
>>>
>>>
>>> My context is a portal, I'm using the JSF portal bridge.
>>>
>>>
>>> The web.xml looks like:
>>>
>>> ...
>>> <servlet>
>>>  <servlet-name>pdf-test</servlet-name>  
>>>  <servlet-class>com.xxx.PDFTest</servlet-class>
>>>  <load-on-startup>20</load-on-startup>
>>> </servlet>    ...
>>>
>>> I would like to avoid to send a redirect and would prefer to create a
>>> navigation rule in the faces-config, but it fails with an exception
>>> arised from my GenericPortlet
>>>
>>> ...
>>>
>>> public class JSFGenericPortlet
>>>     extends org.apache.myfaces.portlet.MyFacesGenericPortlet {
>>> ...
>>> public void render(RenderRequest req, RenderResponse res)
>>>         throws IOException, PortletException {
>>> ...
>>> super.render(req, res);
>>> }
>>> ...
>>> }
>>>
>>> javax.portlet.PortletException: String index out of range: -1
>>>         at
>>> org.apache.myfaces.portlet.MyFacesGenericPortlet.handleExceptionFromLifecycle(MyFacesGenericPortlet.java:310)
>>>
>>>
>>>         at
>>> org.apache.myfaces.portlet.MyFacesGenericPortlet.facesRender(MyFacesGenericPortlet.java:502)
>>>
>>>
>>>         at
>>> org.apache.myfaces.portlet.MyFacesGenericPortlet.doView(MyFacesGenericPortlet.java:323)
>>>
>>>
>>>         at
>>> javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
>>>         at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
>>>         at
>>> com.gutzmann.portlets.JSFGenericPortlet.render(JSFGenericPortlet.java:73)
>>>
>>>
>>>
>>> The navigation rule looks like:
>>>
>>>     <navigation-rule>
>>>         <from-view-id>/pages/view.xhtml</from-view-id>
>>>         <navigation-case>
>>>             <from-outcome>call_servlet</from-outcome>
>>>             <to-view-id>/pdf-test/</to-view-id>
>>>         </navigation-case>
>>>     </navigation-rule>
>>>
>>> I tried also `<to-view-id>/context_path/pdf-test/</to-view-id>' - same
>>> exception.
>>>
>>>
>>>
>>> What is the "best practice" to do such redirect / servlet calls?
>>>
>>>
>>> If request parameter should be changed, how would it work in the action
>>> method?
>>>
>>>
>>> Many thanks fro some help!
>>>
>>>
>>> Regards,
>>> Andreas
>>>
>>>
>>>
>>>
>>>
>>>
>>
> 
> 

Reply via email to