-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
Another 'lil problem.
I've got the following code:
Java:
import org.zkoss.zk.ui.util.GenericForwardComposer; //import org.zkoss.zkex.zul.Fisheye; import org.zkoss.zkex.zul.Fisheyebar; import org.zkoss.zul.Include; import org.zkoss.zul.Label; import org.zkoss.zul.Tab; import org.zkoss.zul.Tabbox; import org.zkoss.zul.Tabpanel; import org.zkoss.zul.Tabpanels; import org.zkoss.zul.Tabs; import org.zkoss.zul.Window; public class febTest extends GenericForwardComposer { //static private Fisheyebar febMenu; //autowired --Will be used to add fisheye objects to static private Label lblStatus; //autowired --Temporary for testing purposes //static private Tabbox tbxMain; //autowired --Needed to access tabs and tabpanels static private Tabs tbsMain; //autowired --Used for adding tabs static private Tabpanels tbpsMain; //autowired --Used for adding tabpanels public void onItemClicked(){ Tab tbNew=new Tab(); Tabpanel tbpNew=new Tabpanel(); Window winTest=new Window(); tbNew.setLabel("It Works!"); tbNew.setClosable(true); tbNew.setParent(tbsMain); Include test=new Include(); test.setSrc("/test.zul"); winTest.setHeight("100%"); winTest.appendChild(test); tbpNew.appendChild(winTest); tbpNew.setParent(tbpsMain); lblStatus.setValue("something's happened"); } }
And the zul file:
<window id="main" apply="febTest" height="100%"> <borderlayout height="100%" > <north> <label id="lblStatus" value="unchanged" /> </north> <center> <tabbox orient="vertical" width="100%" height="100%" id="tbxMain"> <tabs id="tbsMain" width="200px" /> <tabpanels id="tbpsMain" /> </tabbox> </center> <south title="Menu" collapsible="true" flex="true"> <window id="menu" height="80px" apply="febTest"> <div align="center"> <fisheyebar id="febMenu" attachEdge="center" itemMaxHeight="80" itemMaxWidth="80" style="position: relative; margin-top: 30px" labelEdge="top"> <fisheye id="feiTest" label="test" image="/images/background.png" forward="onClick=onItemClicked" /> </fisheyebar> </div> </window> </south> </borderlayout> </window>
I'm using tomcat on Ubuntu. As you can see, it's all in a state of testing and trying to figure out what I'm doing (thus the bad variable names and the like). Anyway, whenever I refresh the page, and then try to click on the item in the fisheyemenu, I get the following error:
Access denied: component, <Tabs tbsMain>, belongs to another desktop: [Desktop g05]
I'm lead to believe that I can leave garbage collection to Java. I did find this passage in the Apress ZK Ajax without the Javascript book:
"...once a component is detached from a page, it is no longer managed by ZK if the application does not keep any reference to it. The memory occupied by the component will be released by the Java Virtual Machine (JVM) garbage collector. However, if the application holds a reference to the component, it will not be collected with the garbage..."
So do I need to somehow remove the reference to the component in the Java file?
Thanks for any help you're able to offer.
Regards,
Nevyn.
@nevyn
There is another problem relating to your onClick event, this is not how you setup ZK using the MVC pattern.
Please take a look at this MVC tutorial!
Note that it is highly recommended to put your Java class into a package, maybe "test.febTest" and then specify the name in the Window's apply attribute apply="test.febTest"
Also note that the java function should read:
EVENT_NAME$CONTROL NAME(Event e)
therefore in your case the skeleton of the function should be
public void onClick$feiTest{ .... }
See if that gets you started!
Asked: 2009-12-14 04:30:07 +0800
Seen: 1,053 times
Last updated: Dec 15 '09