-
FEATURED COMPONENTS
First time here? Check out the FAQ!
When I click report button Iframe setContent() is not working correctly.
I coding with iframe src="xxx" as a initial value that's working... but click the button same... not working.
when I click the button continually hanging the return value...
Report Servlet return the pdf file.
I don't know why not working...
I use version 5.0.1
Thank you so much.
1. print.zul source
=============================
<?page title="Email" contentType="text/html;charset=UTF-8"?>
<zk>
<borderlayout apply="com.event.ReportTestController" id="mainLayout" height="100%">
<north maxsize="24" size="24" border="0">
<hbox>
Choice the file type : <listbox id="format" mold="select" >
<listitem label="PDF" value="pdf" selected="true" />
<listitem label="XML" value="xml" />
<listitem label="HTML" value="html" />
<listitem label="Word (RTF)" value="rtf" />
<listitem label="Excel" value="xls" />
<listitem label="Excel (JXL)" value="jxl" />
<listitem label="CSV" value="csv" />
<listitem label="OpenOffice (ODT)" value="odt" unless="false"/>
</listbox>
<button label="Report!" id="report_btn" />
</hbox>
</north>
<center border="none" >
<iframe id="report" style="width:500px; height:400px;border:3px inset;" />
</center>
</borderlayout>
</zk>
=============================
2. com.event.PrintReportController.java
=============================
import java.sql.Connection;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zkex.zul.Jasperreport;
import org.zkoss.zul.Iframe;
public class ReportTestController extends GenericForwardComposer {
/**
*
*/
private static final long serialVersionUID = -7315856983395276171L;
public void onClick$report_btn(Event event) {
Iframe report = null;
try {
System.out.println("test1");
report = (Iframe) Path.getComponent("/report");
System.out.println("test2");
report.setContent(new org.zkoss.util.media.AMedia("report.pdf" , "pdf", "application/pdf", new java.net.URL("http://www.xxx.com:8080/xxx/ReportServlet"), null) );
System.out.println("test3");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
=============================
It works try this code : private Iframe frame; String path ="C:/Users/user/file/toto.pdf" File f = new File(path); org.zkoss.util.media.AMedia mymedia = null; try {media = new AMedia(f, "application/pdf", null); } catch (FileNotFoundException e1) { e1.printStackTrace(); } if (media != null) frame.setContent(media);
Asked: 2010-06-05 14:40:43 +0800
Seen: 1,075 times
Last updated: Jan 30 '14