@SelectorParam"
From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} = Syntax = <source lang="java"> @SelectorParam("#componentId") @SelectorParam("tagName") @SelectorParam(".className") @SelectorParam(":...") |
m ((via JWB)) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersReferencePageHeader}} | {{ZKDevelopersReferencePageHeader}} | ||
+ | {{Deprecated | url=[http://books.zkoss.org/zk-mvvm-book/8.0/syntax/selectorparam.html zk-mvvm-book/8.0/syntax/viewmodel/parameters/selectorparam]|}} | ||
Line 18: | Line 19: | ||
</source> | </source> | ||
− | + | For selector syntax, please refer to <javadoc> org.zkoss.zk.ui.select.SelectorComposer </javadoc> | |
=Description = | =Description = | ||
− | '''Target:''' A method's parameter (initial | + | '''Target:''' A method's parameter (for initial and command methods) |
'''Purpose:''' To identify that a method's parameter should be retrieved from view component of the binder. | '''Purpose:''' To identify that a method's parameter should be retrieved from view component of the binder. | ||
Line 60: | Line 61: | ||
</source> | </source> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | =Version History= | ||
+ | |||
+ | {| class='wikitable' | width="100%" | ||
+ | ! Version !! Date !! Content | ||
+ | |- | ||
+ | | 6.0.0 | ||
+ | | February 2012 | ||
+ | | The MVVM was introduced. | ||
+ | |} | ||
+ | |||
+ | |||
{{ZKDevelopersReferencePageFooter}} | {{ZKDevelopersReferencePageFooter}} |
Latest revision as of 07:36, 8 July 2022
This article is out of date, please refer to zk-mvvm-book/8.0/syntax/viewmodel/parameters/selectorparam for more up to date information.
Syntax
@SelectorParam("#componentId")
@SelectorParam("tagName")
@SelectorParam(".className")
@SelectorParam(":root")
@SelectorParam("button[label='Submit']")
@SelectorParam("window > button")
For selector syntax, please refer to SelectorComposer
Description
Target: A method's parameter (for initial and command methods)
Purpose: To identify that a method's parameter should be retrieved from view component of the binder.
The value element is the selector to find components. It uses Selectors to select the components. The base component of the selector is the view component of the binder, the component which uses ViewModel.
If the parameter type is a Collection, binder passes the result directly. Otherwise it passes the first result or null if no result.
Example
<vbox apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('foo.SelectorParamVM')">
<hbox><label id="message" /></hbox>
<hbox><label /></hbox>
<hbox><label /></hbox>
<hbox><label /></hbox>
<button id="cmd" label="cmd" onClick="@command('cmd')" />
</vbox>
Example to pass components by selector
public class SelectorParamVM {
@Command
public void cmd(@SelectorParam("label") LinkedList<Label> labels, @SelectorParam("#message") Label msg) {
for (int i = 0; i < labels.size(); i++) {
labels.get(i).setValue("Command " + i);
}
msg.setValue("msg in command");
}
}
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |