Liferay 6 Development Documentation
2. Edit project properties
You can find a file named “portal-ext.properties” in path: /myliferay-ext/docroot/WEB-INF/ext-impl/src a) For JDBC configure: jdbc.default.driverClassName=com.mysql.jdbc.Driver jdbc.default.url=jdbc:mysql://localhost/ecatalogue?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false jdbc.default.username=root jdbc.default.password=123456 b) For Auto creating predefine table and filling initial data: (just use for initial
database in first time) schema.run.enable=true schema.run.minimal=true Liferay 6 Development Documentation
c) Hibernate setting: hibernate.show_sql=true
3. Create a empty Liferay6 schema by the “jdbc.default.url” in properties
e.g.: ecatalogue
4. Change the default build.xml for deployment.
Create a new portlet
1. Before to start the following steps, please do some things first: 1) 2) Create a folder \/myliferay/docroot/WEB-INF/ext-web/docroot/html/portlet/product Create a folder \/myliferay/docroot/WEB-INF/ext-impl/src/content, then create a file name \Language-ext_en.properties\3) Copy liferay-display.xml from Liferay Tomcat installed path liferay-portal-tomcat-6.0.5\\${TOMCAT_HOME}\\webapps\\ROOT\\WEB-INF to /myliferay/docroot/WEB-INF/ext-web/docroot/WEB-INF
2. Create a Java Action file in this path:
File path:
/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/action/PortletAction.java /** * */ package com.accentrix.ecatalog.action; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.PortletConfig; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; Liferay 6 Development Documentation
import com.liferay.portal.struts.PortletAction; /** * @author tom.wu * */ public class ProductAction extends PortletAction { public ActionForward render(ActionMapping mapping, ActionForm form, } }
PortletConfig config, RenderRequest req, RenderResponse res) throws Exception { if (getForward(req) != null && !getForward(req).equals(\ return mapping.findForward(getForward(req)); } else { } return mapping.findForward(\3. Create a JSP file
File path: /myliferay/docroot/WEB-INF/ext-web/docroot/html/portlet/product/products.jsp <%@ include file=\%> This is theProduct Listportlet.
4. Struts xml file setting
File path: /myliferay/docroot/WEB-INF/ext-web/docroot/WEB-INF/struts-config-ext.xml
5. Tiles xml setting
File path: /myliferay/docroot/WEB-INF/ext-web/docroot/WEB-INF/tiles-defs-ext.xml Liferay 6 Development Documentation
6. Portlet-ext.xml setting
File path: /myliferay/docroot/WEB-INF/ext-web/docroot/WEB-INF/portlet-ext.xml
7. Liferay-portlet-ext.xml setting
File path:/myliferay/docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml
8. Liferay-display.xml setting
File path: /myliferay/docroot/WEB-INF/ext-web/docroot/WEB-INF/liferay-display.xml ………
9. Language-ext_en.properties setting
File path: /myliferay-ext/docroot/WEB-INF/ext-impl/src/content/Language-ext_en.properties
javax.portlet.title.product = My Product Portlet
Compiling & Deploying portlet
Now we can deploy the basic configuration, run ant to deploy /myliferay/build.xml
Start the tomcat server and open in browser http://localhost:8080/
Notice: http://127.0.0.1:8080/ may not work in Firefox.
5. Table Maintenance Portlet
Development
We will create a table and coding in this part.
1. Create example table in MySql
CREATE TABLE product ( uuid char(36) NOT NULL,