JSF 2.0中的复合组件验证 [英] Composite component validation in JSF 2.0
本文介绍了JSF 2.0中的复合组件验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在JSF 2.0中具有复合组件
I have composite component in 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>
,我需要对此进行一些验证(是数字,长度验证等) 那么,我该怎么做呢?
and I need to make some validation on it (is it number, lenght validation etc) So, how can I make it?
推荐答案
You need to define the desired input for which you'd like to attach a validator as a <cc:editableValueHolder>
in the <cc:interface>
.
<cc:interface>
<cc:editableValueHolder name="input" targets="#{cc.attrs.inputId}" />
...
</cc:interface>
标签基本上告诉您,任何<f:validator for="input">
必须以与targets
中指定的相同的id
应用于UIInput
组件.因此,您可以按如下所示进行注册:
The tag basically tells that any <f:validator for="input">
must be applied on the UIInput
component with the same id
as specified in targets
. So, you can then register it as follows:
<my:input ...>
<f:validateLength for="input" ... />
</my:input>
这篇关于JSF 2.0中的复合组件验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文