我可以使用JavaScript通过disable =“ true”在XPages中动态禁用DatePicker。但是,它仅对编辑框禁用,而对选择器按钮禁用。该按钮仍然有效。
如何禁用按钮?
<xp:inputText id="date1"
defaultValue="#{javascript:@Today()}">
<xp:dateTimeHelper id="dateTimeHelper1"></xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date"
dateStyle="full">
</xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
禁用时,
document.getElementById("#{id:date1}").disabled="true";
启用时,
document.getElementById("#{id:date1}").disabled="";
最安全的方法是在服务器端禁用组件。
<xp:button value="disable" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="date1">
<xp:this.action><![CDATA[#{javascript:viewScope.datedisabled = true}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button value="enable" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="date1">
<xp:this.action><![CDATA[#{javascript:viewScope.datedisabled = false}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:inputText id="date1" defaultValue="#{javascript:@Today()}"
disabled="#{viewScope.datedisabled}">
<xp:dateTimeHelper id="dateTimeHelper2"></xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date" dateStyle="full">
</xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
它同时包括:输入字段和日期按钮。无论组件如何渲染取决于主题,它始终将起作用。
您仍然可以尝试使用客户端JavaScript代码来完成它,但是除非您确定您永远不会更改应用程序的主题,否则我不建议您这样做。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句