0

use EL expression to call a method in a ViewModel.

asked 2012-11-17 10:32:16 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

In the Documentation ( http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM/Data%20Binding/EL%20Expression), they have said the following

Call ViewModel Methods
You can use EL expression to call a method in a ViewModel.
Call concat() of a ViewModel
1
<label value="@load(vm.concat(vm.foo,'postfix'))"/>


Can someone give a simple example for this

Regards
Senthil M

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2012-11-17 20:07:00 +0800

sarco gravatar image sarco flag of Spain
93 6
https://github.com/sarcow...

I'm trying to do this one, but the method doesn't receive anything.

<tabpanel forEach="${vm.set}">
       <grid model="@load(vm.getEvents(each.key))">
       ......

If you get a example, please post it.

Thanks you.

link publish delete flag offensive edit

answered 2012-11-18 01:49:32 +0800

rdgrimes gravatar image rdgrimes
735 7

updated 2012-11-18 02:06:32 +0800

Sorry, but I think you guys have seriously misread this. The concat does not allow you to pass parameters to a viewmodel method in the @load binding.

The concat() is merely an EL syntax for concatenating two strings. See any JSP EL guide. So, in your case, I believe it will concat the returned string from vm.foo with 'postfix' to dynamically determine a vm method to call in the @load binding. It will end up calling a method, in the viewmodel, whose name is the concatenation of (some-string-value-returned-from-foo + postfix) upon @load. So, I'm not sure where you gathered that the concat() was a way to pass parameters. Again, remember that any such reference to @load(vm.someProperty) is really telling the bindcomposer to look in the viewmodel for a method getSomeProperty() and retrieve those contents. Getters do NOT accept arguments in the traditional sense of getters.

Try this link for a better idea of how to handle things when it comes to tabs.

link publish delete flag offensive edit

answered 2012-11-18 06:11:12 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Thank you. I am aware of concat, but i dont know to how to call viewmodel method on @load and also passing arguments. If you have any simple example, please let me know.

link publish delete flag offensive edit

answered 2012-11-19 08:12:00 +0800

khcyt gravatar image khcyt
216 1 1

Hi Senthilchettyin

here are an example of how to call methods of the view model with parameters (look for listbox model = "@ bind (vm.getLM (each))") and also read some of the resulting problems.

Kai

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-11-17 10:32:16 +0800

Seen: 221 times

Last updated: Nov 19 '12

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