我使用rich:dataTable
动态创建组件,每行中的组件为checkbox、text1和text2。我可以创建/删除行。我为text1和text2添加了验证器。
我需要根据text1中插入的字符验证text2。假设在text1组件中,如果输入了3,那么在text2组件中,我需要允许最多3个字符。这需要为整个表的所有动态生成的行执行。
<rich:dataTable id ="outtable" value="#{bean.Items}" var="row">
<rich:column>
<f:facet name="header">
<h:outputText id="selectrow" value="select" style="font-weight: bold; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 12px;" />
</f:facet>
<h:selectBooleanCheckbox value="#{row.selected}" />
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText size="15" value="Bean Value"
style="font-weight: bold; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 12px;"/>
</f:facet>
<s:decorate id="valueDecoration" template="layout/edit.xhtml">
<h:inputText size="8" maxlength="4" value="#{row.beanValue}" required="true" >
<f:validator validatorId="beanValueValidator"/>
<s:validate/>
<a:support event="onblur" reRender="valueDecoration" bypassUpdates="false" ajaxSingle="true"/>
</h:inputText>
</s:decorate>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Bean Data"
style="font-weight: bold; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 12px;"/>
</f:facet>
<s:decorate id="dataDecoration" template="layout/edit.xhtml">
<h:inputText size="30" maxlength="40" value="#{row.beanData}" required="true">
<f:validator validatorId="beanDataValidator"/>
<s:validate/>
<a:support event="onblur" reRender="dataDecoration" bypassUpdates="false" ajaxSingle="true" />
</h:inputText>
</s:decorate>
</rich:column>
<f:facet name="footer">
<h:panelGroup>
<h:commandButton value="Add Row" action="#{bean.add}" />
<h:commandButton value="Delete Selected" action="#{bean.remove}" />
</h:panelGroup>
</f:facet>
</rich:dataTable>
我怎样才能做到这一点?
试试richfaces 3.3 Graph Validator(4.x)。