You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by robinhoo <ro...@gmail.com> on 2006/03/05 16:43:36 UTC

Hi! I have implemented an upload Component into my application. The user can also upload msg (MS Outlook) Files from there. I have Problem in setting the MIME Type in JSF.

Hi!
Please help!
I have Problem in setting the MIME Type in JSF.
I Implemented a method called "createXReport" that create report using JXL
and output it on the outputStream directly.
that result in a dialog asking the user either to save or to open this
report which is an excel report but this dialogue when return it say that it
is an HTML page not Excel.
and there exist a JSF page with commandButton that when clicked call this
method  but what happens is that the returned streamData
didn't have the content type I set it in my createXReport.

and this is the JSF page code's  "ReportsScreen.jsp"

<h:commandButton id="GenerateXReport" value="create XReport" title="Generate
X report" action = "#{reports.generateXReport}"/>

and this is the Method Code

public void generateSalaryReport() {
  FacesContext faces = FacesContext.getCurrentInstance();
  HttpServletResponse response =
(HttpServletResponse)faces.getExternalContext().getResponse();

 OutputStream out = null;
  try{
          response.setHeader("Content-Disposition", "attachment; filename=
XReport.xls");
          response.setContentType("application/vnd.ms-excel");

          WritableWorkbook w = Workbook.createWorkbook(
response.getOutputStream());
          WritableSheet s = w.createSheet("XReport", 0);

            // writing the headers columns.
            s.addCell(new Label(0, 0, "Date"));

.....................................................................................
            List X = _reportingService.getXReport();
            Iterator it = X.iterator();

......................................................................................

            w.write();
            w.close();

        } catch (Exception e)
        {
            _logger.error("Exception in Excel Sample Servlet\n" + e.getCause
());
        }
}

thanx in advance
--
Ali Abd El Aziz Ali

Re: Hi! I have implemented an upload Component into my application. The user can also upload msg (MS Outlook) Files from there. I have Problem in setting the MIME Type in JSF.

Posted by robinhoo <ro...@gmail.com>.
sorry for the title I was coping this title from a previous email and by
fault I past it her so forgive me.
 and please if any one have solution please help me

On 3/5/06, robinhoo <ro...@gmail.com> wrote:
>
> Hi!
> Please help!
> I have Problem in setting the MIME Type in JSF.
> I Implemented a method called "createXReport" that create report using JXL
> and output it on the outputStream directly.
> that result in a dialog asking the user either to save or to open this
> report which is an excel report but this dialogue when return it say that it
> is an HTML page not Excel.
> and there exist a JSF page with commandButton that when clicked call this
> method  but what happens is that the returned streamData
> didn't have the content type I set it in my createXReport.
>
> and this is the JSF page code's  " ReportsScreen.jsp"
>
> <h:commandButton id="GenerateXReport" value="create XReport"
> title="Generate X report" action = "#{reports.generateXReport}"/>
>
> and this is the Method Code
>
> public void generateSalaryReport() {
>   FacesContext faces = FacesContext.getCurrentInstance();
>   HttpServletResponse response =
> (HttpServletResponse)faces.getExternalContext().getResponse();
>
>  OutputStream out = null;
>   try{
>           response.setHeader("Content-Disposition", "attachment; filename=
> XReport.xls");
>           response.setContentType("application/vnd.ms-excel");
>
>           WritableWorkbook w = Workbook.createWorkbook(
> response.getOutputStream());
>           WritableSheet s = w.createSheet("XReport", 0);
>
>             // writing the headers columns.
>             s.addCell(new Label(0, 0, "Date"));
>
> .....................................................................................
>             List X = _reportingService.getXReport();
>             Iterator it = X.iterator();
>
> ......................................................................................
>
>             w.write();
>             w.close();
>
>         } catch (Exception e)
>         {
>             _logger.error("Exception in Excel Sample Servlet\n" +
> e.getCause());
>         }
> }
>
> thanx in advance
> --
> Ali Abd El Aziz Ali
>



--
Ali Abd El Aziz Ali
Software Developer OpenCraft
http://aabdelaziz.blogspot.com/