1

Is there a way to resolve view model properties as input to client side javascripts?

asked 2012-12-21 10:50:17 +0800

thrane gravatar image thrane
43 3

updated 2013-01-25 08:29:16 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Is there a way to resolve view model properties as input to client side javascripts?

In the example shown below, the "????" indicates the bit that I have a problem with. The my.zul fragment shows a listbox where the attribute "w:onSelect" defines a client side event which is trigged when an entry in the listbox is selected:

my.zul fragment::

<window id="reportPanelWindow" 
    apply="org.zkoss.bind.BindComposer" 
    viewModel="@id('vm') @init('com.alpha.pineapple.web.zk.viewmodel.ModulePanel')" 
    hflex="1" vflex="1" border="none" >

... layout stuff here....

<listbox id="modelListbox" 
    model="@load(vm.models)" 
    selectedItem="@bind(vm.selectedModel)"
    onSelect="@command('loadSelectedModel')"            
    w:onSelect="helloJS( ????? )"

I would like the event to invoke a JavaScript defined in the zul named "helloJS" to which I need to provide input from the view model as argument.

The two possible solutions that I hope for help with is either:

1) Resolution of view model properties (e.g. vm.xxxx) as input to a java script. As stated above the missing part is illustrated with the ???? in the example above.

2) Access to view model properties from within a java script defined in a ZUL, e.g. can I access the view model vm from the helloJS script?

BR, Allan

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2013-01-25 08:38:27 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team
  1. You can use this API Clients.evalJavaScript(java.lang.String) to invoke a Javascript function from the VM.
  2. I think so far there is not a way to access a VM from Javascript at client side.
link publish delete flag offensive edit

answered 2013-10-09 18:12:00 +0800

salman1 gravatar image salman1 flag of United Kingdom
40 4

This feature would be really useful. Anyone know if this is now possible?

link publish delete flag offensive edit

answered 2013-10-15 11:56:41 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

could be like this,

< button label="test" w:param="@load(vm.someval)" w:onClick='alert(this.param)'/>

however, it doesn't provide yet.

link publish delete flag offensive edit

answered 2014-09-10 02:12:10 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

You may use ZK-Angular Project instead.

link publish delete flag offensive edit

answered 2015-03-26 03:01:35 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

You can use client binding API to do so, please take a look at this article

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2012-12-21 10:50:17 +0800

Seen: 106 times

Last updated: Mar 26 '15

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