Skip to content
This repository was archived by the owner on Jan 30, 2019. It is now read-only.
This repository was archived by the owner on Jan 30, 2019. It is now read-only.

Accessing properties of a bean implementing the Map interface #31

Description

@frifle

Hello all,

we are trying to access properties of a Java-bean implementing the Map interface with an EL-expression like "#{bean.property}" which always yields null. Is this a bug or is it specified? Please see the following testcase for details.

public class ElTestCase {

    private ELProcessor elProcessor;

    @Before
    public void before() {
        elProcessor = new ELProcessor();
        TestMapWithProperty test = new TestMapWithProperty("hello");
        test.put("entry", "world");
        elProcessor.defineBean("test", test);
    }

    @Test
    public void property() {
        // fails because the expression evaluates to null
        assertThat( elProcessor.eval("test.property"), is("hello") );
    }

    @Test
    public void property_II() {
        // fails because the expression evaluates to null
        assertThat( elProcessor.eval("test['property']"), is("hello") );
    }

    @Test
    public void entry() {
        // success
        assertThat( elProcessor.eval("test.entry"), is("world") );
    }

    public static class TestMapWithProperty extends HashMap<String, String> {
        private String property;

        public TestMapWithProperty(String property) {
            this.property = property;
        }

        public String getProperty() {
            return property;
        }
    }
}

The EL-Implementation we are using is

    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.el</artifactId>
        <version>3.0.1-b10</version>
    </dependency>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions