简体   繁体   English

Primefaces标签不起作用

[英]Primefaces tags are not working

I am trying to jumpstart my Primefaces 3.2 development using Eclipse 3.6 and Glassfish 3.1 as app server. 我正在尝试使用Eclipse 3.6和Glassfish 3.1作为应用服务器来启动Primefaces 3.2开发。

When I try to publish my application from Eclipse using this very simple code. 当我尝试使用此非常简单的代码从Eclipse发布应用程序时。

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<ui:composition template="WEB-INF/template.xhtml">
    <ui:define name="content">
        <p:panel header="Login Form">
            <h:form>
                <p:button value="With Icon!" icon="bookmark" />
                <br />
                <p:spinner />
            </h:form>
        </p:panel>
    </ui:define>
</ui:composition>
</html>

The Primefaces is not rendering. Primefaces无法渲染。 The button is showing but no icon and the spinner is showing just an input text. 该按钮正在显示,但没有图标,而微调框仅显示输入文本。

Not sure but I have put the primefaces jar file at the WEB-INF/lib folder. 不确定,但是我已将primefaces jar文件放在WEB-INF / lib文件夹中。

Although I see this error at glassfish log. 虽然我在glassfish日志中看到此错误。

[#|2012-04-17T11:37:56.864+0800|INFO|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.renderkit|_ThreadID=23;_ThreadName=Thread-2;|WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=null[severity=(ERROR 2), summary=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.), detail=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.)]|#]

Update: 更新:

Sorry here is my web.xml 抱歉,这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
</web-app>

My template 我的范本

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
  <title><ui:insert name="title">My Test Application</ui:insert></title>
</head>
<body>
<div id="header">
    <ui:insert name="header">
        <h1>Header</h1>
    </ui:insert>
</div>
<div id="content">
  <ui:insert name="content">

  </ui:insert>
</div>

<div id="footer">
  <ui:insert name="footer">
        <br/><br/>Footer!
  </ui:insert>
</div>
</body>
</html>

you need to make the following change in template.xhtml file, for example 例如,您需要在template.xhtml文件中进行以下更改

<f:view>
  <h:head>
   <title><ui:insert name="title">insert title</ui:insert></title>
   <meta content="text/html; charset=UTF-8" http-equiv="Content-type" />
   <link type = "text/css"  rel="stylesheet" href="/your/theme/skin.css" />
   </h:head>

Hope this will help you. 希望这会帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM