根据富表中textbox1中输入的值验证动态文本框2

时间:2011-05-27 11:15:54

标签: jsf jsf-2 richfaces

我使用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>

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)