0

I'm wondering if changing the EL resolver so a bean can use public fields in jsf could cause issues with the proxies? [That's why it isn't a duplicate.] Aall managed bean fields have to be private in the framework, because that's how the EL resolver does things. However it's a bit cumbersome and looks useless most of the time.

@Named
@RequestScoped
public class myBean{
    public int age;
}

So would it cause issue with proxies trying to intercept things or whatnot?

This guy in this question apparently changed the el resolver so it's doable

Community
  • 1
  • 1
Ced
  • 15,847
  • 14
  • 87
  • 146
  • please do not refer to other questions. try to make your question as atomic as possible (the other question can be removed) – Leo Jun 04 '16 at 01:58
  • 1
    @Leo allright I'll edit that – Ced Jun 04 '16 at 01:59
  • So, this question is a duplicate. – Jorge Campos Jun 04 '16 at 02:30
  • 1
    Possible duplicate of [With Java EL 2.2 / JSF2 Is it possible to do field access rather than getters/setters?](http://stackoverflow.com/questions/14610522/with-java-el-2-2-jsf2-is-it-possible-to-do-field-access-rather-than-getters-se) – Jorge Campos Jun 04 '16 at 02:30
  • @JorgeCampos Read again, this isn't a duplicate of that. I even linked it in the question. And I posted my question after reading that exact link. My question is about proxies potentially interfering with the process. I have suspicions that the link (indirectly the answer) you & I linked is wrong ence the question. – Ced Jun 04 '16 at 05:08

1 Answers1

1

Unfortunately yes, it will mess with CDI.

Why? Because public field access is impossible when bean is proxied. With Weld during startup you will get a definition error:

WELD-000075: Normal scoped managed bean implementation class has a public field ...

It's going to work fine only for non-proxied scopes (@Singleton and @Dependant).

I agree it's a bit cumbersome and looks useless sometimes, so you have two solutions:

  1. Use IDE to generate them automatically.
  2. Use lombok project.

But none of them is perfect.

G. Demecki
  • 10,145
  • 3
  • 58
  • 58