Dims
Dims

Reputation: 51239

How to pack portlet+theme+layout into single WAR/web application in Liferay?

The ROOT application contains all of the items described (classic theme, approx 10 layouts and numerous portlets).

Is it possible or good practice to create own packages like this? How to?

Please, give a hint.

Upvotes: 2

Views: 796

Answers (2)

Prakash K
Prakash K

Reputation: 11698

Theoretically it is possible to have a single project with a Portlet, Theme, Layout and a Hook all packed in one.

But it is not at all a good-practice to have all the four types togather, from both maintenance and development perspective.

Though sometimes you may have a portlet and hook in one project if they are somehow related for example like you want to have some Listeners to add data to your custom table and then your portlet would provide an interface to update or view that data, so in this case they are interdependent and if the portlet goes the hook is of no use. So go ahead and combine them.

So if the 4 types are related somehow or interdependent than I see a usecase to have them togather (it would be rare) but still from maintenance point of view I would rather keep the 4 separate. Atleast I would keep portlets and themes separate and may have a Portlet-hook combination and a theme-layout combination since they go well with each other even from the maintenance & development point-of-view.

Here is how you can do it

  1. Let the name of the project be say MyCompletePackage-portlet
  2. The project can live in the portlets folder of the plugins-sdk if you are using the plugins-sdk.
  3. Now add the plugin-type specific stuff as you normally do, like:
    1. liferay-hook.xml for hooks
    2. liferay-portlet.xml for portlets
    3. liferay-look-and-feel.xml for themes
    4. liferay-layout-templates.xml for layouts
  4. For hook and portlet combination you won't need to modify the build.xml file and just build as you normally do.
  5. Even for theme and layout combination you won't need to modify the build.xml.
  6. But for theme and portlet combination you would need to include theme specific stuff in your build.xml.
  7. Since the deployer looks for the specific files in the project it would know what all things you are deploying and would register them accordingly.

Let me know if this works for you or if you face any issues.

Disclaimer: I have not tried the 6th point but it should work

Upvotes: 2

Ravi Kumar Gupta
Ravi Kumar Gupta

Reputation: 1798

Generally one would add all portlets in one war so that they can access the service without any problems and to save context reloading time.

However Themes with portlets might not be a good idea always since we change theme.. and thus while updating portlets reloading in unnecessary. Well that's once in months but still a statement to keep portlets away from themes war.

Upvotes: 1

Related Questions