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. 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. To access Liferay’s scripting console, navigate to the Control Panel, click on Server Administration under the Configuration heading, then open the Script tab.

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. Even if you don’t leverage custom scripts, it’s a powerful and robust...

Read More

Custom Java Tools in the Script Engine

Users of the Script Engine face several challenges, including debugging and logging challenges. One approach to overcome these challenges is to develop custom Java utilities that can be called from...

Read More

Summary

In this chapter, we saw how Liferay’s script engine opens up many exciting possibilities for working with Liferay. You can write and execute scripts from Liferay’s Script console in the Control...

Read More
0 (0 Votes)
Summary Previous