Revision history [back]

click to hide/show revision 1
initial version

answered 2010-12-16 05:13:29 +0800

robertpic71 gravatar image robertpic71

Here the code using an own printwindow:

The mainfunction, code when print button is clicked: ..

// open print.zul in a new window
public void onPrint(Event event) {
        StringBuffer sb = new StringBuffer();
        sb.append("print.zul?id=");
        sb.append(model.getPlanung().getId());
        sb.append("&kid=");
        sb.append(model.getPlanung().getKunde().getId());
        sb.append("&rab=");
        sb.append(model.getPlanung().getRabatt());
        sb.append("&netto=");
        sb.append(true);
        System.out.println("Url " + sb.toString());
        Executions.getCurrent().sendRedirect(sb.toString(), "Print Window");
    }
..

The PrintController (print.zul: ...<window id="printWin" apply="${printController}" ----)<="" p="">

@Repository("printController") 
@Scope("prototype")
public class PrintController extends GenericForwardComposer {

    private static final long serialVersionUID = -7456868519044922719L;
    private AnnotateDataBinder binder;
    ...
    @Autowired
    LoginData loginData;

    @Override
    public void doAfterCompose(Component _win) throws Exception {
        super.doAfterCompose(_win);
        binder = new AnnotateDataBinder(_win);
        binder.bindBean("controller", this);
        checkParms();   // parse url
        load();             // load the plan
        binder.loadAll(); // load UI (databinding)
        Clients.print();   // fire the printdialog 
        Clients.evalJavaScript("window.close()"); // close the printwindow
    }

If i found some time, i try the iframe-variant. This shoudl really an invisible solution: inside the main.zul <iframe id="printarea" width="1px" height="1px"/>

and instead of: Executions.getCurrent().sendRedirect(sb.toString(), "Print Window"); --> printarea.setSrc(sb.toString());

/Robert

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