[英]one requiredMessage for 2 “h:selectOneMenu”s
I want one requiredmessage for two h:selectOneMenu components, that is when a user submits the form if one of those selects values is not null, the bean method should be called, otherwise(both of them null) : I should tell him to select at least one, is it possible? 我想要一个用于两个h:selectOneMenu组件的必需消息,即当用户提交表单(如果其中一个选择值不为null时),则应调用bean方法,否则(它们都为null):我应该告诉他选择至少有可能吗? or do I have to use JS.
还是我必须使用JS。 Thanks in advance,
提前致谢,
I'd use the OmniFaces validateOne validator for this or the validateOneOrMore if filling both is allowed too. 如果对此也允许同时填充两者,则我将使用OmniFaces validateOne验证器对此或validateOneOrMore进行验证 。
Code example from their site: 来自其站点的代码示例:
<h:form>
<h3>Please fill out only one of two fields</h3>
<o:validateOne id="one" components="foo bar" />
<h:panelGrid columns="3">
<o:outputLabel for="foo" value="Foo" />
<h:inputText id="foo" />
<h:message for="foo" />
<o:outputLabel for="bar" value="Bar" />
<h:inputText id="bar" />
<h:message for="bar" />
<h:panelGroup />
<h:commandButton value="submit">
<f:ajax execute="@form" render="@form" />
</h:commandButton>
<h:panelGroup>
<h:message for="one" />
<h:outputText value="OK!" rendered="#{facesContext.postback and not facesContext.validationFailed}" />
</h:panelGroup>
</h:panelGrid>
</h:form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.