我试图使primefaces元素出现在我的页面上通过从展示中获取代码,菜单经过一些修改后工作良好,但选择菜单拒绝出现。
布局单元中没有显示任何东西。这是我的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:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Consultation Travaux Soumis (Etudiant)</title>
<style type="text/css">
.ui-widget,.ui-widget .ui-widget {
font-size: 90% !important;
}
</style>
</h:head>
<body>
<p:layout fullPage="true">
<p:layoutUnit position="north" size="158" header="Intranet" resizable="false" closable="false" collapsible="false">
<h:graphicImage value="/img/Logo.jpg" width="110" height="110"/>
<h:outputText value=" Consultation de la liste de travaux" />
</p:layoutUnit>
<p:layoutUnit position="west" size="200" header="Menu" resizable="true" closable="true" collapsible="true">
<h:form id="pmenu">
<p:menu style="width:90%">
<p:submenu label="Navigation">
<p:menuitem value="Acceuil" action="#" immediate="true" icon="ui-icon ui-icon-home"/>
<p:menuitem value="Deconnexion" action="#{PagesController.logout}" immediate="true" icon="ui-icon ui-icon-locked"/>
</p:submenu>
<p:submenu label="Services">
<p:menuitem value="Emploi du Temps" actionListener="#" immediate="true" ajax="false" icon="ui-icon ui-icon-suitcase" disabled="true"/>
<p:menuitem value="Relevé de Notes" actionListener="#" immediate="true" ajax="false" icon="ui-icon ui-icon-folder-collapsed" disabled="true"/>
<p:menuitem value="Remise de Doc." url="/secure/remisetrEt.xhtml" immediate="true" ajax="false" icon="ui-icon ui-icon-folder-open" />
</p:submenu>
<p:submenu label="Infos">
<p:menuitem value="Réclamation" actionListener="#" immediate="true" ajax="false" icon="ui-icon ui-icon-alert" />
<p:menuitem value="A Propos" actionListener="#" immediate="true" ajax="false" icon="ui-icon ui-icon-info" />
</p:submenu>
</p:menu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form>
<h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5">
<p:selectOneMenu>
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Option 1" itemValue="1" />
<f:selectItem itemLabel="Option 2" itemValue="2" />
<f:selectItem itemLabel="Option 3" itemValue="3" />
</p:selectOneMenu>
</h:panelGrid>
</h:form>
</p:layoutUnit>
</p:layout>
</body>
</html>
你的代码工作了。你使用的是哪个版本的初始面?您要部署到哪个应用服务器?你用哪个浏览器测试过?除了选择菜单,这页上还有别的吗?
尝试以下操作。在Glassfish上使用Primefaces 3.
<?xml version='1.0' encoding='UTF-8' ?>
<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:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
<title>Test</title>
<link type="text/css" rel="stylesheet"
href="#{request.contextPath}/css/default.css" />
<link type="text/css" rel="stylesheet"
href="#{request.contextPath}/css/custom.css" />
</f:facet>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5">
<p:selectOneMenu>
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Option 1" itemValue="1" />
<f:selectItem itemLabel="Option 2" itemValue="2" />
<f:selectItem itemLabel="Option 3" itemValue="3" />
</p:selectOneMenu>
</h:panelGrid>
</h:form>
</h:body>
</f:view>
</html>
问题是我必须将我的selectonemenu
绑定到我拥有的托管bean的属性。