Development Portlet First step: How to develop static portlets based on crystal?

Source: Internet
Author: User

When the team needs to develop porltet based on crystal, it is divided into the following three parts:

    • Developing static portlets based on Crystal
    • Dynamic portlets based on modifying static portlets to test data
    • Linking dynamic portlets to Dynamic Data Services

So how do you develop static portlets based on crystal?

Step 1, create a project
    • Prepare the eclipse-based Liferay development environment and replicate the static Portlet development project Static-development-portlet, with the following directory structure:

The template project contains 4 portlets that are easy to initialize, with the following specific initialization items:

    • To modify the project name information:

/static-development-portlet/pom.xml file : Modify the group ID, Artifact ID, and version information to specify values for the project

/static-development-portlet/src/main/webapp/web-inf/liferay-plugin-package.properties Files : Specify values for items such as modifying the corresponding information

/static-development-portlet/src/main/webapp/web-inf/liferay-plugin-package.xml Files : Specify values for items such as modifying the corresponding information

2, modify (add, delete) portlet information:

/static-development-portlet/src/main/webapp/web-inf/portlet.xml file:

Each <portlet></portlet> tag corresponds to a portlet definition, and the template file contains four portlet definitions, which can be modified or deleted according to actual needs.

Portlet-name information must be English, globally unique, according to the project designation, the general structure of the "Project Code"-"Porlet code", the word between the words with "-" separated.

Display-name is used in the management process to distinguish which portlet,titile is used to display the title text on the Portlet border, and to take concise and straightforward text.

Portletsetupshowborders is whether the border is displayed by default, Fase is not displayed.

In the following sample code, except for Portlet-name and Chinese content, it is not changed.

<portlet> <portlet-name>Static-user-list</portlet-name> <display-name> user list (static) </display-name> <portlet-class>com.gsoft.crystal.portlet.crystaldispatcherportlet</portlet-class> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <p Ortlet-mode>view</portlet-mode> </supports> <resource-bundle>content. language</resource-bundle> <portlet-info> <title> User Management (static) </title> &lt ; Short-title> user Management (Static) </ Short-title> <keywords> User Management (Static) </keywords> </portlet-info> <portlet-preference s> <preference> <name>portletSetupShowBorders</name> <val Ue>false</value> </preference> </portlet-preferences> <security-role-ref> <role-name>administrator</role-name> </security-role-ref> </portlet>

/static-development-portlet/src/main/webapp/web-inf/liferay-portlet.xml file:

Each <portlet></portlet> tag corresponds to a portlet definition, and the template file contains four portlet definitions, which can be modified or deleted according to actual needs.

The portlet-name must correspond to portlet-name one by one in the portlet.xml file .

The rest is the path to loading icons, CSS, and JS files to ensure consistency with the specific file path.

<portlet><portlet-name>Static-user-list</portlet-name><icon>/images/ User-list.png</icon>2.1. 1. js</footer-portlet-javascript><footer-portlet-javascript>/js/bootstrap.min.js</ footer-portlet-javascript><footer-portlet-javascript>/js/bootstrap-multiselect.js</ Footer-portlet-javascript><footer-portlet-javascript>/js/user-list.js</footer-portlet-javascript ></portlet>

/static-development-portlet/src/main/webapp/web-inf/liferay-display.xml file:

For example, add the defined portlet to the STATIC-DEV classification.

Modify or delete ****-portlet.xml files under the/static-development-portlet/src/main/webapp/web-inf/spring directory

WHERE * * * corresponds to the value of the Portlet-name property (remove the bar, such as Portlet-name is Test-list, the file name is Testlist-portlet.xml).

Modify the corresponding package path (must be com.gsoft.portlet, the child package, otherwise an unknown problem may occur).

Modify the directory where the JSP file resides.

Create a folder for each portlet under the/static-development-portlet/src/main/webapp/web-inf/jsp directory, consistent with the path specified on the file.

Create a Portlet class under the Com.gsoft.portlet.demo.application package with unlimited class names:

The contents are as follows:

/** * @author SHENCQ **/@Controller Public classApplicationmanagementportlet extends Abstractcrystalportlet {@RequestMapping PublicString View (model, renderrequest request) {return "View"; } @RequestMapping (params="Action=add")     Publicstring View4add (model model, @RequestParam string rediract) {Model.addattribute ("rediract", rediract); return "Add"; } @RequestMapping (params="Action=save")     Publicstring Save (model, @RequestParam string rediract) {Model.addattribute ("rediract", rediract); return "pop_up_success"; }}

Where, return "* * * * *", corresponding to the JSP directory specified above the JSPs filename, the identity jumps to the ****.jsp file.

Default execution:

method, if you need to request additional methods, you can take parameters such as Action=add in the request parameters, you can perform the following methods:

To create a static resource file and a JSP file:

Wherein, in the JSP file, in addition to static code, if you need to request a service jump page or execute the JS code, can be as follows:

3. Publishing Portlets

Create a Liferay Portal Server

Move the Portlet project to the server under deployment

You can use Portlets to start a service, modify JSPs, static files, and so on, which are typically automatically updated, such as not automatically updated, to manually redeploy portlets.

Development Portlet First step: How to develop static portlets based on crystal?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.