Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

OGNL is the Object Graph Navigation Language - see http://www.ognl.org for the full documentation of OGNL. In this document we will only show a few examples of OGNL features that co-exist with Webwork.

Basic Expressions
Anchor
basic
basic

To review basic concepts, refer to OGNL

Collections (Maps, Lists)
Anchor
Collections
Collections

Dealing with collections(map,listmaps, lists, and sets) in webwork comes often, so here are a few examples using the select tag:
Syntax for list: {e1,e2}. This creates a List containing the String "name1" and "name2."

...

Lambda Expressions
Anchor
Lambda
Lambda

OGNL supports basic lamba expression syntax enabling you to write simple functions.

For example:

For all you math majors who didn't think you would ever see this one again.
fibonacci Fibonacci: if n==0 return 0; elseif n==1 return 1; else return fib(n-2)+fib(n-1);
fib(0) = 0
fib(1) = 1
fib(11) = 89

The lambda expression is everything inside the brackets. The #this variable holds the argument to the expression, which is initially starts at 11.

Code Block
<ui<ww:property value="#fib =:[#this==0 ? 0 : #this==1 ? 1 : #fib(#this-2)+#fib(#this-1)], #fib(11)" />

...