why don't you put the zscript in your controller? Like that you know that PROJECT_MENU is initialisized
chillworld ( 2015-02-16 20:11:03 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello.
I've upgraded my project to ZK 7.0.3. My main page used the composer that extends GenericForwardComposer:
<window id="main" width="100%" height="100%" apply="myproject.web.MainLayoutComposer">
However, I see that doAfterCompose method in MainLayoutComposer is not invoked at all (I have super.doAfterCompose(comp) call at the beginning of this method) which leads to application crash. Could you please help me to find out - why this method is not called?
UPD. I've found out that the problem is with <include src="menu.zul"/>. Something is wrong with menu.zul. I'll try to investigate and if I have more questions on it I'll ask.
in ZK 6.0.0 the scripting engine in ZK was changed to allow additional languages and control over the execution of zscript elements see: http://www.zkoss.org/product/zk/releasenote/6.0.0
according to the API docs (http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/metainfo/ZScriptInfo.html) there were additions to the zscript API to enable that feature.
The option deferrable="true" pm the <zscript> element might do the trick to postpone the execution far enough. Otherwise you need to find out when the session.setAttribute("PROJECT_MENU", yourmenu); is called and ensure the <zscript/> is called later. Or even consider initializing the menu right when you create it.
I am some what worried, that you are storing menu information in a session-scoped attribute, as this will lead to conflicts in case the user opens more than one browser tab of the same application (I'd suggest a "desktop.get/setAttribute", to be sure it is a new instance for each browser tab)
Anyway as chill already pointed out, <zscript> is more useful for prototyping and loading up the script engine will slow down your pages. Anything that can be done in a <zscript can="" be="" done="" in="" a="" doaftercompose="" method="" of="" a="" composer="" as="" well,="" and="" will="" execute="" much="" faster.="" and="" in="" a="" way="" you="" have="" more="" control="" about.<="" p="">
<zscript>
<![CDATA[
import java.util.*;
import myproject.web.menu.*;
import org.springframework.security.context.*;
ProjectMenu menu = (Project) session.getAttribute("PROJECT_MENU");
List items = new ArrayList();
if(menu==null){
ProjectMenuItem item = new ProjectMenuItem(null, null, null);
items.add(item);
} else {
items = menu.getSelectedPath();
}
]]>
</zscript>
The check for "menu=null" is added by me to avoid crash - initially it just called the "getSelectedPath" method. The ProjectMenu object is initialized and saved into session in composer.
why don't you put the zscript in your controller? Like that you know that PROJECT_MENU is initialisized
chillworld ( 2015-02-16 20:11:03 +0800 )editI can't upload the project - it's too big and is a commercial one. However this is what I found: the zul in "include" tag contained zscript code that used some object, initialized in composer - and this code was launched BEFORE composer code. That lead to null pointer and crash. I'm new to ZK and for some reason I was sure that doAfterCompose is invoked first (in previous version it was so, I think). So, is it possible that zscript code in included zul is launched before the composer, applied to the page with "include" tag?
Hi Darksu,
Unfortunately the problem is not solved yet. On ZK 7.0.3 doAfterCompose is not invoked on any page. I currently try to launch my applicaion on 5.0.12 - I managed to do it by removing <include src="menu.zul"/>, but the functionality seems to be partially broken (some properties of ZK tags do not work, I got "Unknown idspace: null" exception occasionally, etc.). I tried on different workspaces (and computers), on Tomcat 6 and 7 - everything is the same. I have to use Java 1.6, since production servers have this version.
Is it possible we can get the project or at least the config with some pages
chillworld ( 2015-02-16 05:23:32 +0800 )editHello sleb82,
I just imported your project to my work-space and it works as expected.
Do you still have the problems you mentioned before? If you still have then i recommend creating a new work-space, download again the latest zk libraries and with java 1.7 and re-test the application.
Best Regards,
Darksu
Asked: 2015-02-09 11:27:22 +0800
Seen: 44 times
Last updated: Feb 17 '15
the initial example on http://zkfiddle.org/ shows a working override of GenericForwardComposer can you compare what you are doing differently or place your reproducing code there? and post a link to your example here so I can have a look?
cor3000 ( 2015-02-10 01:08:01 +0800 )editHi. Thanks for reply. I've updated the initial post with code samples. According to ZK documentation stating composer in "apply" property of the window tag is pretty much enough to make it work in any version. So I'm really confused why doAfterCompose is not invoked for me when I move from 3.6.4.
sleb82 ( 2015-02-10 16:17:08 +0800 )editI have another project on ZK 5.0.5 - composer works OK there, but when I moved all jars from that project to the current project the issue was not resolved. Config files are also the same. Really weird.
sleb82 ( 2015-02-10 23:08:51 +0800 )edithere your example running on zk fiddle (http://zkfiddle.org/sample/2fgdol8/1-doAfterCompose-called) with some adjustments, so your assumption about incorrect jar-files may be right.
cor3000 ( 2015-02-11 00:25:22 +0800 )editUpdated the initial post wih my recent findings.
sleb82 ( 2015-02-11 22:45:04 +0800 )edit