2

我在 JSF 2.0 中有复合组件

<composite:interface>
    <composite:attribute name="inputId"/>
    <composite:attribute name="labelValue"/>
    <composite:attribute name="inputValue" />
    <composite:attribute name="required" />
    <composite:attribute name="requiredMessage" />
</composite:interface>
<composite:implementation>
    <div class="control-group">
        <h:outputLabel for="#{cc.attrs.inputId}" value="#{cc.attrs.labelValue}" class="control-label" />
        <div class="controls">
            <h:inputText id="#{cc.attrs.inputId}" value="#{cc.attrs.inputValue}" required="#{cc.attrs.required}" requiredMessage="#{cc.attrs.requiredMessage}" />
        </div>
    </div>
</composite:implementation>

我需要对它进行一些验证(是数字、长度验证等)那么,我该怎么做呢?

4

1 回答 1

4

您需要<cc:editableValueHolder><cc:interface>.

<cc:interface>
    <cc:editableValueHolder name="input" targets="#{cc.attrs.inputId}" />
    ...
</cc:interface>

该标记基本上告诉<f:validator for="input">必须在UIInput组件上应用任何与id中指定的相同targets。因此,您可以按如下方式注册它:

<my:input ...>
    <f:validateLength for="input" ... />
</my:input>
于 2012-06-03T22:44:33.593 回答