org.zkoss.bind.annotation.Init Maven / Gradle / Ivy
/* Init.java
Purpose:
Description:
History:
2011/11/30 Created by Dennis Chen
Copyright (C) 2011 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* Marker annotation to identify a initial method.
* Only one (could be zero) initial method is allowed in a particular class.
* If you want binder to call super calss's initial method also, you have to set {@link #superclass()} to true,
* and super class's initial method will be called first.
* You could annotate it on the type if the class doesn't has a init method but super-class has.
*
*
* For example, in class hierarchy A(has @Init) <- B(has @Init, superclass true) <- C(no @Init) <- D (has @Init, superclass false). D is the last one.
* If D is the view model, will call D.init only
* If C is the view model, no method will be called
* If B is the view model, will call A.init then B.init
* If A is the view model, will call A.init
*
*
* Exception: if {@link #superclass()} was been set to true and your initial method
* is an overridden method to it's super's initial method, ex:
* X.m1() <- Y.m1()
* Binder will throw an exception due to the conflict of java language's overriding nature.
*
*
* Parameter Binding, for convenience, initial method support several kinds of
* Parameter Annotations. Binder will weave it's context(Zul page annotation, Java EE Context)
* with method's parameters while invocation.
* For example, you can wire @init('BlaBlaVM', a='b') to an initial method like:
* @Init public void doInit(@BindingParam("a") String a)
*
*
* @see BindingParam
* @see ExecutionParam
* @see ExecutionArgParam
* @see HeaderParam
* @see CookieParam
* @see QueryParam
* @see ScopeParam
* @see ContextParam
* @see Default
*
* @see AfterCompose
*
* @author dennis
* @since 6.0.0
*/
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface Init {
boolean superclass() default false;
}