OGNL expressions?

540 views
Skip to first unread message

Frank LaRosa

unread,
Apr 16, 2012, 2:30:01 PM4/16/12
to mybati...@googlegroups.com
The MyBatis documentation says: "MyBatis employs powerful OGNL based expressions to eliminate most of the other elements.". It then goes on to show an example "if" statement that looks like this:

<if test=”title != null”>

I do not know what an OGNL expression is. I'm assuming that the part which reads "title != null" is such an expression. I expected the documentation to further explain to me what other OGNL expressions exist so I could figure out what else is possible in an if statement, but it does not.

What I'm trying to do is write an if statement that selects based on the existence of an enum in a set. In Java, the expression I would write is "mySet.contains(SOME_ENUM.SOME_VALUE)", where SOME_ENUM is an enum and mySet is a Set<SOME_ENUM>. If it is not directly possible to do this in myBatis, I would settle for passing in the values as a set of String. Or perhaps I could create an int that sets a bit for each possible enum value, although for this to work I would need access to bitwise operators in the "OGNL" expression.

If someone could help me out here, and/or point me to some documentation that fully explains my options, I would appreciate it.

Thanks.

Eduardo

unread,
Apr 16, 2012, 2:54:08 PM4/16/12
to mybatis-user
An introduction from the wikipedia

http://en.wikipedia.org/wiki/OGNL

The languaje guide:

http://commons.apache.org/ognl/language-guide.html
Reply all
Reply to author
Forward
0 new messages