cancel
Showing results for 
Search instead for 
Did you mean: 

Import jQuery or other library in controller script?

gronfelt
Champ in-the-making
Champ in-the-making
I would like to use a library like jQuery or YUI in my controller scripts. However, when I try to import these libraries there are always some errors, because they expect to be in a browser environment, using objects such as "document" or "window".

Is there anyway around this?
4 REPLIES 4

mikeh
Star Contributor
Star Contributor
I would just pull the functions you need out of the libraries - what are you trying to achieve?

The other path you might try going down is to create "fake" document and window JavaScript objects - although I suspect you'll end up stubbing-out half the browser's API in order to keep the libraries happy!

Mike

gronfelt
Champ in-the-making
Champ in-the-making
I want to make remote calls to another web service, so I'd like to use the simplified AJAX functions. I've seen that Alfresco Share has a remote API, but as far as I understand it only supports http (I'd need https), right?

mikeh
Star Contributor
Star Contributor
The problem you'll have is that the XmlHttpRequest object isn't supported by Rhino, so you won't get any AJAX-style functionality anyway.

The remote/connector API should support https as far as I'm aware (please raise a JIRA bug if this doesn't work); you'd need to update or add new endpoints in the webscript-framework configuration.

Thanks,
Mike

gronfelt
Champ in-the-making
Champ in-the-making
Ok, thanks a lot for your input. If it´s possible to get https working I think that the connector API would suit my needs perfectly. I'm not really interested in AJAX functionality, I just want a simple way to connect to a remote web service, retrieve information and present it in a dashlet.