Liferay create site / page programmatically

我只是一个虾纸丫 提交于 2019-12-13 04:46:20

问题


I have been using Liferay for work for 2 weeks. I noticed that it's a bit difficult to find good documentation and tutorials. Until now I created pages from the web portal. After I create them, I drag and drop portlets. I don't really like this approach, I would prefer to use a coding approach. Is there a way to create a website or page programmatically by defining a project as I do to create portlets?

Moreover, I am using Liferay with WebLogic 10.3.6. I want to know where liferay puts pages I created via web-portal on the file system. I suppose that a file, or something similar, is created when I declare a new site on the Liferay web-portal.

Thank you all,

Marco


回答1:


Yes Liferay has it's Database, all data of any Liferay object is stored in the database and / or on the file system depending on your configuration.

However, one of the functionality of Liferay is to let you create pages / sites through the UI. As documented in the Java Portal Specification and Liferay Server Documents your approach to create pages in an alternative way is possible but it is part of Liferay's Portal Services. You can use Liferay's Service (HTTP REST) API to call the related service. To access those APIs you need to configure your Liferay Server.

In case you want to do programmatically you still need to configure, enable and call those external HTTP services from your code. You should not create Liferay Objects from your own code hosted as an extension inside your Liferay Instance as that will result inconsistency in your Liferay Database / filesystem. (As in case of page creation Liferay creates a set of other related objects in it's database / filesystem.)




回答2:


In your liferay bundle you will find two plugins of interest.

First is resources-importer-web for which description says

The Resources Importer app allows front-end developers to package web content, portlet configurations, and layouts together in a theme without saving it as a compiled .LAR file thereby allowing for greater flexibility in its usage between Liferay Portal versions.
This app will automatically create associated content when other plugins are deployed that are configured to make use of the Resource Importer app.

This app installs as a Liferay service.

Second is welcome-theme which declares resources to be created by resources-importer-web. This on should be example how to create your own. Take a look at

  1. welcome-theme\WEB-INF\src\resources-importer\*
  2. welcome-theme\WEB-INF\liferay-plugin-package.properties

This feature is described at importing-resources-with-themes




回答3:


As mentioned by gabor_the_kid, Liferay stores all objects in its tables. For example, User related objects would be in user table. Liferay exposed services or API's to change the default/to add new behaviors by program but not easier than achieving it through UI. Also maintenance should be considered for going program way of creating pages or layouts etc.




回答4:


You can describe your changes using xml and use the Liferay Portal DB Setup core to create the changes in DB. The library defines the list of available xml configurations.

There are two examples of how your can use the library: as a portlet, as a hook. That's an alternative to resources importer delivered by Liferay.



来源:https://stackoverflow.com/questions/32823015/liferay-create-site-page-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!