javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL 自 Java EE 7/EL 3.0 起不再工作 [英] javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL does not work anymore since Java EE 7 / EL 3.0

查看:15
本文介绍了javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL 自 Java EE 7/EL 3.0 起不再工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>

不适用于 glassfish 4 和 wildfly 8 Final 上的最新 Mojarra 2.2.5

Does not work with the latest Mojarra 2.2.5 on both glassfish 4 and wildfly 8 Final

我已经看到多个关于此的错误报告,Manfried Riem

I have seen multiple bug reports on this, Manfried Riem says,

已确定这是一个 EL 问题,并且 EL 实现具有已修复以解决此问题

It was determined this is an EL issue and the EL implementation has been fixed to fix this

修复版本说是2.2.5,在2.2.5的发行说明中也有说明,我是不是遗漏了什么?

The fix versions says 2.2.5, and it is also stated in the release notes of 2.2.5, am I missing something?

推荐答案

使用自定义解析器修复:

Fixed with a custom resolver:

faces-config.xml:

faces-config.xml:

<application>
     <el-resolver>my.package.EmptyNullStringResolver</el-resolver>
</application>

EmptyNullStringResolver.java:

EmptyNullStringResolver.java:

/**
 * @author pg
 */
public class EmptyNullStringResolver extends ELResolver {

    @Override
    public Class<?> getCommonPropertyType(ELContext context, Object base) {
        return String.class;
    }

    @Override
    public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
        return null;
    }

    @Override
    public Class<?> getType(ELContext context, Object base, Object property) {
        return null;
    }

    @Override
    public Object getValue(ELContext context, Object base, Object property) {
        return null;
    }

    @Override
    public boolean isReadOnly(ELContext context, Object base, Object property) {
        return true;
    }

    @Override
    public void setValue(ELContext context, Object base, Object property, Object value) {
    }

    @Override
    public Object convertToType(ELContext context, Object obj, Class<?> targetType) {
        if (String.class.equals(targetType) && obj instanceof String && ((String) obj).trim().isEmpty()) {
            context.setPropertyResolved(true);
        }
        return null;
    }
}

这篇关于javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL 自 Java EE 7/EL 3.0 起不再工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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