cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Custom Script APIs

_valerio_
Champ in-the-making
Champ in-the-making
HI everybody Smiley Very Happy
I read the wiki on Adding Custom Script APIs  on http://wiki.alfresco.com/wiki/3.0_JavaScript_API#How_is_Scripting_integrated_into_Alfresco.3F, but I didn't understand how to create a new java object to implement new methods (for extending the methods still availables in alfresco, like default document.content, and so on) that later will be availables as root objects.
I understood that in the  file script-services-context.xml I should create a bean with the name of my java object (with the methods I want to use), like
<bean id="MY_OBJECT_NAME" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.ScriptLogger">
    <property name="extensionName">
        <value>????????</value>
    </property>
</bean>
but I didn't understand how to fill the field ?????? and, specially, in which folder suould I create my new java object.

thanks to all that will answer this question Smiley Very Happy
1 REPLY 1

tfrith
Champ on-the-rise
Champ on-the-rise
The value for <extensionName> is what you want to refer to your java class as from within javascript.

So if your java exposed a method called doTest() and you set <extensionName>test</extensionName> then in javascript you would call:
test.doTest()

And your java class should probably go in a jar file on the classpath, eg /alfresco/tomcat/webapps/alfresco/WEB-INF/lib.

And of course the class attribute of the <bean> tag should point to your java class that contains the doTest() method and extends BaseProcessorExtension.