package de.forsthaus.webui.codes; import java.io.Serializable; import org.apache.log4j.Logger; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Path; import org.zkoss.zk.ui.event.Event; import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Iframe; import org.zkoss.zul.Intbox; import org.zkoss.zul.Window; import de.forsthaus.webui.util.GFCBaseCtrl; /** * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br> * This is the controller class for the /WEB-INF/blog/blog.zul file. <br> * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br> * * @author bbruhns * @author sgerth */ public class CodesCtrl extends GFCBaseCtrl implements Serializable { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(CodesCtrl.class); /* * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * All the components that are defined here and have a corresponding * component with the same 'id' in the zul-file are getting autowired by our * 'extends GFCBaseCtrl' GenericForwardComposer. * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ protected Window windowCodes; // autowired protected Borderlayout borderLayout_Codes; // autowired protected Iframe iFrameCodes; // autowired /** * default constructor.<br> */ public CodesCtrl() { super(); } @Override public void doAfterCompose(Component window) throws Exception { super.doAfterCompose(window); /** * 1. Set an 'alias' for this composer name to access it in the * zul-file.<br> * 2. Set the parameter 'recurse' to 'false' to avoid problems with * managing more than one zul-file in one page. Otherwise it would be * overridden and can ends in curious error messages. */ this.self.setAttribute("controller", this, false); } // +++++++++++++++++++++++++++++++++++++++++++++++++ // // +++++++++++++++ Component Events ++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // /** * Automatically called method from zk. * * @param event * @throws Exception */ public void onCreate$windowCodes(Event event) throws Exception { doFitSize(); iFrameCodes.setSrc("http://sourceforge.net/projects/zksample2/"); } /** * when the "refresh" button is clicked. <br> * <br> * * @param event * @throws InterruptedException */ public void onClick$btnRefresh(Event event) throws InterruptedException { doFitSize(); } // +++++++++++++++++++++++++++++++++++++++++++++++++ // // +++++++++++++++++ Business Logic ++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // // ++++++++++++++++++++ Helpers ++++++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // /** * Recalculates the container size for this controller and resize them. * * Calculate how many rows have been place in the listbox. Get the * currentDesktopHeight from a hidden Intbox from the index.zul that are * filled by onClientInfo() in the indexCtroller. */ public void doFitSize() { // normally 0 ! Or we have a i.e. a toolBar on top of the listBox. final int specialSize = 26; final int height = ((Intbox) Path.getComponent("/outerIndexWindow/currentDesktopHeight")).getValue().intValue(); final int maxListBoxHeight = height - specialSize - 88; this.borderLayout_Codes.setHeight(String.valueOf(maxListBoxHeight) + "px"); borderLayout_Codes.invalidate(); } }