我的单选按钮在一个具有相同groupName的桌子上。在不使用CCJS的情况下提交表单时,是否有相对简单的方法来验证此字段?
<xp:td>
<xp:radio id="radio120" groupName="R_1" value="#{document1.R_1}" selectedValue="1"></xp:radio>
</xp:td>
<xp:td>
<xp:radio id="radio120" groupName="R_1" value="#{document1.R_1}" selectedValue="2"></xp:radio>
</xp:td>对于常规的Radio控件,我使用validateRequired和一个errorMessage控件来显示消息。
<xp:radioGroup styleClass="A2" style="border:0px;" value="#{document1.Necktie}" layout="pageDirection" id="Necktie">
<xp:this.validators>
<xp:validateRequired message="REQUIRED!"></xp:validateRequired>
</xp:this.validators>
<xp:selectItem itemLabel="No" id="selectItem13"></xp:selectItem>
<xp:selectItem itemLabel="Yes" id="selectItem14"></xp:selectItem>
</xp:radioGroup>
<xp:message id="message10" for="Necktie"></xp:message>发布于 2016-12-02 12:25:52
使用服务器端的数据源document1来确定是否选中了单选按钮。
document1.getItemValueString("R_1")测试。如果是空的,设置错误消息并返回false。否则保存文档。
<xp:button value="Save" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
if (document1.getItemValueString("R_1") == "") {
facesContext.addMessage(null,
new javax.faces.application.FacesMessage("select a radio"));
return false;
}
document1.save();
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:messages id="messages1" />发布于 2016-11-30 16:22:39
很公平..。在这种情况下,除了和CSJS做点什么外,我不太确定.
不确定这是否有帮助,但请看一下Marky Roden:https://xomino.com/2012/03/10/checking-xpages-radio-buttons-have-been-selected-with-jquery/的这篇文章
随着年底的到来,我已经4/5周没有做任何开发工作了,所以我的大脑并没有像它应该做的那样工作……
https://stackoverflow.com/questions/40887623
复制相似问题