Our documentation has been relocated here, the Liferay Developer Network. Please update your bookmarks!

Using Scripting for Advanced Flexibility

Liferay provides a robust script engine that can be used to interpret scripts in Beanshell, Javascript, Groovy, Python and Ruby. The script engine came out of Liferay’s involvement with the Romulus project (http://www.ict-romulus.eu). It was originally developed to support non Java-based portlets, but has now been extended to handle a lot more. For example, when Liferay’s workflow framework was introduced, the script engine was leveraged to support the execution of scripts from within a workflow module. A script console is now included in the Server Administration portlet in the control panel. It allows system administrators an easy way to execute scripts to perform repetitive user maintenance operations, bulk manipulations using the Liferay API to ensure consistency, or even system level operations.

This chapter helps you to understand Liferay’s script engine and covers the following topics:

  • Accessing Liferay’s service layer from a script

  • Running scripts from the script console

  • Using the script engine with workflow

  • Leveraging custom Java tools in the script engine

The most common thing you’ll want to do is access Liferay’s services. If you have any familiarity with Liferay’s developer tools and API, this will be a snap for you.

Accessing Liferay Services

In many cases, you’ll want to interact with one of Liferay’s many services. This is possible from all of the scripting languages supported, but the syntax is a little different for each language....

Read More

Running Scripts from the Control Panel

To see a very simple example of the script console in action, log into the portal as an administrator and navigate to the control panel → Server Administration → Script. Change the script type to...

Read More

Leveraging the Script Engine in Workflow

Liferay’s Kaleo workflow engine provides a robust system for reviewing and approving content in an enterprise environment. Just with the standard feature set, it is a powerful and robust workflow...

Read More

Custom Java Tools in the Script Engine

There are several challenges when working with the Script Engine, including debugging and logging. One approach to overcome these challenges is to develop custom Java utilities that can be called...

Read More

Summary

In this chapter we saw how Liferay’s script engine opens up many exciting posibilities for working with Liferay regardless of your language of choice. We learned how you can leverage Liferay’s...

Read More
0 (0 Votes)
Summary Previous