Я хочу разработать JSF-страницу с простыми лицами.У меня есть index.xhtml, который содержит компонент композиции пользовательского интерфейса.На моей странице каждый компонент primefaces не загружает компоненты primefaces и файлы css.Если я загружаю свою страницу, я получаю сообщение об ошибке браузера:
Uncaught ReferenceError: PrimeFaces is not defined
at developer.xhtml:1
developer.xhtml:4 Uncaught ReferenceError: PrimeFaces is not defined
at developer.xhtml:4
developer.xhtml:4 Uncaught ReferenceError: PrimeFaces is not defined
at developer.xhtml:4
developer.xhtml:5 Uncaught ReferenceError: PrimeFaces is not defined
at developer.xhtml:5
developer.xhtml:5 Uncaught ReferenceError: PrimeFaces is not defined
at developer.xhtml:5
developer.xhtml:5 Uncaught ReferenceError: PrimeFaces is not defined
at developer.xhtml:5
developer.xhtml:9 Uncaught ReferenceError: $ is not defined
at developer.xhtml:9
В браузере отображается следующий источник:
<input id="j_idt2" name="j_idt2" type="text" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" /><script id="j_idt2_s" type="text/javascript">PrimeFaces.cw("InputText","widget_j_idt2",{id:"j_idt2"});</script>
<div class="boxing">
<div class="buttons"><button id="j_idt4" name="j_idt4" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" onclick="PrimeFaces.ab({s:"j_idt4"});return false;" type="submit"><span class="ui-button-icon-left ui-icon ui-c ui-icon-star"></span><span class="ui-button-text ui-c">speichern</span></button><script id="j_idt4_s" type="text/javascript">PrimeFaces.cw("CommandButton","widget_j_idt4",{id:"j_idt4"});</script><button id="j_idt5" name="j_idt5" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" onclick="PrimeFaces.ab({s:"j_idt5"});return false;" type="submit"><span class="ui-button-icon-left ui-icon ui-c ui-icon-star"></span><span class="ui-button-text ui-c">löschen</span></button><script id="j_idt5_s" type="text/javascript">PrimeFaces.cw("CommandButton","widget_j_idt5",{id:"j_idt5"});</script>
</div><table id="j_idt7" class="ui-panelgrid ui-widget developeredit" role="grid"><tbody><tr class="ui-widget-content" role="row"><td role="gridcell" class="ui-panelgrid-cell">name</td><td role="gridcell" class="ui-panelgrid-cell"><input id="j_idt9" name="j_idt9" type="text" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all developerinput" /><script id="j_idt9_s" type="text/javascript">PrimeFaces.cw("InputText","widget_j_idt9",{id:"j_idt9"});</script></td></tr><tr class="ui-widget-content" role="row"><td role="gridcell" class="ui-panelgrid-cell">webseite</td><td role="gridcell" class="ui-panelgrid-cell"><input id="j_idt11" name="j_idt11" type="text" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all developerinput" /><script id="j_idt11_s" type="text/javascript">PrimeFaces.cw("InputText","widget_j_idt11",{id:"j_idt11"});</script></td></tr><tr class="ui-widget-content" role="row"><td role="gridcell" class="ui-panelgrid-cell">Gründungsjahr</td><td role="gridcell" class="ui-panelgrid-cell"><input id="j_idt13" name="j_idt13" type="text" value="0.0" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all developerinput" /><script id="j_idt13_s" type="text/javascript">PrimeFaces.cw("InputText","widget_j_idt13",{id:"j_idt13"});</script></td></tr></tbody></table>
</div>
<div class="boxing2"><div id="j_idt15" class="ui-datatable ui-widget ui-datatable-scrollable developerchoose"><div class="ui-datatable-header ui-widget-header ui-corner-top">
Developer
</div><div class="ui-widget-header ui-datatable-scrollable-header"><div class="ui-datatable-scrollable-header-box"><table role="grid"><thead id="j_idt15_head"><tr role="row"><th id="j_idt15:j_idt19" class="ui-state-default" role="columnheader" aria-label="name"><span class="ui-column-title">name</span></th></tr></thead></table></div></div><div class="ui-datatable-scrollable-body" tabindex="-1"><table role="grid"><tbody id="j_idt15_data" class="ui-datatable-data ui-widget-content" tabindex="0"><tr class="ui-widget-content ui-datatable-empty-message"><td colspan="1">No records found.</td></tr></tbody></table></div><div class="ui-widget-header ui-datatable-scrollable-footer"><div class="ui-datatable-scrollable-footer-box"><table role="grid"></table></div></div><input type="hidden" id="j_idt15_selection" name="j_idt15_selection" autocomplete="off" value="0" /><input type="hidden" id="j_idt15_scrollState" name="j_idt15_scrollState" autocomplete="off" value="0,0" /></div><script id="j_idt15_s" type="text/javascript">$(function(){PrimeFaces.cw("DataTable","widget_j_idt15",{id:"j_idt15",selectionMode:"single",scrollable:true,liveScroll:false,scrollStep:0,scrollLimit:0,liveScrollBuffer:0,behaviors:{rowUnselect:function(ext,event) {PrimeFaces.ab({s:"j_idt15",e:"rowUnselect",p:"j_idt15"},ext);},rowSelect:function(ext,event) {PrimeFaces.ab({s:"j_idt15",e:"rowSelect",p:"j_idt15"},ext);}}});});</script>
</div>
Мой код выглядит так:
index.xhtml:
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<h:outputStylesheet name="css/index.css"></h:outputStylesheet>
<h:outputStylesheet name="css/developer.css"></h:outputStylesheet>
</h:head>
<h:body>
<h:form id = "overview">
<p:growl id="msgs" showDetail="true" />
<div id="page">
<div id="seperator">
Launchrada
</div>
<div class="ordner" id="menubox">
<p:menu id="menu" styleClass="box">
<p:submenu label="Ressources">
<p:menuitem value="Developer"></p:menuitem>
<p:menuitem value="Publisher"></p:menuitem>
<p:menuitem value="Plattform"></p:menuitem>
<p:menuitem value="Language"></p:menuitem>
<p:menuitem value="Genre"></p:menuitem>
</p:submenu>
<p:submenu label="Game">
<p:menuitem value="Game Creation"></p:menuitem>
<p:menuitem value="Game Editing"></p:menuitem>
</p:submenu>
</p:menu>
<div id="content" class="box">
<ui:include src = "/developer.xhtml" />
</div>
</div>
</div>
</h:form>
</h:body>
</html>
Файл композиции пользовательского интерфейса выглядит следующим образом:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<p:inputText rendered="false" />
<p:inputText />
<div class="boxing">
<div class="buttons">
<p:commandButton value="speichern" icon="ui-icon-star" actionListener="#{developerBean.save}">
</p:commandButton>
<p:commandButton value="löschen" icon="ui-icon-star" actionListener="#{developerBean.delete}">
</p:commandButton>
</div>
<p:panelGrid columns="2" styleClass="developeredit">
<h:outputText value="name"/>
<p:inputText styleClass="developerinput" value="#{developerBean.selectedDeveloper.name}"/>
<h:outputText value="webseite"/>
<p:inputText styleClass="developerinput" value="#{developerBean.selectedDeveloper.website}"/>
<h:outputText value="Gründungsjahr"/>
<p:inputText styleClass="developerinput" value="#{developerBean.selectedDeveloper.foundingdate}"/>
</p:panelGrid>
</div>
<div class="boxing2">
<p:dataTable styleClass="developerchoose" var="dev" value="#{developerBean.developerDTOList}"
selectionMode="single" rowKey="#{dev.id}" selection="#{developerBean.selectedDeveloper}"
scrollable="true">
<f:facet name="header">
Developer
</f:facet>
<p:ajax event="rowSelect" listener="#{developerBean.onRowSelect}"/>
<p:ajax event="rowUnselect" listener="#{developerBean.onRowUnselect}"/>
<p:column headerText="Id" rendered="false">
<h:outputText value="#{dev.id}"/>
</p:column>
<p:column headerText="name">
<h:outputText value="#{dev.name}"/>
</p:column>
</p:dataTable>
</div>
</ui:composition>