Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EL ${} syntax  RSS feed

 
Andreas Oikonomou
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I understand the immediate (${}) syntax was inadequate for jsf and so defered #{} syntax was created.

Is there any case that I must use immediate syntax instead of defered one or does immediate syntax has any advantage over defered syntax?
 
Tim Holloway
Bartender
Posts: 18704
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "deferred" syntax, as you call it, is a superset of the "immediate" syntax.

One of the primary differences between "${}" and "#{}" is that the $-notation expressions indicate a value that must render as a string (write-only), whereas "#" defines reference expressions and therefore can be used when you want the value in question to be read/write.

By accidentally mistyping an EL expression just the other day, I discovered that an "$" gets turned into a String expression and can throw exceptions in cases where "#" would not.

As far as having any use for "$" notation in JSF, I could think of 2:

1. To explicitly indicate a display write-only String value.

2. It's theoretically possible that the "$" notation expressions could require less processing to be realized, but I wouldn't prematurely optimize on that assumption nor on the assumption that all $-notation expressions process faster.

Neither of the above compensate for the fact that junior personnel (and distracted senior ones) are likely to get confused if presented with page templates with mixed $- and #-notation expressions, and it is not the industry norm, so I wouldn't recommend it. People get confused enough without that, as you can see by my constant nagging of people NOT to code method-reference expressions with "()" in them.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!