【发布时间】:2013-01-11 18:56:33
【问题描述】:
我想将omnifaces 库中的o:validator 标记用于组合组件:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
<cc:interface>
<cc:attribute name="disabled" />
<cc:attribute name="label" />
<cc:attribute name="validatorMessage" />
<cc:attribute name="required" />
<cc:attribute name="value" required="true" />
<cc:editableValueHolder name="date" targets="textfield"/>
</cc:interface>
<cc:implementation>
<p:outputLabel id="label" for="textfield" value="#{cc.attrs.label}" rendered="#{cc.attrs.label!=null}" />
<p:inputText id="textfield" value="#{cc.attrs.value}" styleClass="dateInputField" required="#{cc.attrs.required}" disabled="#{cc.attrs.disabled}">
<f:convertDateTime locale="de_DE" type="date" />
<!-- some other stuff... -->
</p:inputText>
<p:watermark for="textfield" value="TT.MM.JJJJ" />
<cc:insertChildren/>
</cc:implementation>
验证器的调用方式如下:
<o:validator validatorId="customGreaterThanValidator" compareTo="#{bean.date}" validatorMessage="given date must be later than #{bean.date}" for="date"/>
但不幸的是,omnifaces 的验证器标签似乎忽略了“for”属性。使用来自 JSF 的原始验证器标记,“for”标记有效,但如果“compareTo”标记的值为 ValueExpression,则无效。
我尝试实现一个自定义标记处理程序,但这也不起作用。
【问题讨论】:
-
那只是一个错字,我把它删掉了。
-
<o:validator>确实不支持这个。我已经为你创建了一个问题单:code.google.com/p/omnifaces/issues/detail?id=126 -
嗨,BalusC 感谢您的答复/票证。我想这需要一些时间,直到实现这个功能。你知道我完成任务的另一种方法吗?
标签: jsf validation composite-component omnifaces