mardi 23 juin 2015

How to set an object as "this" in ELProcessor?

I need to evaluate some criteria that are in a format compatible with javax.el. The context of the expression is relative to a single object. For example:

Root is instance of Person
  -name : "Fred"
  -friend: Person
     -name: "Barney"

If my expression is { friend.name eq "Barney" }, how can I have ELProcessor resolve "this" to my object. Can I just do this?

x = new ELProcessor();
x.setValue("this", myRoot);
Boolean expressionTrue = x.eval("{friend.name eq 'Barney'}");

Or do I need to get more elaborate with Resolvers.

Aucun commentaire:

Enregistrer un commentaire