0

zk8 and client binder

asked 2016-01-19 19:32:09 +0800

afxgroup gravatar image afxgroup
126 1

Hello, I'm using zk8 (but also zk8.1) and i'm facing this problem.

I need to send a message from client to server using MVVM (with MVC i had no problems in the past). So in my MVVM class i have:

package com.papersoft;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;

public class TestViewModel {
private String myPage;

@Init
public void Init() {
    myPage = "testMVVM.zul";
}

@Command
@NotifyChange("myPage")
public void changePage(@BindingParam("page") String page) {
    System.out.println(page);
}

public String getMyPage() {
    return myPage;
}
public void setMyPage(String myPage) {
    this.myPage = myPage;
}
}

Then my simply zul test page

<zk xmlns:h="http://www.w3.org/1999/xhtml" xmlns:n="native" xmlns:zk="http://www.zkoss.org/2005/zk">
<div viewModel="@id('vm') @init('com.papersoft.TestViewModel')">
    <n:div id="pageManager"></n:div>
    <label value="@load(vm.myPage)"></label>
</div>
<script type="text/javascript">
    zk.afterMount(function() {
        var newPage = "test.zul";
        var binder = zkbind.$('$pageManager');
        if (binder)
            binder.command('changePage', {page: newPage });
    });
</script>
</zk>

I have no javascript errors but the changePage method on MVVM class is never fired. I've also tried to use @ToServerCommand but i have the same problem.

Can someone tells me what is wrong?

P.S. In ZK8.1 i have this error when the library starts:

GRAVE: Message code not found: 27112700 not in it:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul]
gen 19, 2016 8:26:14 PM org.zkoss.mesg.Messages getNotFound
GRAVE: Message code not found: 27112701 not in it:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul]
gen 19, 2016 8:26:14 PM org.zkoss.mesg.Messages getNotFound
GRAVE: Message code not found: 27112702 not in it:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul]
gen 19, 2016 8:26:14 PM org.zkoss.mesg.Messages getNotFound
GRAVE: Message code not found: 27112703 not in it:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul]
gen 19, 2016 8:26:14 PM org.zkoss.mesg.Messages getNotFound
GRAVE: Message code not found: 27112704 not in it:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul]
delete flag offensive retag edit

Comments

when does the command needs to be triggered?

chillworld ( 2016-01-20 07:38:28 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-01-20 08:39:33 +0800

afxgroup gravatar image afxgroup
126 1

in this example in the afterMount the changePage command should be triggered. But even if you create a javascript function and try to trigger it it will not work

link publish delete flag offensive edit

Comments

Basically it works with the previous version of zk, i tested it yesterday

Darksu ( 2016-01-20 10:07:12 +0800 )edit

Tracker then @Darksu

chillworld ( 2016-01-20 10:10:54 +0800 )edit

So it is a problem on ZK 8.0.1?

afxgroup ( 2016-01-21 16:33:56 +0800 )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
1 follower

RSS

Stats

Asked: 2016-01-19 19:32:09 +0800

Seen: 28 times

Last updated: Jan 20 '16

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