package demo.input.form_sample; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.ContextParam; import org.zkoss.bind.annotation.ContextType; import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.event.InputEvent; public class FormViewModel extends UserForm { private String dateFormat; private int memoHeight = 6; private String foregroundColour = "#000000", backgroundColour = "#FDC966"; public String getForegroundColour() { return foregroundColour; } public void setForegroundColour(String foregroundColor) { this.foregroundColour = foregroundColor; } public String getBackgroundColour() { return backgroundColour; } public void setBackgroundColour(String backgroundColor) { this.backgroundColour = backgroundColor; } public String getDateFormat() { return dateFormat; } public void setDateFormat(String dateFormat) { this.dateFormat = dateFormat; } public int getMemoHeight() { return memoHeight; } public void setMemoHeight(int memoHeight) { this.memoHeight = memoHeight; } @Command @NotifyChange("memoHeight") public void changeMemoHeight( @ContextParam(ContextType.TRIGGER_EVENT) InputEvent change) { try { int parsed = Integer.parseInt(change.getValue()); if (parsed > 0) { this.memoHeight = parsed; } } catch (NumberFormatException nfe) { // nothing that we can do here, the validation should pick it up } } @Command @NotifyChange("captcha") public void regenerate() { this.regenerateCaptcha(); } @Command public void submit() { } }