【发布时间】:2014-11-01 13:29:11
【问题描述】:
我已经使用列选项列表来自定义页面上表格的列,如果用户禁用选项列表中的所有列,我想显示对话框消息(应启用至少一列)。这意味着用户应该在启用框中至少保留一列。
<p:dialog id="pickListDialog" header="Customize View"
widgetVar="dlg">
<h:panelGrid>
<p:pickList id="columnPickList"
value="#{Class_Name.columns}" var="col"
itemLabel="#{Class_Name.columnPickList.columnsDisplayMap.get(col)}"
itemValue="#{col}">
<f:facet name="sourceCaption">Disabled</f:facet>
<f:facet name="targetCaption">Enabled</f:facet>
</p:pickList>
<p:commandButton value="Submit"
actionListener="#{Class_Name.columnPickList.saveColumns}" onclick="return disableClick();"
ajax="false" />
</h:panelGrid>
</p:dialog>
Javascript 方法 -
function disableClick(){
if (document.getElementById("form:columnPickList_target").value == ""){
alert("Please Select Atleast One Field");
return false;
}
}
我在这里使用了 Javascript。但我想通过 JSF 做到这一点。 谁能告诉我?
【问题讨论】:
-
使用pickList的必需属性。将其设置为 required="true" 并定义 requiredMessage。
标签: validation jsf jsf-2 primefaces