Problem combining ice:commandButton with s:link for PDF download
[Logo]
Forums for ICEfaces and ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
Problem combining ice:commandButton with s:link for PDF download  XML
Forum Index -> JBoss Seam Integration Go to Page: 1, 2 Next 
Author Message
nordmeyer

Joined: 18/08/2008 00:00:00
Messages: 13
Offline


Hi,

I am trying to download a pdf stream using icefaces with seam. I started using an ice:commandButton, but then no download dialog did open. Replacing the button with a s:link, the download is fine, but my ice:commandButtons on the same page are out of order. Tracing the events on browser side (Firefox 3.0) with Firebug, I find
[window] Interup pressed
for each push to the button. The button stays dead even when I end the download, no matter if I perform it to the end or cancel it.

When klicking onto another s:link, my ice:commandButtons are back working.

Did anyone have similar problem - and solved it?

Maybe anyone knows, how to perform the download with the ice:commandButton or how to keep the buttons alive after the download-klick.

CU,
Thomas
jguglielmin

Joined: 20/07/2007 00:00:00
Messages: 181
Offline


What are you using for the pdf download....your own servlet?
Which versions of Seam, ICEfaces, which application server?
nordmeyer

Joined: 18/08/2008 00:00:00
Messages: 13
Offline


Hi jguglielmin,
I am running Seam 2.0.2.GA with Icefaces 1.7.1_6.

I am generating PDF using iText, writing the data directly into the HttpResponse's OutputStream (similar to Samuels solution: http://www.seamframework.org/Documentation/HowToUploadAndDownloadFilesInSeam)

kenny posted in this Forum a problem similar to mine (http://www.icefaces.org/JForum/posts/list/3165.page) but unfortunately, his solution seems not to fit my problem as it points to a phisical file on file system.

In the meantime I solved the problem by moving the download link to a page where no ice buttons are on and no form submit is done. But I expect this behavior to be a more common problem.

Thanks for thinking.

CU,
thomas
jguglielmin

Joined: 20/07/2007 00:00:00
Messages: 181
Offline


are you using jsf-delegation? (with the just-ice.jar)??

We have an open jira for seam-pdf integration, so you if you have a sample app you can attach (for other users) that would be very helpful. Please attach any samples, significant code, problems, etc to the jira
nordmeyer

Joined: 18/08/2008 00:00:00
Messages: 13
Offline


Hi,

There is no just-ice.jar in my CP.

I tried to strip down the code. What you find now is the java source (compilable when iText, Seam and JBoss jars are in classpath) and a sketch of the xhtml I used. Look at TermsheetBean.java and view.xhtml, maybe DownloadReportContext.java. I don't expect the other files to contain helpful information.

Hope, this helps you reproducing the problem.

CU,
Thomas
 Filename dead-button-test.zip [Disk] Download
 Description Java classes and xhtml (hopefully) reproducing the problem.
 Filesize 17 Kbytes
 Downloaded:  120 time(s)

jguglielmin

Joined: 20/07/2007 00:00:00
Messages: 181
Offline


Thanks....once ICEfaces1.7.2 is out, I'm going to (try) get a working example of seam-pdf with ICEfaces (using jsf-delegation). Technically it should work (have you seen the seam-mail example with ICEfaces?? It uses jsf-delegation and so should seam-pdf).
nordmeyer

Joined: 18/08/2008 00:00:00
Messages: 13
Offline


Hi jguglielmin,
sorry, if my excerpt is not too helpfull, but extracting and testing is quiet time expensing and I am far from beeing ICE or Seam expert.
I am not working with seam-pdf (the xhtml-part or DocumentStore) but plain iText. You could use any other data feeding the OutputStream, I believe.
This is te first time I hear about "jsf-delegation". Can you tell me where to read more about this? (Google told me about "Japan Special Fund (JSF) delegation." in Nepal -- nono, I see, this is the wron track.)

CU,
Thomas
jguglielmin

Joined: 20/07/2007 00:00:00
Messages: 181
Offline


There is a section in the Developer's Guide as well as an example for seam-mail attached to jira 2321
nordmeyer

Joined: 18/08/2008 00:00:00
Messages: 13
Offline


Hi,
I am back at this problem, my workaround died yesterday: We now need both, ice:commandButtons and some kind of download button on the same page.

I'am sorry, but I still don't understand your solution, Judy. I tried, but somehow it seems to me to solve some but not my problem.

With a few more weeks in ICEfaces and Seam I try to describe it again, I think, it is quiet simple to solve for someone who is deeper in matter:

On my pages I usually operate using ICE commandButtons which call some ActionBean methods. As ICE buttons are rendered as HTML input tags, there is no way to use them starting a download of any kind. Right?
Now I add a second type of button to the page, s:link from the Seam library. Connecting this button to a ActionBeanMethod
Code:
myBean.download()

In this method I write my load (the PDF file) to the stream returned by
Code:
((HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext()). getOutputStream();
 

, set some header info (like content type) and finalize the stream with
Code:
  
   stream.flush();
   stream.close();
   FacesContext.getCurrentInstance().responseComplete();
 

This procedure leads to the result I wanted: After Klicking the button, the browser's Download Popup opens an I can happily download my File.

BUT: After this done, all my ICE commandButtons don't fire anymore.
My Firebug plugin says
Code:
[window.KQdo#1.sync-connection] [8615404] : receive [200] OK
 [window.KQdo#1.sync-connection] receive broadcast failed TypeError: X is null message=X is null
 [window.KQdo#1.sync-connection] [8615404] : connection closed

which I don't understand at all.

Has someone a simple understandable solution for making a file download available while keeping the ICE buttons alive?

CU,
Thomas
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1043
Offline


sorry, but I'm not too sure I understand totally what it is you would like to do. If you want to open a pdf file, then you can use the <ice:outputResource> component (if you are using 1.7.2 release of ICEfaces). There is a sample of it in the latest seam-comp-showcase download.

If you want to create a pdf from html (facelets page), you can either use itext directly or try to use seam-pdf (which theoretically should work using jsf-delegation similar to the example for seam-mail that I referred to).

If it's something different, maybe you want to create a simple application and attach it here with some reference to it and where it doesn't work. (or you can try to describe it again?). We can then look at the example (please make it as simple as possible as we're time strapped too).

nordmeyer

Joined: 18/08/2008 00:00:00
Messages: 13
Offline


Hi Judy,
I think the second comes closest to my problem. Creating PDF using iText.
As far as I understand, the mail example describes how to use ICEfaces to render some text and send it via email. But what I want to do, is to send the text as downloadable data back to the browser. This part works in my implementation, but browser-side ICE seams to die when the browser receives the data (or when sending the request).

I can't find any useful info about jsf-delegation anywhere. Maybe it's just the wrong keyword but as I don't know at all what It means, I cannot vary it.

Can you send me the link to the page in the developer's guide?

Thanks,
Thomas

P.S.: Maybe someone else understands my gebabbel and can translate it to human language so Judy does understand - sorry for my bad English.
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1043
Offline


OK....I think I understand now...are you trying to use seam-pdf or are you using itext without the jboss-seam-pdf module?
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1043
Offline


In the ICEfacesDevelopersGuide, p 17, 18 on JSF Integration. I just looked at it and there isn't much there, but there is also more on p 21 of the same document (Configuration Reference). Basically, you are delegating the non-icefaces tags (anything that isn't ice: so this includes h:) to use the jsf ViewHandler. You package just-ice.jar instead of icefaces.jar which will do the rendering of the pages which contain ONLY the <ice:> tags.

In web.xml you use the following context-param
<param-name>com.icesoft.faces.delgateNonIface</param-name>
<param-value>true</param-value>

You would also have to do a servlet-mapping for the Faces Servlet for the extension of your non-icefaces pages. The servlet-mapping for Persistent Faces Servlet would remain the same as typical application.
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1043
Offline


i have a working example of seam-pdf and ICEfaces using jsf delegation that I will clean up and post on Monday to the jira and will put a link here.
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1043
Offline


please see ICE-2114 for sample application of ICEfaces and seam-pdf
 
Forum Index -> JBoss Seam Integration Go to Page: 1, 2 Next 
Go to:   
Powered by JForum 2.1.7ice © JForum Team