4

I have seen and used both, but always wondered what the difference between the two expressions

${foo.bar()}

and

#{foo.bar()}

is in juel.

Any clues? Its hard to google "$" and "#" ....

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jan Galinski
  • 11,768
  • 8
  • 54
  • 77

1 Answers1

4

Functionally, ${} can do only a get, while the #{} can do a get and a set of the value.

Refer Difference between JSP EL, JSF EL and Unified EL for more.

Read JavaEE tutorial:

All expressions using the ${} syntax are evaluated immediately. These expressions can only be used within template text or as the value of a JSP tag attribute that can accept runtime expressions. [...] Immediate evaluation expressions are always read-only value expressions. The expression shown above can only get the total price from the cart bean; it cannot set the total price.

Deferred evaluation expressions take the form #{expr} and can be evaluated at other phases of a page life cycle as defined by whatever technology is using the expression. In the case of JavaServer Faces technology, its controller can evaluate the expression at different phases of the life cycle depending on how the expression is being used in the page.

Also refer to this SO answer.

Community
  • 1
  • 1
AllTooSir
  • 48,828
  • 16
  • 130
  • 164