[英]Composite component validation in JSF 2.0
我在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>
我需要对其进行一些验证(它是数字,长度验证等),那么我该如何做呢?
您需要在<cc:interface>
中将要附加验证器的所需输入定义为<cc:editableValueHolder>
<cc:interface>
。
<cc:interface>
<cc:editableValueHolder name="input" targets="#{cc.attrs.inputId}" />
...
</cc:interface>
标记基本上告诉所有<f:validator for="input">
必须以与targets
指定的id
相同的id
应用于UIInput
组件。 因此,您可以按如下所示进行注册:
<my:input ...>
<f:validateLength for="input" ... />
</my:input>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.