-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am sorry if this question seems a bit rediculous, but I'm still pretty new to ZK, and java in general.
I am consistently been unsuccessful with "use"ing or "apply"ing classes. I tried this little tutorial, as an example...
How to load tab contents on demand http://www.zkoss.org/smalltalks/netbeans2/netbeans2.dsp
And I get this as an exception "org.zkoss.zk.ui.UiException: java.lang.ClassNotFoundException: com.MyTabbox"
Likewise, this is the root cause "java.lang.ClassNotFoundException: com.MyTabbox"
When I try to use or apply a class the normal error is the 'ClassNotFoundException:' for what ever the name of the class is
Can anyone help me understand why I'm not able to use or apply classes?
I use tomcat 6, if that makes much of difference.
Thank you for any and all of your help
can you provide you project config and test code ?
i think you didn't have right classpath or compile the source correctly .
Here is the code...
index.zul
<zk> <window id="root"> <tabbox use="com.MyTabbox" id="tabbox" width="100%" > <tabs> <tab label="Preload"/> <tab label="OnDemand 1"/> <tab label="OnDemand 2"/> </tabs> <tabpanels> <tabpanel> This panel is pre-loaded. </tabpanel> <tabpanel id="second"> <include id="secondContent" src=""/> </tabpanel> <tabpanel id="third"> <include id="thirdContent" src=""/> </tabpanel> </tabpanels> </tabbox> </window> </zk>
package com; import org.zkoss.zk.ui.Desktop; import org.zkoss.zk.ui.Path; import org.zkoss.zul.Include; import org.zkoss.zul.Tabpanel; public class MyTabbox extends org.zkoss.zul.Tabbox { private int i=0; public void onSelect() { i++; Tabpanel item = getSelectedPanel(); Desktop desktop = this.getDesktop(); desktop.setAttribute("time",i); if(item != null && item.getId().equals("second")) { Include inc = (Include)Path.getComponent("/root/secondContent"); inc.setSrc("secondTab.zul"); } if(item != null && item.getId().equals("third")) { Include inc = (Include)Path.getComponent("/root/thirdContent"); inc.invalidate(); inc.setSrc("thirdTab.zul"); } } }
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>testing with the load on demand</display-name> <listener> <description> Used to cleanup when a session is destroyed</description> <display-name> ZK Session Cleaner</display-name> <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class> </listener> <servlet> <description> The servlet loads the DSP pages.</description> <servlet-name>dspLoader</servlet-name> <servlet-class> org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class> </servlet> <servlet> <description> ZK loader for ZUML pages</description> <servlet-name>zkLoader</servlet-name> <servlet-class> org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> <init-param> <param-name>update-uri</param-name> <param-value>/zkau</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <description> The asynchronous update engine for ZK</description> <servlet-name>auEngine</servlet-name> <servlet-class> org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>dspLoader</servlet-name> <url-pattern>*.dsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zhtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> <welcome-file>index.zul</welcome-file> </welcome-file-list> </web-app>
Hi James,
can you check, that there's a file called MyTabbox.class in tomcat/webapps/YourApplication/WEB-INF/classes/com? If not, you'll have to change your deployment to make it work.
Cheers, Maik
there was not.
I've tried a couple of different deployment options, non of which created that file. I created one... not sure what all was supposed to be in it, but i put the same code as MyTabbox.java.
I got this error...
java.lang.ClassFormatError: Incompatible magic value 1885430635 in class file com/MyTabbox
if you use eclipse
you should use Dynamic Web Project
or you have to copy the class to your classpath
(Default is WEB-INF/classes/ )
Hey... You know, I have been using the "Dynamic Web Project" and it hasn't worked. When I did it again, just to be sure and do as you said, I noticed this little option "Dynamic Web Module version" it defaults to 2.4 I changed it to 2.5 and it works now. I had previously just kept it as the default.
Thanks everyone for your time and help.
It works now
Asked: 2009-01-16 20:57:00 +0800
Seen: 669 times
Last updated: Jan 20 '09