Liferay:Facelet portlet是空的

时间:2011-04-29 15:05:09

标签: jsf liferay

我开发了一个简单的facelet 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时,它是空的 - 只是空矩形。页面代码(fireBug中的html代码检查)显示portlet中没有内容。

我做错了什么?

1 个答案:

答案 0 :(得分:-1)

您是否包含了liferay特定的工件?对于要在liferay中部署的porlet,工件需要一些liferay特定的配置文件。您可以使用Liferay插件SDK创建骨架工件。 (您可以在其他文件下载部分找到它。)

或者您可以下载JSF samples并更改它以符合您的配置。