1

我想将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,则无效。

我试图实现一个自定义标记处理程序,但这也不起作用。

4

1 回答 1

0

<o:validator>当前的 1.3 (也不)确实不支持这一点<o:converter>根据第 126 期(您可以在其中下载快照),它将在未来的 1.4 中出现。

关键是分别更改TagHandlerValidatorHandlerConverterHandler以便TagHandlerDelegate可以为复合材料完成其工作。

于 2013-01-30T16:23:13.710 回答