0

ZK 7.0.3 doAfterCompose is not called for GenericForwardComposer

asked 2015-02-09 11:27:22 +0800

sleb82 gravatar image sleb82
1 1

updated 2015-02-11 22:45:26 +0800

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.

delete flag offensive retag edit

Comments

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

Hi. 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 )edit

I 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 )edit

here 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 )edit

Updated the initial post wih my recent findings.

sleb82 ( 2015-02-11 22:45:04 +0800 )edit

5 Answers

Sort by ยป oldest newest most voted
0

answered 2015-02-14 08:53:18 +0800

Darksu gravatar image Darksu
1991 1 4

Hello 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

link publish delete flag offensive edit
0

answered 2015-02-15 19:08:25 +0800

sleb82 gravatar image sleb82
1 1

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.

link publish delete flag offensive edit

Comments

Is it possible we can get the project or at least the config with some pages

chillworld ( 2015-02-16 05:23:32 +0800 )edit

definitely we need a reproducing example here, since I use <include/> every day without ever seeing this error message.

cor3000 ( 2015-02-16 06:08:19 +0800 )edit
0

answered 2015-02-16 17:01:56 +0800

sleb82 gravatar image sleb82
1 1

I 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?

link publish delete flag offensive edit

Comments

post that zscript plz

chillworld ( 2015-02-16 18:23:46 +0800 )edit
0

answered 2015-02-16 19:03:38 +0800

sleb82 gravatar image sleb82
1 1
    <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.

link publish delete flag offensive edit

Comments

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
0

answered 2015-02-17 01:07:15 +0800

cor3000 gravatar image cor3000
4293 1 7
ZK Team

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

link publish delete flag offensive edit
Your answer
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
2 followers

RSS

Stats

Asked: 2015-02-09 11:27:22 +0800

Seen: 38 times

Last updated: Feb 17 '15

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