Creating an Ext plugin
You can create Ext plugins in Liferay Developer Studio or in your terminal environment. The Ext plugin is stored in the
ext directory of the Plugins SDK (see Chapter 2, The Plugins SDK).
Using Developer Studio
Go to File → New → Liferay Project.
Fill in example for Project name and Example for Display name.
Select the Liferay Plugins SDK and Portal Runtime you’ve configured.
Select Ext for your Plugin type.
Figure 8.1: Creating an Ext plugin
The Plugins SDK automatically appended
-ext to the project name when naming the parent folder of your Ext plugin. In Developer Studio, you can either create a completely new plugin or add a new plugin to an existing plugin project.
Using the terminal
Navigate to the ext directory in the Liferay Plugins SDK and enter the appropriate command for your operating system to create a new Ext plugin:
In Linux and Mac OS, enter
./create.sh example "Example"
In Windows, enter
create.bat example "Example"
BUILD SUCCESSFUL message from Ant tells you there’s a new folder named
example-ext inside the
ext folder in your Plugins SDK. The Plugins SDK automatically named the EXT by appending
-ext to the project name.
Anatomy of the Ext Plugin
The structure of your new
example-ext folder looks like this:
Figure 8.2: Here’s the directory structure in the Ext plugin’s Package Explorer
Let’s look at a few of the
/docroot/WEB-INF/ subdirectories in more detail:
ext-impl/src: Contains the
portal-ext.properties configuration file, custom implementation classes, and in advanced scenarios, classes that override core classes within
ext-lib/global: Contains libraries that should be copied to the application server’s global classloader upon deployment of the Ext plugin.
ext-lib/portal: Contains libraries to be copied inside Liferay’s main application. These libraries are usually necessary because they are invoked from the classes added in
ext-service/src: Contains classes that should be available to other plugins. In advanced scenarios, this directory contains classes that overwrite the classes of
portal-service.jar. Service Builder puts the interfaces of each service here.
ext-web/docroot: Contains the web application’s configuration files, including
WEB-INF/struts-config-ext.xml, which allows you to customize Liferay’s core struts classes. However, hooks are recommended for customizing a struts action. Any JSPs that you’re customizing also belong here.
ext-util-taglib: These folders are needed only in scenarios where you need to customize the classes of three libraries provided with Liferay:
util-taglib.jar, respectively. Otherwise you can ignore these directories.
By default, several files are added to the plugin. Here are the most significant:
Tip: After creating an Ext plugin, remove the files you don’t need to customize from
docroot/WEB-INF/ext-web/docroot/WEB-INF. Liferay keeps track of the files deployed by each Ext plugin and won’t let you deploy multiple Ext plugins that override the same file. If you remove unnecessary (uncustomized) files, you’ll avoid collisions with Ext plugins deployed alongside yours.
You’ve now created an Ext plugin and are familiar with its directory structure and its most significant files. Let’s use your Ext plugin to customize Liferay Portal.