77范文网 - 专业文章范例文档资料分享平台

Liferay6 开发 环境部署 Liferay6实例(4)

来源:网络收集 时间:2019-04-22 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

Liferay 6 Development Documentation

name varchar(100) default NULL, qty int(11) default NULL, comment varchar(100) default NULL, date_added timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8

2. Create product_service.xml to generate source code

File path:

/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/product_service.xml product You should add or remove a table column in this file. 3. Create build.xml for to run the product_service.xml

File path: /myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/build.xml Run the build file auto generate source code under below path:

/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/model/impl /myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/base /myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/impl /myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/persistence

Liferay 6 Development Documentation

Notice: a) b)

Please noted that path must be right, otherwise will not create successfully.

Since this class is auto generated, you should never modify it, or your changes will be overwritten the next time you run Service Builder. Instead, all custom code should be placed in XXXLocalServiceImpl.

4. Add a method to the service layer.

Add the following method to to ProductLocalServiceImpl.java File path:

/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/impl/ProductLocalServiceImpl.java

package com.accentrix.ecatalog.product.service.impl; import java.util.List;

import com.accentrix.ecatalog.product.model.Product;

import com.accentrix.ecatalog.product.service.base.ProductLocalServiceBaseImpl; import com.liferay.portal.kernel.exception.SystemException; /**

* @author tom.wu * */

public class ProductLocalServiceImpl extends ProductLocalServiceBaseImpl { }

public List findByName(String name, int start, int end) throws SystemException { }

public int countByName(java.lang.String name) throws SystemException { }

int count = productPersistence.countByName(name); return count;

List list = productPersistence.findByName(name, start, end); return list;

5. Add ProductSearch.java for search result

File path:

/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/ProductSearch.java

package com.accentrix.ecatalog.product.action; import java.util.ArrayList; Liferay 6 Development Documentation

import java.util.HashMap; import java.util.List; import java.util.Map;

import javax.portlet.PortletRequest; import javax.portlet.PortletURL;

import com.accentrix.ecatalog.product.model.Product; import com.liferay.portal.kernel.dao.search.SearchContainer; import com.liferay.portlet.enterpriseadmin.search.RoleDisplayTerms; /**

* @author tom.wu * */

public class ProductSearch extends SearchContainer {

public ProductSearch(PortletRequest portletRequest, PortletURL iteratorURL) {

super(portletRequest, new RoleDisplayTerms(portletRequest), new ProductSearchTerms(portletRequest), public static final String EMPTY_RESULTS_MESSAGE = \; static { }

headerNames.add(\); headerNames.add(\); headerNames.add(\);

static List headerNames = new ArrayList();

static Map orderableHeaders = new HashMap();

DEFAULT_CUR_PARAM, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE); }

}

6. Create ProductSearchTerms.java for search term query.

File path:

/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/ProductSearchTerms.java

package com.accentrix.ecatalog.product.action; import javax.portlet.PortletRequest; Liferay 6 Development Documentation

import com.liferay.portal.kernel.dao.search.DAOParamUtil; import com.liferay.portal.kernel.dao.search.DisplayTerms; /**

* @author tom.wu * */

public class ProductSearchTerms extends DisplayTerms { }

public void setName(String name) { }

this.name = name; public String getName() { }

return name;

public ProductSearchTerms(PortletRequest portletRequest) { }

super(portletRequest);

// name = ParamUtil.getString(portletRequest, NAME); name = DAOParamUtil.getLike(portletRequest, NAME); public String name;

public static final String NAME = \

7. Update ProductAction.java (already added in second part)

File path:

/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/ProductAction.java /** * */ package com.accentrix.ecatalog.product.action; import java.util.List; import javax.portlet.PortletConfig; import javax.portlet.PortletURL; import javax.portlet.RenderRequest; Liferay 6 Development Documentation

import javax.portlet.RenderResponse; import javax.portlet.WindowState;

import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;

import com.accentrix.ecatalog.product.model.Product;

import com.accentrix.ecatalog.product.service.ProductLocalServiceUtil; import com.liferay.portal.kernel.dao.search.ResultRow; import com.liferay.portal.kernel.util.ParamUtil; 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 {

List results = ProductLocalServiceUtil.findByName(searchTerms.getName(), searchContainer.getStart(),

ProductSearchTerms searchTerms = (ProductSearchTerms) searchContainer.getSearchTerms();

// set table header

ProductSearch searchContainer = new ProductSearch(req, portletURL); searchContainer.setDeltaConfigurable(false);

// search term,return all result if name is null String name = ParamUtil.getString(req, \PortletURL portletURL = res.createRenderURL(); portletURL.setWindowState(WindowState.MAXIMIZED);

portletURL.setParameter(\portletURL.setParameter(\

searchContainer.getEnd());

for (int i = 0; i < results.size(); i++) {

searchContainer.setTotal(total); searchContainer.setResults(results);

List resultRows = searchContainer.getResultRows(); req.setAttribute(\

int total = ProductLocalServiceUtil.countByName(searchTerms.getName());

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Liferay6 开发 环境部署 Liferay6实例(4)在线全文阅读。

Liferay6 开发 环境部署 Liferay6实例(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/619664.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: