views:

74

answers:

1

I'm a JSP newbie, I understand that there are some kind of taglib files as I understand they are some kind of custom defined JSP tags. Here is a snippet of javascript code which I don't understand :

Polygon.viewPoint = function( index ){  
     window.${ec:safeId('polygon.view')}.Point( Page.ListofPoints.elements[index], index, 100 );
     Page.changeRowColor('row_'+index);
     Page.getProximityList( index );      
     Page.infoWindowLocation = Page.ListofPoints.elements[index];
    }

The javascript question is not really that important, what I'm interested in is this part ${ec:safeId('poygon.view')} I understand that this part is some kind of variable, and that is injected from somewhere. Probably from here <%@ taglib uri="/WEB-INF/tld/tagli-ec.tld" prefix="ec"%> or maybe not .. can someone please explain what is with this $ after window.. what does it represent ?

+1  A: 

To start, the ${} syntax is the EL (Expression Language) syntax. If you're familiar with Scriptlets, this is like <%= %> syntax or in case of PHP the <?= ?> syntax (which becomes deprecated in future release though). It basically just accesses and prints the server side controlled variables at the server side before sending the response to the client side. If you do a 'view source' in your webbrowser, you'll see that it is already parsed/evaluated.

Then there is the ${tagprefix:functionname} syntax which represents EL functions. To the point, this enables you to define static Java methods which takes some arguments and returns the result which can then be accessed in EL. JavaRanch has a quite good FAQ about that. The JSTL for example has also a very useful functions taglib.

BalusC
if this is format is ${tagprefix:functionname} , than what is this ${pageContext.request.contextPath} -> what is what in this variable/scriptlet .. or whatever it is
Gandalf StormCrow
This roughly resolves to jspContext.getPageContext().getRequest().getContextPath(). To start, check JspContext's API doc.
BalusC
Thank you for your simple answers. Less is more :D
Gandalf StormCrow
You're welcome.
BalusC