未定义 Primefaces - JavaScript 错误
Primefaces is not defined - JavaScript error
我正在为我的 Web 层使用 Primefaces 5.3 和 bootsfaces。我遇到的问题是我在使用组件 poll 的 facelet 中收到错误 "Primefaces is not defined",如下所示:
<b:row id="results">
<c:if test="${not empty twitterSearch.text or not empty twitterSearch.result }">
<b:panel title="Tweets for #{twitterSearch.text}" collapsible="false" look="info" col-md="6">
<h:form>
<p:poll interval="3" update="sentimentChart" />
<p:chart id="sentimentChart" type="pie" model="#{liveSentimentChartBean.liveCharts.get(twitterSearch.text)}" style="width:400px;height:300px"/>
</h:form>
</b:panel>
</c:if>
</b:row>
这个名为 analysis.xhtml 的 facelet 是 app_template.xhtml 模板的 facelet 客户端,因此它的根元素如下:
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui"
template="/WEB-INF/templates/app_template.xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
我知道这个问题通常是因为在 facelet 中缺少 h:head 标签,但是在模板中是这样定义的:
<?xml version='1.0' encoding='UTF-8' ?>
<!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://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:b="http://bootsfaces.net/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<h:head>
<meta charset="utf-8" />
<title>#{i18n['page.title']}</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="revisit-after" content="7 days" />
<meta name="DISTRIBUTION" content="GLOBAL" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
</h:head>
<h:body>
<c:set var="root" value="#{request.contextPath}/" />
<ui:insert name="navbar">
<ui:include src="/WEB-INF/content/navbar.xhtml"/>
</ui:insert>
<b:container>
<ui:insert name="content" />
</b:container>
<ui:insert name="footer">
<ui:remove>
<ui:include src="/WEB-INF/content/footer.xhtml"/>
</ui:remove>
</ui:insert>
</h:body>
</html>
有谁知道这个问题可能是由于?提前致谢:)
这是因为创建视图时必须有一些primefaces的组件。如果不满足就会有none,所以不包含库
例如,如果包含 p:inputText,则有效
我正在为我的 Web 层使用 Primefaces 5.3 和 bootsfaces。我遇到的问题是我在使用组件 poll 的 facelet 中收到错误 "Primefaces is not defined",如下所示:
<b:row id="results">
<c:if test="${not empty twitterSearch.text or not empty twitterSearch.result }">
<b:panel title="Tweets for #{twitterSearch.text}" collapsible="false" look="info" col-md="6">
<h:form>
<p:poll interval="3" update="sentimentChart" />
<p:chart id="sentimentChart" type="pie" model="#{liveSentimentChartBean.liveCharts.get(twitterSearch.text)}" style="width:400px;height:300px"/>
</h:form>
</b:panel>
</c:if>
</b:row>
这个名为 analysis.xhtml 的 facelet 是 app_template.xhtml 模板的 facelet 客户端,因此它的根元素如下:
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui"
template="/WEB-INF/templates/app_template.xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
我知道这个问题通常是因为在 facelet 中缺少 h:head 标签,但是在模板中是这样定义的:
<?xml version='1.0' encoding='UTF-8' ?>
<!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://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:b="http://bootsfaces.net/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<h:head>
<meta charset="utf-8" />
<title>#{i18n['page.title']}</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="revisit-after" content="7 days" />
<meta name="DISTRIBUTION" content="GLOBAL" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
</h:head>
<h:body>
<c:set var="root" value="#{request.contextPath}/" />
<ui:insert name="navbar">
<ui:include src="/WEB-INF/content/navbar.xhtml"/>
</ui:insert>
<b:container>
<ui:insert name="content" />
</b:container>
<ui:insert name="footer">
<ui:remove>
<ui:include src="/WEB-INF/content/footer.xhtml"/>
</ui:remove>
</ui:insert>
</h:body>
</html>
有谁知道这个问题可能是由于?提前致谢:)
这是因为创建视图时必须有一些primefaces的组件。如果不满足就会有none,所以不包含库
例如,如果包含 p:inputText,则有效