Lah*_*zey 2 jsf primefaces jsf-2
我有一个简单的JSF页面,显示来自primefaces(Showcase)的文本编辑器.
但是,不显示文本编辑器.当我检查它(铬中的F12)时,我看到多个错误,第一个是:
core.js.xhtml:2 Uncaught ReferenceError: $ is not defined
at Object.resolveUserAgent (core.js.xhtml:2)
at Object.init (core.js.xhtml:2)
at core.js.xhtml:2
Run Code Online (Sandbox Code Playgroud)
其他是Uncaught TypeError:无法读取未定义的属性' 来自Primefaces的标签 '.
我读了这些问题:1/2,但我确实有 <h:head>.
我错过了什么?
我的页面(index.xhtml):
<h:html xmlns="http://www.w3.org/1999/xhtml"
xmlns:b="http://bootsfaces.net/ui"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<h:outputStylesheet library="css" name="style.css" />
<h:outputScript library="js" name="script.js" />
</h:head>
<h:body>
<p:textEditor value="#{textEditorController.text}" height="300" style="margin-bottom:10px"/>
<p:commandButton value="Submit" action="#{textEditorController.submit}"/>
</h:body>
</h:html>
Run Code Online (Sandbox Code Playgroud)
我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>MusiglabelWEB</display-name>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
</web-app>
Run Code Online (Sandbox Code Playgroud)
如果重要的话,我会使用多个项目(WEB,JPA,EJB,EAR).
WEB项目中包含的库:
这是PrimeFaces中的一个错误,我在这里注册了它.当ap:textEditor是最终视图中的第一个PrimeFaces组件时,它会显示出来.
要解决这个bug,只需在它之前添加一些其他组件,你可以使它不被渲染,所以它不会影响你的页面:
<p:inputText rendered="false" />
<p:textEditor />
Run Code Online (Sandbox Code Playgroud)