验证失败后未出现错误信息

时间:2018-12-07 15:17:02

标签: validation jsf icefaces

在下面的源代码片段中,我试图验证输入文本,以使其不超过5000个字符。但是,我遇到了一个奇怪的行为。当我将组件importantInfo标记为required=true时,如果validateLength失败,将显示验证错误消息。但是,当我将importantInfo标记为required=false时,将进行验证过程,但是如果我输入的字符超过5000个,则不会出现错误消息。对于信息,我正在使用JSF 1.2和ICEFACES 1.8.1。

user.jspx

<tr>    
                <td class="label">    
                               <ice:outputText value="#{msg.importantNotes}" />    
                </td>    
                <td class="data">     
                               <ice:inputTextarea id="importantInfo" rendered="#{editable}" required="true"

                                               value="#{user.importantInfos}" style="width:300px;height:200px;overflow: auto;">    
                                               <f:validateLength maximum="5000" />    
                               </ice:inputTextarea>    
                               <h:message styleClass="errorMessage" for="importantInfo"/>                                                           
                               <pre style="font-family: Verdana, Arial, sans-serif; font-size: 11px; width:700px;overflow: auto;">    
                                               <ice:outputText rendered="#{!editable}" value="#{user.importantInfos}" />    
                               </pre>    
                </td>  
                <td/>    
</tr>

faces-config.xml:

 <application>
                    <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
                    <view-handler>com.icesoft.faces.facelets.D2DFaceletViewHandler</view-handler>
                    <message-bundle>i18n.validationErrorMessages</message-bundle>
                    <resource-bundle>
                                   <base-name>version</base-name>
                                   <var>version</var>
                    </resource-bundle>
    </application>

validationErrorMessages.properties

javax.faces.validator.LengthValidator.MAXIMUM=Der eingegebene Wert ist zu lang.

0 个答案:

没有答案
相关问题