cancel
Showing results for 
Search instead for 
Did you mean: 

create a custom java-action

mirtunis
Champ in-the-making
Champ in-the-making
Hi all ,
I need return a value from a custom action , so i write the action executer class ,here is the code :

public class AddAspectActionExecuter extends ActionExecuterAbstractBase{
   public static String PARAM_RESULT = "result";
   //private BeanFactory beanFactory ;
   @Override
   protected void executeImpl(Action ruleAction, NodeRef nodeRef) {
      ruleAction.setParameterValue(PARAM_RESULT, "helllloooooooooo");
   }
   @Override
   protected void addParameterDefinitions(List<ParameterDefinition> arg0) {
      // TODO Auto-generated method stub   
   }
}


I compile it and i put the JAR in Alfresco\tomcat\webapps\alfresco\WEB-INF\lib
and i configure the action in Spring in the file rule-context.xml here is the code:
<blockcode>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN'
  'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
<bean id="add-aspect" class="org.alfresco.repo.action.executer.AddAspectActionExecuter" parent="action-executer">
</bean>
</beans>
</blockcode>

i put the file (rule-context.xml) in Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension.

When i try this code in javascript :
<javascript>
var actionOne = actions.create("add-aspect");
print(actionOne.parameters["PARAM_RESULT"]);
</javascript>
the return is null
Maybe I've missed something?
any idea???

Thanks in advance.

1 REPLY 1

mitpatoliya
Star Collaborator
Star Collaborator
That is because your are setting parameter in "executeImpl" method and it is not being called when you create the action. It will be called when you actually execute the action.


execute(node, readOnly, newTxn)
execute(nodeRef)


Above methods can be used to execute the action against the specified node