0

Iframe setContent() not working

asked 2010-06-05 14:40:43 +0800

nextbiz gravatar image nextbiz
9 2

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());
}
}


}
=============================

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-06-10 03:27:53 +0800

vinhvo gravatar image vinhvo
369 3

DId you find solution ?
Thax.

link publish delete flag offensive edit

answered 2010-06-10 19:59:35 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

@nextbiz,

Please post to ZK bugs so we can track it. Thanks.

link publish delete flag offensive edit

answered 2014-01-30 22:59:39 +0800

codesambinfo gravatar image codesambinfo
0

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);

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-06-05 14:40:43 +0800

Seen: 1,075 times

Last updated: Jan 30 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More