Hi
I think it is a bug in JSF 2.2 spec. The behavior for
ScopedAttributeELResolver (for facelets) is defined in section
5.6.2.9. To solve it (for 2.3) you should raise an issue on:
https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC
But I found this one already created on Mojarra issue tracker:
https://java.net/jira/browse/JAVASERVERFACES-3362
Please create an issue on the spec issue tracker. MyFaces already has
some params to control the EL Resolver ordering, so I suppose this
feature will help to fix the problem for 2.2.x. Besides that, we can't
do anything else from this side.
regards,
Leonardo Uribe
2015-03-27 9:19 GMT-05:00 William Lucy :
>
> Thanks for the response, Leonardo.
>
> From what I can tell, the issue isn't that MyFaces can't find the
> StaticFieldELResolver - that is loaded correctly. JSP static field EL
> references do work properly through MyFaces, so there does seem to be some
> JSF issue.
>
> I think there may be a spec issue here? (What I believe to be) a similar
> issue had to be addressed for JSP 2.3:
> https://bz.apache.org/bugzilla/show_bug.cgi?id=57141
>
> MyFaces has a resolver, ScopedAttributeResolver, which always sets the
> "resolved" field on the EvaluationContext to true if the EL expression's
> "property" isn't null. The issue with that is when we're trying to resolve
> the EL expression "base" (eg. "Boolean" in the expression Boolean.TRUE) EL
> 3.0 never has a chance to resolve the import the base ELClass, since it
> first runs through the EL Resolvers.
>
> My testing has shown that if we don't set context.setPropertyResolved(true)
> in the ScopedAttributeResolver, this particular case (#{Boolean.TRUE})
> works as expected.
>
> Any thoughts on this? Let me know if I need to clarify anything.
>
> Regards,
>
> Bill Lucy
>
>
> Leonardo Uribe wrote on 03/25/2015 06:10:00 PM:
>
>> From: Leonardo Uribe
>> To: MyFaces Discussion
>> Date: 03/25/2015 06:11 PM
>> Subject: Re: EL 3.0 Static Field References
>>
>> 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 :
>> >
>> >
>> > 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: [> > 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 {
>> > ...
>> > publ