从Java EE 7/EL 3.0开始,javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL不再起作用 [英] javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL does not work anymore since Java EE 7 / EL 3.0

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

问题描述

<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?

推荐答案

自定义解析器已修复:

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;
    }
}

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

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