Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1436

button disabled state not synchronized


    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Normal Normal
    • None
    • 6.0.2, 6.5.0
    • Components, Databind 2
    • Windows/Linux, JDK 6, Explorer/Chrome/Firefox

      In the following test case when clicking "Open Editor" the modal window should have an enabled "Save" button but sometimes it is not.
      If the button is enabled the first time the window is opened, then it will always be right.
      If it it not enabled then you have to delete the text (which disables the button) and then retype the text.

      Exchanged JSON messages seem to be right.
      Strangely, without binding the title of the window seems to solve the problem.

      public class TestVM {
      	private boolean updating;
      	private boolean editorEnabled;
      	private String text;
      	public void doBeforeClose(
      			@ContextParam(ContextType.TRIGGER_EVENT) Event event) {
      		editorEnabled = false;
      		text = null;
      	@NotifyChange({ "editorEnabled", "text", "updating" })
      	public void doEdit() {
      		editorEnabled = true;
      		text = "automatic text";
      		updating = new Random().nextBoolean();
      	public void doSave() throws Exception {
      		// persist text or throw exception
      		editorEnabled = false;
      		text = null;
      	public String getText() {
      		return text;
      	public void init() {
      		editorEnabled = false;
      		text = null;
      	public boolean isEditorEnabled() {
      		return editorEnabled;
      	public boolean isSaveDisabled() {
      		return text == null || text.trim().isEmpty();
      	public boolean isUpdating() {
      		return updating;
      	public void setText(String text) {
      		this.text = text;
      <window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.TestVM')">
      	<button label="Open Editor" onClick="@command('doEdit')" />
      	<window title="@load(vm.updating ? 'Update' : 'Insert')"
      		mode="modal" width="30em" height="30ex"
      		visible="@load(vm.editorEnabled)" closable="true"
      		<vlayout vflex="1">
      			<textbox instant="true" rows="2" hflex="1" vflex="1"
      				value="@bind(vm.text)" />
      		<hbox pack="end" width="100%">
      			<button label="Save"
      				onClick="@command('doSave')" disabled="@load(vm.saveDisabled)" />

            Unassigned Unassigned
            benedetti benedetti
            1 Vote for this issue
            2 Start watching this issue