steps to reproduce
run the attached example, and observe the initial and dynamic updates
actual result
using checked="false" initially or calling setChecked(false) during the initial rendering causes the checkbox to be checked
calling setChecked(true/false) dynamically works
calling setChecked twice causes multiple response commands sent to the client, causing unnecessary network traffic
using the html conform values such as checked="checked" or not setting the the property at all (calling setDynamicProperty("checked", null/"checked")) works when initially rendering the component, however dynamic changes always result in an unchecked checkbox
expected result
consistent behavior, either true/false or "checked"/null.
This inconsistency requires additional customization when integrating the input element with ZKBind.
To avoid duplicate setAttr commands a mechanism like smartUpdate should be considered
Workaround
a custom component class to get things working from the server side:
@ComponentAnnotation("checked:@ZKBIND(ACCESS=both, SAVE_EVENT=onCheck)") public class CheckableInput extends Input { private static final long serialVersionUID = 1L; @Override public boolean isChecked() { return getDynamicProperty("checked") != null; } @Override public void setChecked(boolean checked) { setDynamicProperty("checked", checked ? true : null); } }
this results in the DOM attribute checked="true" being rendered.
However this should rather be checked="" or checked="checked"
(refer to https://www.w3.org/TR/html-markup/input.checkbox.html#input.checkbox.attrs.checked)