首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

liferay portlet上添print按钮

2012-06-29 
liferay portlet上加print按钮?在Eclipse生成的代码上改装。?使用MVCPortlet在portlet.xml中,

liferay portlet上加print按钮

?

在Eclipse生成的代码上改装。

?

============使用MVCPortlet

在portlet.xml中,替换

<portlet-class>com.test.NewPortlet</portlet-class>

<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>

对初学而言,这样可以避免很多麻烦。使用MVCPortlet后,不需要写java代码,就能实现print页面。

?

============加jstl相关的jar文件

加jstl-1.2.jar和standard.jar到WEB-INF/lib下,便于项目中使用jstl。

?

============修改portlet.xml

把<value>/html/print.jsp</value>

改成<value>/html/view.jsp</value>

让print和view使用同一页面。

?

============加代码到view.jsp

<%@ page contentType="text/html; charset=UTF-8" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>

<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>

<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>

<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>

?

<%@ page import="com.liferay.portal.kernel.util.HtmlUtil

,com.liferay.portal.kernel.portlet.LiferayPortletMode

,com.liferay.portal.kernel.language.LanguageUtil

" %>

<%---- 下面2个定义很有用,enable renderRequest, portletDisplay ----%>

<portlet:defineObjects />

<liferay-theme:defineObjects />

?

<%---- 初始化print相关参数 ----%>

<%?

String portletTitle = HtmlUtil.unescape(portletDisplay.getTitle());

boolean print = renderRequest.getPortletMode().equals(LiferayPortletMode.PRINT);

%>

?

<%---- 画print按钮,参考/portal-trunk/portal-web/docroot/html/portlet/journal_content/view.jsp ----%>

<c:if test="<%= print %>">

<div alt="liferay portlet上添print按钮" width="363" height="278">

春风得意

?

note: why iteye? sina cannot paste code freely, iteye can.

热点排行