myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nebinger, David" <dnebin...@tbbgl.com>
Subject RE: response.Header() not working in JSF Portlet
Date Tue, 21 Nov 2006 14:26:21 GMT
I'd guess that by returning null (assuming this is an action method), faces will redirect back
to the form (although you don't indicate what happens when you do submit).

Just a guess, but I'd try returning an actual string which, in the nav map will need to be
coded with a <redirect /> in order to get the result you're looking for.

> -----Original Message-----
> From: pals [mailto:pallavi.roy@wipro.com]
> Sent: Monday, November 20, 2006 11:50 PM
> To: users@myfaces.apache.org
> Subject: Re: response.Header() not working in JSF Portlet
> 
> 
> 
> Hi All,
> 
>        Please give me any suggestions to proceed.:-(
> 
> Best Regards,
> Pals
> 
> pals wrote:
> > 
> > 
> > Hi All,
> >          I have a JSF portlet where i want to save the 
> contents of my
> > Text area on the click of a button to a word document.
> >          (IBM Websphere portal)
> > 
> > 
> >      <h:inputTextarea id="text1"
> > value="#{pc_TextAreaView.textAreaValue}" rows="10" cols="50" />
> >      <h:commandButton id="save" value="Save As Word"
> > action="#{pc_TextAreaView.SaveAsWord}"/>
> > 
> > 
> > In my page bean i have written the follwoing code but the
> > response.setHeader() doesn't seem to work.
> > I am not getting any pop dialog and i cannot save my file.
> > Please let me know what is wrong in this code snippet.How 
> can i make it
> > work in my portlet.
> > 
> > 
> > 
> ==============================================================
> ==========
> > =======
> > 
> > 
> > public String SaveAsWord() {
> >  
> > 
> >   FacesContext context = FacesContext.getCurrentInstance();
> >   HttpServletResponse response =
> > (HttpServletResponse)context.getExternalContext().getResponse();
> >   response.setContentType("application/vnd.ms-word");
> >      response.setHeader("Content-Disposition", "attachment;
> > filename=myfile.doc");
> > 
> >      response.setHeader("Cache-Control", "no-cache");
> >      try{
> >      byte[] buf=new byte[4*1024];
> >      InputStream inStream=new
> > ByteArrayInputStream(textAreaValue.getBytes());
> >      OutputStream outStream=response.getOutputStream();
> >      int sizeRead;
> >      while ( ( sizeRead=inStream.read(buf, 0, buf.length) ) != -1 )
> >        {
> >        outStream.write(buf, 0, sizeRead);
> >        }
> >      inStream.close();
> >      outStream.close();
> >   }
> >      catch(IOException ex){
> >       ex.printStackTrace();
> >       }
> >      return null;
> >   }
> > 
> > 
> > Best Regards,
> > Pallavi
> > 
> > 
> >  
> > 
> > 
> > 
> > 
> > The information contained in this electronic message and 
> any attachments
> > to this message are intended for the exclusive use of the 
> addressee(s) and
> > may contain proprietary, confidential or privileged 
> information. If you
> > are not the intended recipient, you should not disseminate, 
> distribute or
> > copy this e-mail. Please notify the sender immediately and 
> destroy all
> > copies of this message and any attachments.
> > 
> > 
> > WARNING: Computer viruses can be transmitted via email. The 
> recipient
> > should check this email and any attachments for the 
> presence of viruses.
> > The company accepts no liability for any damage caused by any virus
> > transmitted by this email.
> > 
> > 
> > www.wipro.com
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/response.Header%28%29-not-working-in-JSF
-Portlet-tf2668471.html#a7465840
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message