Revision history [back]

click to hide/show revision 1
initial version

answered 2013-03-22 02:46:23 +0800

samchuang gravatar image samchuang

Hi, you can simply bind a boolean value and use @NotifyChange

<zk>

<window title="new page title" border="normal" apply="org.zkoss.bind.BindComposer" viewmodel="@id('vm') @init('test.FocusVM')"> <textbox type="text" width="200px" focus="@load(vm.userNameFocus)"/> <button label="Focus User Name" onclick="@command('doFocusUserName')"/>

<!-- bind with string argument-->
<textbox width="200px" focus="@load(vm.getFocus('password'))"/>
<button label="Focus Passowrd" onClick="@command('doFocusPassword')" />

</window> </zk>

Hi, you can simply bind a boolean value and use @NotifyChange

 <zk>

<window title="new page title" border="normal" apply="org.zkoss.bind.BindComposer" viewmodel="@id('vm') @init('test.FocusVM')"> <textbox type="text" width="200px" focus="@load(vm.userNameFocus)"/> <button label="Focus User Name" onclick="@command('doFocusUserName')"/>

onclick="@command('doFocusUserName')"/>
<!-- bind with string argument-->
 <textbox width="200px" focus="@load(vm.getFocus('password'))"/>
 <button label="Focus Passowrd" onClick="@command('doFocusPassword')" />
onclick="@command('doFocusPassword')"/>
</window>
</zk>
 

</window> </zk>

Hi, you can simply bind a boolean value and use @NotifyChange


<zk>
<window title="new page title" border="normal" apply="org.zkoss.bind.BindComposer" viewmodel="@id('vm') @init('test.FocusVM')">
    
    <textbox type="text" width="200px" focus="@load(vm.userNameFocus)"/>
    <button label="Focus User Name" onclick="@command('doFocusUserName')"/>

    
    <textbox width="200px" focus="@load(vm.getFocus('password'))"/>
    <button label="Focus Passowrd" onclick="@command('doFocusPassword')"/>
</window>
</zk>
 

public class FocusVM {

    String focus;
    boolean isUserNameFocus;

    public boolean getFocus(@BindingParam("target") String target) {
        return Objects.equals(focus, target);
    }

    public boolean getUserNameFocus() {
        return isUserNameFocus;
    }

    @Command
    @NotifyChange("userNameFocus")
    public void doFocusUserName() {
        isUserNameFocus = true;
    }

    @Command
    @NotifyChange("getFocus")
    public void doFocusPassword() {
        focus = "password";
    }
}
 
Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More