[EMAIL PROTECTED] a écrit :
> I currently have a JSF popup that:
>
>    1. notifies the user to wait for a download to begin
>    2. uses Javascript (window.location = uriStr;) to redirect the page
>       to my download servlet that compiles tha data and writes  back
>       a  "csv/plain" response (using ServletOutputStream).
>
> It seems like there should be a better (cleaner) way to do this with
> MyFaces.  I haven't had any luck finidn a solution.
>
> Any suggestions?
>
> Thank you for your time.
>
Mmm not sure JSF should be implied specifically there.

You are getting a file from a specific servlet. Thus you do not use JSF
to download the file.

For the popup generation itself, what you can do is embed all the work
of writing the little popup generating javascript and rendering the link
button to a custom JSF component.
This way you could write this in your .jsp

<mylibrary:waitDownload url="/path/to/csv/servlet?get=myreport"
popup="/path/to/pleasewait.html" ><h:outputText value="get the
File!"/></mylibrary:waitDownload>

If you can afford a dependency to tomahawk project, you can even serve
the content of the popup as a html fixed in your .jar ressource an
simplify your tag like this :) (using addResource and AddResourceFactory)

<mylibrary:waitDownload url="/path/to/csv/servlet?get=myreport"
/><h:outputText value="get the File!"/></mylibrary:waitDownload>

Of course, creating this custom component is just a matter of reusing a
bit of html code in a constant way eveyrwhere. It's not very difficult
but can be seen as too much work to generalize 2 lines of html. You can
achieve the same with subview to include a small portion of form, or
with facelets that is using templates (but then you must be able to
abandon use of JSP for you faces).

Reply via email to