我已经开发了一个简单的facet portlet。更改了faces-config.xml
中的ViewHandler,正如书中所说:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config
1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config xmlns="http://java.sun.com/JSF/Configuration">
<application>
<view-handler>
com.sun.facelets.FaceletPortletViewHandler
</view-handler>
</application>
<factory>
<faces-context-
factory>com.liferay.util.bridges.jsf.myfaces.MyFacesContextFactoryImpl</faces-
context-factory>
</factory>
</faces-config>
有2个.xhtml
页面:template.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<html>
<head>
</head>
<body>
<h:outputText value="block"></h:outputText>
<h:outputLabel value="label" for="input"/>
<h:inputText id="input"/>
JUST TEXT
<ui:insert name="insertBlock">
<h:outputText value="defaultText"></h:outputText>
</ui:insert>
</body>
</html>
和insertedBlock.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition template="template.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<ui:define name="insertBlock">
<h:outputText value="Inderted block"/>
<h:outputLabel value="test label" for="testInput"/>
<h:inputText id="testInput"/>
</ui:define>
</ui:composition>
portlet . xml: <?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<portlet-name>LiferayFirstPortlet_war_exploded</portlet-name>
<display-name>LiferayFirstPortlet_war_exploded</display-name>
<portlet-class>com.test.HelloWorld</portlet-class>
<init-param>
<name>default-view</name>
<value>insertedBlock.xhtml</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>LiferayFirstPortlet_war_exploded</title>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
</portlet-app>
当我在Liferay上部署此portlet时,没有显示任何错误。但是,当我在页面上添加portlet时,IT IS EMPTY—只是一个空矩形。页面的代码(fireBug中的html代码检查)显示portlet中也没有内容。
我做错了什么?
您是否包含了特定于生命周期的工件?对于要在生命周期中部署的portlet,工件需要一些生命周期特定的配置文件。您可以使用Liferay Plugin SDK创建一个骨架工件。(您可以在附加文件下载部分找到它。)
或者您可以下载JSF示例并修改它以匹配您的配置。