JSF 1.2和JSF 2.1中的validateLength [英] validateLength in JSF 1.2 Vs JSF 2.1

查看:164
本文介绍了JSF 1.2和JSF 2.1中的validateLength的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近已从JSF 1.2升级到JSF 2.1.这是我的代码:

I have recently upgraded from JSF 1.2 to JSF 2.1. Here is my code:

Product Code: <h:inputText id="productCode" value="#{dataItem.productCode}" maxlength="25" disabled="#{dataItem.disabled}">
                        <f:validateLength minimum="2" maximum="25" />
                    </h:inputText>
                    <h:message for="productCode" errorClass="error" showSummary="false" />

在JSF 1.2中validateLength的行为是,如果我们在产品代码"字段中输入小于最小允许值"2"的值"1",我将收到错误消息值小于允许值的最小值". '2'".但是,如果我没有在产品代码"字段中输入任何值,那么我看不到任何错误消息.

The behavior of the validateLength in JSF 1.2 was if we enter the value "1" in the field Product Code which is less than the mininum allowable '2', I will get the error message "Value is less than allowable minimum of '2'". But if I dont enter any value for the field Product Code then I dont see any error message.

此行为更改了JSF 2.1的一部分.如果我没有为产品代码"字段提供任何值,则会收到错误消息值小于允许的最小值'2'".

This behavior has changed part of JSF 2.1. If I dont give any value for the field Product Code then I get the error message "Value is less than allowable minimum of '2'".

该行为真的改变了JSF 2.1的一部分吗?

Did the behavior really change part of JSF 2.1?

对此表示任何想法或帮助.

Any thoughts or help on this is much appreciated.

推荐答案

您可以通过添加以下上下文参数来配置此行为:

You can configure this behaviour by adding the following context param:

<context-param>
    <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
    <param-value>false</param-value>
</context-param>

这篇关于JSF 1.2和JSF 2.1中的validateLength的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆