0

Problems accessing included pages components

asked 2012-07-07 09:11:21 +0800

cocoes gravatar image cocoes flag of Spain
94 6

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

or
    window.getFellow("myinclude-1").getFellow("myTree")

It just says that the component doesn't exist. I try to do it during the main zul page creation

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

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-08-23 10:51:50 +0800

paowang gravatar image paowang
140 6

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!");
	}
}

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: 2012-07-07 09:11:21 +0800

Seen: 137 times

Last updated: Aug 23 '12

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