Forum Discussion
4 Replies
- DougS10 years agoKhoros Oracle
You can't access an endpoint from a component server-side (in the freemarker logic). You will need to use javascript to call the endpoint from your component.
Another option you can try is to make your http.client call in your page initialization script then set the result as the value of a request attribute: use the http.request.setAttribute call (that is documented on the http request freemarker context object article) in your page initialization script, then use thehttp.request.attributes.name.get call to retrieve the attribute in your component(s).
-Doug
- AdamN10 years agoKhoros Oracle
Hi dustin,
I'm curious what you're trying to accomplish by calling the endpoint via FreeMarker? What I've found in the past is that when I wanted to do something like this, I could instead move my endpoint logic to a FreeMarker macro. I can then call that macro both from the endpoint (if I want to access the results externally) or from a custom component (if I want to access the results internally).
Check out this page for more information:
I hope this helps!
- luk10 years agoBoss
@Doug Does that "Another option you can try is to make your http.client call in your page initialization script then set the result as the value of a request attribute" mean that you can access an Endpoint with FreeMarker from within the page init script??
- DougS10 years agoKhoros Oracle
luk wrote:
@Doug Does that "Another option you can try is to make your http.client call in your page initialization script then set the result as the value of a request attribute" mean that you can access an Endpoint with FreeMarker from within the page init script??
It does not mean you can directly call an endpoint from your components. As AdamN mentioned before, you can call a macro from your page init script, so you could put your http.client logic in that macro and you would be able to call it from your page init script, as well as from an endpoint. If you only need to use it in your page init script, you could put the http.client logic directly in there instead. You would still need to put the result of the http.client call in a request attribute (see the http.request.setAttribute call and the http.request.attributes.name.get call in the http.request freemarker object) in order to access the results in components.
Related Content
- 10 years ago