The following screen shows the creation of a contact data verification script. You can see the
select box for the default script event (1) which can be bound to a script. In this case it is
BeforeContentSave.
If the default script event is set to
Manual, the script can be executed via the
administration UI in the
script overview.
| List of available events | ||
|---|---|---|
|
|
|
The following screen shows the script overview. You can see the script
ClearLiveTree.gy
(1), which can be executed manually via the administration UI,
and other scripts, bound to different
events.
The following screen shows the [fleXive] Script console. It allows you to execute scripts directly at the EJB layer.
You can choose between the following languages and file extensions (1):
gy: Groovy v1.5.1 (Bundled GroovyShell v1.5.1)
groovy: Groovy v1.5.1 (Bundled GroovyShell v1.5.1)
js: ECMAScript v1.6 (Mozilla Rhino v1.6 release 2)
If you want to execute the script on the web layer, check the option
Execute at Web layer
(2). Mind that this feature is only available for bundled Groovy!
The Groovy code in this example creates a new tree node in the
Edit tree
of the
Content Tree. The
node's name is
NodeName
and its label
NodeLabel.
You might want to copy paste the example and try it out:
import com.flexive.shared.EJBLookup; import com.flexive.shared.interfaces.TreeEngine; import com.flexive.shared.tree.FxTreeNodeEdit; import com.flexive.shared.value.FxString; //Lookup the tree interface TreeEngine tree = EJBLookup.getTreeEngine(); //create new node FxTreeNodeEdit node = FxTreeNodeEdit.createNew("NodeName"); FxString label = new FxString(false, "NodeLabel"); node.setLabel(label); //create the node long id = tree.save(node);