Search code examples
zk

zkoss is not binding the value


My zkoss code is not binding the value from java method.

<window border="normal" id="home"
    apply="com.test.HomeController">
    <caption label="@{home.name}"></caption>
            <button label="text"></button>
</window>


public class HomeController extends GenericForwardComposer{

    public  String getName() {
        return "MY ZKOSS";
    }

}

The window caption is not showing MY ZKOSS . can any one tell me what is the issue?


Solution

  • value binding through getter for a controller extending from GenericForwardComposer will work with EL expression like label="${$composer.name}"

    The kind of data binding you are trying to use will work if controller is extending from component base class for eg HomeController extends from Window instead of GenericForwardComposer. For this to work change apply to use like shown below

    <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
    <window border="normal" id="home" use="com.test.HomeController">
        <caption label="@{home.name}"></caption>
        <button label="text"></button>
    </window>