Bean is not recognized

cancel
Showing results for 
Search instead for 
Did you mean: 
theobroma
Active Member II

Bean is not recognized

Jump to solution

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;
}

1 Solution

Accepted Solutions
kalpesh_c2
Senior Member

Re: Bean is not recognized

Jump to solution

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

ContCentric

View solution in original post

2 Replies
kalpesh_c2
Senior Member

Re: Bean is not recognized

Jump to solution

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

ContCentric

theobroma
Active Member II

Re: Bean is not recognized

Jump to solution

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