12-07-2017 04:11 AM
I have configured new multi-select button in the document library:
When the button is clicked it should execute javascript function onActionAddToList which later calls bean function. Everything works except bean function insert, it is not called/recognized since listManagement is not found. Am I doing something wrong? I am wondering if I should configure bean in an other place? I'm using Alfresco 5.2.0 SDK 3.0.1 Below you can find corresponding code:
1. /alfresco/web-extension/site-data/extensions/my-extension.xml -> share-jar
<configurations>
<config evaluator="string-compare" condition="DocumentLibrary">
<multi-select>
<action type="action-link" id="onActionAddToList" icon="document-approve" label="Add item to a list" />
</multi-select>
</config>
<config evaluator="string-compare" condition="DocLibCustom" replace="true">
<dependencies>
<js src="/components/documentlibrary/custom-documentlibrary-actions.js" />
</dependencies>
</config>
</configurations>
2. resources/components/documentlibrary/custom-documentlibrary-actions.js -> share-jar
YAHOO.Bubbling.fire("registerAction", {
actionName: "onActionAddToList",
fn: function custom_onActionAddToList(record)
{
Alfresco.util.PopupManager.displayMessage({ title: "Info", text: listManagement.insert("Hello")});
}
});
3. alfresco/module/project/context/service-context.xml -> platform-jar
<beans>
<bean id="com.test.actions.ListManagement" class="com.test.actions.ListManagement" parent="baseJavaScriptExtension">
<property name="extensionName" value="listManagement"/>
</bean>
</beans>
4. java/com/test/actions/ListManagement.java -> platform-jar
public class ListManagement extends BaseProcessorExtension {
public String insert(String text) {
return text;
}
12-07-2017 05:33 AM
Hi
Custom javascript root objects created in java are only accessible from server side javascript so listManagement.insert("Hello") is not accessible from custom-documentlibrary-actions.js file. If your requirement is to create custom document library actions, you can create java backed actions referred in Adding new actions to the Document Library | Alfresco Documentation .
Thanks,
Kalpesh
12-07-2017 05:33 AM
Hi
Custom javascript root objects created in java are only accessible from server side javascript so listManagement.insert("Hello") is not accessible from custom-documentlibrary-actions.js file. If your requirement is to create custom document library actions, you can create java backed actions referred in Adding new actions to the Document Library | Alfresco Documentation .
Thanks,
Kalpesh
12-12-2017 12:13 AM
I solved this problem at the end with RestfulAPIs and Java backend Web script.
Helpful: Alfresco One 5.x Developer’s Guide, 2nd Edition, Chapter 7: Exposing Content through a RESTful API with Web Scripts
Explore our Alfresco products with the links below. Use labels to filter content by product module.