cancel
Showing results for 
Search instead for 
Did you mean: 

Problem to access pagecontext from FTL

abarisone
Star Contributor
Star Contributor
Hi all,
I have an Rich Client application with a FTL file that includes some ExtJS files.
The context of the installation is not /alfresco but /DOC/alfresco.
The problem is that in this snippet contained in a javascript declaration
… src="${url.context}/uirnet/browser/i18n.js?${url.context}" id="i18n"
the former expression is correctly replaced by /DOC/Alfresco while the latter is replaced by /alfresco.
How could it be possible such different behaviour on the same line?
Besided, is it possible in Freemarker to access context path with something like ${pageContext.request.contextPath}" in order to handle this variable resolution before the scripts are initialized?

Thanks,
Andrea
3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
The registered object url is java class DefaultURLHelper.
DefaultURLHelper.getContext() method will call RequestContext.getContextPath(),which is just request.getContextPath().
So url.context should be equals to request.getContextPath().

Alfresco dose not put HttpRequestObject into freemarker model,but it put HttpRequestHashModel object into the model under the key "Request". 

Hi,
so you're telling me that using freemarker there's no other object than url to access request context path?
My webscript has no controller since it is only uesd to build the page using root objects.
<cite>
Alfresco dose not put HttpRequestObject into freemarker model,but it put HttpRequestHashModel object into the model under the key "Request".
</cite>
Could you be more precise? Is this "Request" object accessible from the freemarker template through a call like ${Request} or something similar?

Thanks,
Andrea

kaynezhang
World-Class Innovator
World-Class Innovator

As far as I know you can only use url object to access request context path

Yes exception "Request" ,objects("RequestParameters","Session","Application") are accessable in freemarker.
But "Request" object is not HttpServletRequest but HttpRequestHashModel,you can use it to get request attribute.