myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Lucy <wtl...@us.ibm.com>
Subject Re: EL 3.0 Static Field References
Date Fri, 27 Mar 2015 14:19:26 GMT

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 <lu4242@gmail.com> wrote on 03/25/2015 06:10:00 PM:

> From: Leonardo Uribe <lu4242@gmail.com>
> To: MyFaces Discussion <users@myfaces.apache.org>
> 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 <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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message