I'm programming in JSF2 and NetBeans creates many pages with #{}
that contains an expression. However sometimes on the web I found ${}
for the same thing!
Are there any differences? What are they?
There is no difference if you do not put $* or $@ in quotes. But if you put them inside quotes (which you should, as a general good practice), then $@ will pass your parameters as separate parameters, whereas $* will just pass all params as a single parameter. Clearly, "$@" gives the behaviour that we generally want.
The difference between “{}” and “[]” is that {} is an empty array while [] is a JavaScript array, but there are more! In JavaScript, almost “everything” is an object. All JavaScript values, except primitives, are objects. Therefore if you understand objects, you understand JavaScript.
So basically, $# is a number of arguments given when your script was executed. $* is a string containing all arguments. For example, $1 is the first argument and so on. This is useful, if you want to access a specific argument in your script.
#{}
are for deferred expressions (they are resolved depending on the life cycle of the page) and can be used to read or write from or to a bean or to make a method call.${}
are expressions for immediate resolution, as soon as they are encountered they are resolved. They are read-only.You can read more here: http://docs.oracle.com/javaee/6/tutorial/doc/bnahr.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With