5 Replies Latest reply on Sep 17, 2007 6:52 AM by gbc1

    Question on Seam Annotataion with JSF-EL language interpreta

    gbc1

      Hello,

      I'm trying to make my own usefull annotation (e.g. for Interceptors) right now and would like to get something similar to:

      @Restrict("#{identity.loggedIn}")
      


      Is it possible for my own annotations to use this feature and let Seam interpret the expression?

      Greetz GHad

        • 1. Re: Question on Seam Annotataion with JSF-EL language interp
          pmuir

          No idea what you are asking. You can use Seam interceptors at the class level as described in the docs?

          • 2. Re: Question on Seam Annotataion with JSF-EL language interp
            gbc1

            Sorry for not clearing my issue right...

            What I mean is that the Expression "#{identity.loggedIn}" is resolved at runtime and substituted by the correct value (true or false).

            I would like to use this substitution feature for my own Annotation (e.g. @Property) thus using injected values instead of fixed strings, e.g.

            
            @Property("#{currentUser.name}") private String someProperty;
            
            


            instead of

            
            @Property("fixedName") private String someProperty;
            
            


            without parsing and evaluating "#{currentUser.name}" manually. Seam should provide the correct value and look through the Contexts.

            I hope it's understandable. I'm using an interceptor right now for injecting Properties from external Properties files into my classes. But in some situations, properties depend on runtime values (like currentUser) that can be different, e.g. when each user should have its own name.properties file.

            Greetz GHad

            • 3. Re: Question on Seam Annotataion with JSF-EL language interp
              pmuir

              Just use Expressions.instance().createValueExpression(property) to evaluate a EL expression.

              • 4. Re: Question on Seam Annotataion with JSF-EL language interp
                gbc1

                Thanks for your reply! Seems exactly what i looked for...

                I'll give it a try over the weekend and report here...

                Greetz, GHad

                • 5. Re: Question on Seam Annotataion with JSF-EL language interp
                  gbc1

                  Thank you again,

                  this works wonderful, one just needs to look for reentrant calls to the interceptor when executing a method via JSF EL (should't go to the same class, because the interceptor gets invoked by the interceptor gets invoked by the interceptor...)

                  Greetz GHad