【问题标题】:Adding PrimeFaces 4 to Java EE project将 PrimeFaces 4 添加到 Java EE 项目
【发布时间】:2014-02-26 17:14:10
【问题描述】:

我正在使用带有 Eclipse Kepler 的 GlassFish 4。

我想将 PrimeFaces 添加到我的 JSF 项目中,但我似乎无法导入它。我不断收到此错误:

警告:此页面调用 XML 命名空间 http://primefaces.org/ui 使用前缀 p 声明,但该命名空间不存在标记库

当我导入 PrimeFaces 4 jar 并重建(使用我的讲师提供的 ANT 构建)并重新部署时,这让我感到困惑。

这是我的 Ant 构建 -

<project name="JavaEE Build" default="BuildAll">

<!-- This needs to be changed before you build your code -->
<property name="glassfish_libs" value="C:\glassfish4\glassfish\modules"/>

<property name="bin" value="./bin"/>
<property name="lib" value="./lib"/>
<property name="src" value="./src"/> 
<property name="dist" value="./dist"/>
<property name="jarfile" value="${dist}/ejb.jar"/>
<property name="warfile" value="${dist}/webapp.war"/>   
<property name="html" value="./WebContent"/>

<path id="my.classpath">
    <pathelement path="${java.class.path}"/>
    <pathelement location="${bin}"/>

    <fileset dir="${lib}">
        <include name="*.jar"/>
    </fileset>

    <fileset dir="${glassfish_libs}">
        <include name="**/javax*.jar"/>
        <include name="jsf-api.jar"/>
        <include name="security.jar"/>
    </fileset>
</path>  

<target name="BuildAll"
        depends="clean, prep, compile, jar, war"
        description="Complete rebuild.">
    <echo message="Build complete."/>
</target>   

<target name="classpath">
       <property name="current.classpath" refid="my.classpath"/>

       <echo level="info">
       Classpath is :
          ${current.classpath}
       </echo>
</target>

<target name="clean">
    <delete dir="${bin}"/>
    <delete dir="${dist}"/>
    <delete>
       <fileset dir=".">
          <include name="TEST*.xml"/>
       </fileset>
    </delete>
</target>

<target name="prep">        
    <mkdir dir="${bin}"/>
    <mkdir dir="${dist}"/>        
</target>

<target name="compile"
 description="Compile all Java classes"
    depends="prep">

    <javac srcdir="${src}" destdir="${bin}" debug="true" encoding="ISO-8859-1">
        <classpath refid="my.classpath"/>
    </javac>

    <echo message="Compiled."/>
</target>

<target name="jar" depends="compile" 
                         description="Build EJB Jar files.">
   <delete file="${jarfile}"/>

   <jar destfile="${jarfile}" basedir="${bin}">

       <metainf dir="${src}/META-INF">
           <include name="persistence.xml"/>
       </metainf>


   </jar>
</target>

<target name="war" depends="compile" 
                         description="Build WAR file.">
    <copy todir="${bin}">
        <fileset dir="${src}">
            <include name="**/persistence.xml"/>
        </fileset>
    </copy>
   <delete file="${warfile}"/>
   <war destfile="${warfile}" webxml="web.xml">
      <classes dir="${bin}">
      </classes>

      <lib dir="${lib}"/>
      <fileset dir="${html}"/>  <!-- html files --> 
      <!-- The following block is commented out, until 
           the chapter on security. Please leave it until then! -->
      <!--
      <webinf dir="${src}/META-INF">
         <include name="sun-ejb-jar.xml"/>              
      </webinf>
      -->   
   </war>
</target>

<target name="ear" depends="war, jar" description="The full ear file">
   <ear destfile="${dist}/fullapplication.ear" appxml="application.xml">
     <fileset dir="${dist}" includes="*.jar,*.war"/>
   </ear>
</target>

那么这里是一个简单的 Facelet - 它被称为 entry.xhtml

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

    <h:body>
        <p:spinner></p:spinner>
    </h:body>                  

我通过右键单击项目 -> 构建路径 -> 配置构建路径 -> 添加外部 jar 导入了 primefaces-4.0.jar 和 primeface-4.0-sources.jar

如果有人能帮忙,那就太好了

【问题讨论】:

    标签: java eclipse jsf primefaces


    【解决方案1】:

    taglib 的定义很奇怪。我使用 primefaces 4.0,PF taglib 的路径是这样的:

    <html ...
      xmlns:p="http://primefaces.org/ui">
    

    您使用的命名空间在 Primefaces 2 中

    如果这没有帮助,请检查 primefaces 库是否真的在您正在部署的战争中。

    【讨论】:

    • 这是使用 primefaces 2.2 所以我需要那个。用 pf 4 试过了,什么也没有
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多