1

used zAu.send in mvvm

asked 2016-03-24 07:23:25 +0800

longdv1208 gravatar image longdv1208
98 4

updated 2016-03-24 07:25:05 +0800

I want to use an action to perform zAu.send sever the MVVM pattern
Thank
file .zul

<window id="fmisTabFlowketoan" apply="org.zkoss.bind.BindComposer"
    closable="false" height="@load(vm.heightPx)"
    viewModel="@id('vm') @init('com.evnit.fmis.viewmodel.quytrinhlamviec.QuytrinhKetoanVM')"
    border="none">
<script type="text/javascript">
    <![CDATA[
        function valid(){
            zAu.send(new zk.Event(zk.Widget.$(this), 'onValidate'));
        }
    ]]>
</script>
<h:button onclick="valid();">Send simple string</h:button>

</window>

File Code java Mvvm

public class QuytrinhKetoanVM extends BaseViewModel {

@Init
public void initVM() {

}

@AfterCompose
public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
    Selectors.wireComponents(view, this, false);
}

@Command("onFlowform")
public void onFlowform(Event event) {
    System.out.println("Call form highcharts");
}

@Command("onValidate")
public void onValidate() {
    System.out.println("Call form highcharts");
}

@Override
public void onClose(Event event) {

}

}

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-24 08:06:20 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

First of all, your not working MVVM.
You work a mix of MVVM/MVC because you initialize the MVC in your aftercompose.
Maybe for this purpose you can do it so you can use the @Listen annotation like the fiddle but if this is not needed => don't do it.

Here is a fiddle where you can check your code with.

Otherwise if you use ZK 8 please read this topic.

Greetz Chill.

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
1 follower

RSS

Stats

Asked: 2016-03-24 07:23:25 +0800

Seen: 25 times

Last updated: Mar 24 '16

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