All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zkoss.bind.annotation.Destroy Maven / Gradle / Ivy

There is a newer version: 10.0.0-jakarta
Show newest version
/* Destroy.java

        Purpose:
                
        Description:
                
        History:
                Fri Mar 16 3:21 PM:13 CST 2018, Created by klyve

Copyright (C) 2018 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 destroy method.
* Only one (could be zero) destroy method is allowed in a particular class. * If a component is bound with a viewModel which has @Destroy methods, * The @Destroy method would be executed before the component detaching, or before the page or desktop which has this component being destroyed. * If it is triggered by detach, the @Destroy method can interact with UI, * but if it is triggered by destroying page or desktop, the @Destroy method won't interact with UI. * If you want binder to call super class's Destroy method also, you have to set {@link #superclass()} to true, * and super class's Destroy method will be called last. * You could annotate it on the type if the class doesn't has a Destroy method but super-class has. *

*

* For example, in class hierarchy A(has @Destroy) <- B(no @Destroy) <- C(has @Destroy, superclass true) <- D (has @Destroy, superclass false). D is the last one.
* If A is the view model, will call A.Destroy only
* If B is the view model, no method will be called
* If C is the view model, will call C.Destroy
* If D is the view model, will call D.Destroy then C.Destroy
*

* *

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.
*

* * @Destroy public void doDestroy()
* * @author klyve * @since 8.5.2 */ @Target ({ ElementType.METHOD, ElementType.TYPE }) @Retention (RetentionPolicy.RUNTIME) public @interface Destroy { boolean superclass() default false; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy