myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonardo Uribe <lu4...@gmail.com>
Subject Re: EL 3.0 Static Field References
Date Wed, 25 Mar 2015 22:10:00 GMT
Hi

It is in the spec, it should work.

There is some code in
org.apache.myfaces.el.unified.ResolverBuilderForFaces that deals with
this:

        if (STATIC_FIELD_EL_RESOLVER_CLASS != null &&
            GET_STREAM_EL_RESOLVER_METHOD != null)
        {
            try
            {
                ELResolver streamElResolver = (ELResolver)
GET_STREAM_EL_RESOLVER_METHOD.invoke(
                        getRuntimeConfig().getExpressionFactory());
                if (streamElResolver != null)
                {
                    // By default return null, but in a EL 3
implementation it should be there,
                    // this is just to avoid exceptions in junit testing
                    list.add(streamElResolver);
                }
                list.add((ELResolver)
STATIC_FIELD_EL_RESOLVER_CLASS.newInstance());
            }

The code checks for javax.el.StaticFieldELResolver class and
ExpressionFactory.getStreamELResolver(...) method before
add both EL resolvers.

If MyFaces jars cannot locate these classes, the EL resolvers
are not loaded (because it assumes EL < 3.0), and the
described behavior will happen.

regards,

Leonardo Uribe

2015-03-25 15:14 GMT-05:00 William Lucy <wtlucy@us.ibm.com>:
>
>
> Hi All,
>
> I'm running into some issues trying to test the EL 3.0 functionality on
> MyFaces 2.2.7 + Tomcat 8.0.16.  My understanding is that we should be able
> to reference static fields/methods directly from facelets, eg.
>
>       Boolean.TRUE test: [<h:outputText id="out2"
>       value="#{Boolean.TRUE}"/>]
>
> should return "Boolean.TRUE test: [true]".  This isn't the case, however;
> no value is returned, and nothing's logged.  Additionally, when I try to
> access a static field on a local ManagedBean, I get
>
>       ...
>       javax.el.PropertyNotFoundException: Property 'staticReference' not
>       found on type beans.EL30StaticFieldsAndMethodsBean
>          at javax.el.BeanELResolver$BeanProperties.get
>          (BeanELResolver.java:244)
>          at javax.el.BeanELResolver$BeanProperties.access$300
>          (BeanELResolver.java:221)
>          at javax.el.BeanELResolver.property(BeanELResolver.java:331)
>          at javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
>          at javax.el.CompositeELResolver.getValue
>          (CompositeELResolver.java:66)
>          at
>          org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue
> (FacesCompositeELResolver.java:179)
>          ... 1 more
>
> Where the ManagedBean is defined simply as
>
>       package beans;
>       import javax.faces.bean.ApplicationScoped;
>       import javax.faces.bean.ManagedBean;
>
>       @ManagedBean(name = "staticbean")
>       @ApplicationScoped
>       public class EL30StaticFieldsAndMethodsBean {
>          ...
>           public static final String staticReference = "static reference";
>          ...
>       }
>
> Has anyone else tried working with these kinds of EL 3.0 features?  Or am I
> possibly just missing something here?
>
> Thanks,
> Bill Lucy

Mime
View raw message