-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I'm trying to create a portal based on the demo's business portal sample. That portal will be updated using a Thread.
My problem is that I can't access the included portlet's components from the Thread using
Path.getComponent("/main/myinclude-1").getFellow("myTree")
window.getFellow("myinclude-1").getFellow("myTree")
indez.zul:
...
<window id="main" border="none" apply="MyPortalCtrl" >
MyPortalCtrl.java:
...
public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); loadConfiguration(); // Here we init all portlets as in the sample demo business portal MyThread cli = new MyThread((Window)comp);
MyThread.java:
...
public MyThread(Window w) { window = w; desktop = window.getDesktop(); if(!desktop.isServerPushEnabled()){ desktop.enableServerPush(true); } // try { // Executions.activate(desktop); // } catch (Exception e) { // log.error(e.getMessage()); // } myTree = (Tree) ((Include)window.getFellow("myinclude-1")).getFellow("myTree"); myTree.setModel((new DefaultTreeModel( new DefaultTreeNode(null, new DefaultTreeNode[] {} ) )); // Executions.deactivate(desktop); startMyThread(); }
...
It seems like if the Included pages components are not yet available, even when I added them with the "instant" mode, because if later I try to access them, the included pages components -like myTree- are there and I access them using the getFellow method.
Another topic is that if I try to execute the "Executions.activate(desktop)" method before trying to acces the component, the page loading gets paused on that point, and does not continues at all, like if it was waiting for some other thread to finish.
So, in the end, my question is: is there any way of having the included pages components available before the "doAfterCompose()" method from the main window finishes?
Thanks in advance,
Vicente
I try to access component from included zul at "doAfterCompose()", but it works fine.
Here are my codes, I use ZK 6.0.1 :
index.zul
<window id="win" apply="MyComposer"> <include id="inc" src="inc.zul" /> </window>
inc.zul
<label id="msg" value="none" />
MyComposer.java
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Path; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zul.Label; import org.zkoss.zul.Window; public class MyComposer extends SelectorComposer<Window> { @Override public void doAfterCompose(Window win) throws Exception { super.doAfterCompose(win); Component comp = Path.getComponent("/win/inc"); comp = comp.getFellow("msg"); ((Label)comp).setValue("Hello!"); } }
Asked: 2012-07-07 09:11:21 +0800
Seen: 137 times
Last updated: Aug 23 '12