@Default"
From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} =Syntax= <source lang="java"> @Default("defaultValue") </source> = Description = '''Target:''' A method's parameter (initial method and comm...") |
m ((via JWB)) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersReferencePageHeader}} | {{ZKDevelopersReferencePageHeader}} | ||
+ | {{Deprecated | url=[http://books.zkoss.org/zk-mvvm-book/8.0/syntax/default.html zk-mvvm-book/8.0/syntax/viewmodel/parameters/default]|}} | ||
+ | |||
=Syntax= | =Syntax= | ||
Line 7: | Line 9: | ||
= Description = | = Description = | ||
− | '''Target:''' A method's parameter (initial | + | '''Target:''' A method's parameter (for initial and command methods) |
'''Purpose:''' Assign a binding parameter's default value when it's null. | '''Purpose:''' Assign a binding parameter's default value when it's null. | ||
− | You give annotation element's value with String, and ZK will cast to the corresponding type of the parameter. You can apply this annotation after other parameter related annotation e.g., @BindingParam. If a parameter retrieved by first annotation is null, it uses the default value specified in this annotation. | + | You give annotation element's value with a String, and ZK will cast to the corresponding type of the parameter. You can apply this annotation after other parameter related annotation e.g., @BindingParam. If a parameter retrieved by first annotation is null, it uses the default value specified in this annotation. |
= Example = | = Example = | ||
Line 25: | Line 27: | ||
@Command | @Command | ||
− | public void cmd(@Default("false") Boolean arg1, @BindingParam(" | + | public void cmd(@Default("false") Boolean arg1, @BindingParam("arg2") @Default("3") Integer arg2){ |
//... | //... | ||
} | } | ||
Line 31: | Line 33: | ||
</source> | </source> | ||
* According to above example, if we click first button, binder will pass 100 to arg2. If we click second button, arg2 will be 3. | * According to above example, if we click first button, binder will pass 100 to arg2. If we click second button, arg2 will be 3. | ||
+ | |||
+ | =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/default for more up to date information.
Syntax
@Default("defaultValue")
Description
Target: A method's parameter (for initial and command methods)
Purpose: Assign a binding parameter's default value when it's null.
You give annotation element's value with a String, and ZK will cast to the corresponding type of the parameter. You can apply this annotation after other parameter related annotation e.g., @BindingParam. If a parameter retrieved by first annotation is null, it uses the default value specified in this annotation.
Example
Pass parameter from a zul
<button id="first" onClick="@command('cmd', arg2=100)" />
<button id="second" onClick="@command('cmd')" />
Example to assign default value
@Command
public void cmd(@Default("false") Boolean arg1, @BindingParam("arg2") @Default("3") Integer arg2){
//...
}
- According to above example, if we click first button, binder will pass 100 to arg2. If we click second button, arg2 will be 3.
Version History
Version | Date | Content |
---|---|---|
6.0.0 | February 2012 | The MVVM was introduced. |