Standard Expression syntax

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Standard Expression syntax


I go through the STANDARD EXPRESSION SYNTAX given at the below link

But in a project I go through the below syntex in html file


I understand it is a url as it start '@' media is a containing object in current object say it is X.

But can some one tell me what is the meaning of {Media['primary].url}. Here we use barcket like '[]' and 'primary' . But I do not know about these syntex please explain this and give me a tutorial link where i can learn such type of syntex of Standard Expression syntax

Hope I am able to tell you my query.
Reply | Threaded
Open this post in threaded view

Re: Standard Expression syntax

The standard expression syntax is based on Apache OGNL, so you can find more information about the square bracket syntax on OGNL's Language Guide page:

The sections on Referring to Properties and Indexing go on to say that the following are equivalent:


In both cases, OGNL will look for a Java Bean property called "primary" on the media object (eg: it will call media.getPrimary()/media.isPrimary(), or read media.primary if primary is publicly accessible), or, if the media object is a map type, it will look for the item with the key of "primary" (eg: it will call media.get("primary")).

Using the . syntax or the [] syntax when referring to object properties of map keys is completely up to the developer.  I think the only time you really need to use [] is when accessing an array by the index (eg: array[0] to get the first item in the array).