2 Replies Latest reply on Jul 15, 2006 11:02 PM by Jim Hazen

    Accessing static finals

    flo thomas Newbie

      Hi,
      I want to evaluate an EL against some static final from an entity which I tried to outject and (@Out (value="final1")) however it is ignored. Can I not outject from entities? How is it usually solved if one would like access a public static final w/o having to implement getters for them?

      Thanks,
      Joey

        • 1. Re: Accessing static finals
          Jim Hazen Expert

          You can't outject from entities and by default the EL requires getters/setters. I was thinking that a custom JSF VariableResolver might help, but it seems that it only resolves the top-level object (ie, the entity), not the actual returned variable.

          I think you're SOL here, unless the JSF EL in 1.2 has changed to support this (or supports new extension points that I'm unaware of). If you really, really can't just add getter/setters to your entity, then you can use cglib or some other class manipulation library to generate those getters/setters for you.

          I experimented with this in the past and it worked, but is probably overkill for your needs.

          Now just because Entities don't outject doesn't mean you couldn't have a Seam component lookup and outject that static variable (and then inject and set the variable). Although this brings us, why not just have getter/setters?

          If you really wanted to you may also be able to abuse a custom DataBinder into doing what you want as well.

          • 2. Re: Accessing static finals
            Jim Hazen Expert

            A less crazy solution might be to simply access your entity via a session/conversation scoped Seam component wrapper/decorator. Still could be more trouble than it's worth.