The latest version of ZK CKEditor (org.zkoss.zkforge:ckez:4.7.0.0) doesn't provide a straightfoward method to disable the component whereas the original CKEditor provides a Read Only mode through Javascript. Usually, a normal ZK component offers the disabled attribute so the user cannot change the input state via UI.
How can I disable ZK's CKEditor component without having the disabled attribute available?
my.zul:
<ckeditor id="myCKComponentId"/> <!-- disabled doesn't exist -->
MyComposer.java:
public class MyComposer extends GenericForwardComposer {
CKeditor myCKComponentId;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
myCKComponentId.setDisabled(true); // <--- Doesn't exist
}
}
In theory, the disabled
attribute should've been provided for the CKeditor component as it should be considered to be the same as any other input, but it's possible to achieve the same result by passing the config Map with a readOnly
key/value, which will change the settings for the component without the need to use Javascript directly:
myCKComponentId.setConfig(new HashMap<String, Object>() {{ put("readOnly", true); }});
Java 8 and above (one line)
myCKComponentId.setConfig(Map.of("readOnly", true));
Using Javascript:
zk.Widget.$(jq('$myCKComponentId')).getEditor().setReadOnly(true);