@Default

From Documentation
Revision as of 07:32, 8 February 2012 by Hawk (talk | contribs) (Created page with "{{ZKDevelopersReferencePageHeader}} =Syntax= <source lang="java"> @Default("defaultValue") </source> = Description = '''Target:''' A method's parameter (initial method and comm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Syntax

@Default("defaultValue")

Description

Target: A method's parameter (initial method and command method)

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.

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("arg1") @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.




Last Update : 2012/02/08

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.