Written by The Jahia Team
   Estimated reading time:

A customer would like to know a way to call a Java Method when a Node is created or published.


A way to call a Java Method is with a rule, you can call an action when a node is created or published

  1. You can set a name to the action inside the spring xml file, something like this:
    <bean class="com.mae.bureau.actualite.SendActualiteNotificationAction" name="actualiteNotificationAction">
        <property name="name" value="actualiteNotificationAction"/>


  2.  With the name of the action specified in the spring file, you can call it in the drools file, and use this consequence:
    rule "Send notification when created actualite"
    Log "----- Before send notification when created an actualite" + node.getName()
    Execute the action "actualiteNotificationAction" now on the node
    Log "----- After send notification when created an actualite: " + node.getName()

Related links