Recently, I tried setting the property Read-Only to true in Xpage
for a specific field.
However, when attempting to change its mode to edit using client-side JavaScript, I encountered difficulties. Below is the code snippet I used:
document.getElementById("#{id:read}").readOnly = false;
I also attempted the following:
dojo.attr("#{id:read}", "readOnly", false);
Unfortunately, both approaches failed.
(@Trim)
In addition, the server-side JavaScript XSP code is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoParseOnLoad="true"
dojoTheme="true">
<xp:this.resources>
<xp:dojoModule name="dijit.Dialog"></xp:dojoModule>
</xp:this.resources>
<div id="dojoTest" dojoType="dijit.Dialog">
<xp:inputText id="field" defaultValue="Hello" readonly="true"></xp:inputText>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="field">
<xp:this.action> <![CDATA[{javascript:getComponent("field").setReadonly(false);}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:br></xp:br></div>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:button value="Show Popup" id="button2">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[dijit.byId("dojoTest").show();]]> </xp:this.script>
</xp:eventHandler></xp:button>
</xp:view>