primefaces教程_Primefaces面板,PanelGrid和PanelMenu示例教程

primefaces教程

Welcome to Primefaces Panel and PanelGrid example tutorial. We will also look into PanelMenu that provides a way of organizing submenus and menuitems in a hierarchical form mixed with accordionPanel behavior.

欢迎使用Primefaces Panel和PanelGrid示例教程。 我们还将研究PanelMenu,它提供了一种以分层的形式组织子菜单和菜单项的方法,并混合了AccordionPanel行为。

Primefaces面板 (Primefaces Panel)

Primefaces Panel is a grouping component with content toggle, close and menu integration.

Primefaces Panel是具有内容切换,关闭和菜单集成的分组组件。

TagPanel
Component Classorg.primefaces.component.panel.Panel
Component Typeorg.primefaces.component.Panel
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.PanelRenderer
Renderer Classorg.primefaces.component.panel.PanelRenderer
标签 面板
组件类别 org.primefaces.component.panel.Panel
组件类型 org.primefaces.component.Panel
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.PanelRenderer
渲染器类 org.primefaces.component.panel.PanelRenderer

Primefaces面板属性 (Primefaces Panel Attributes)

NameDefaultTypeDescription
idnullStringUnique identifier of the component
renderedtrueBooleanBoolean value to specify the rendering of the component, when set to false component will not be rendered.
bindingnullObjectAn el expression that maps to a server side UIComponent instance in a backing bean
headernullStringHeader text
footernullStringFooter text
toggleablefalseBooleanMakes panel toggleable.
toggleSpeed1000IntegerSpeed of toggling in milliseconds
collapsedfalseBooleanRenders a toggleable panel as collapsed.
stylenullStringStyle of the panel
styleClassnullStringStyle class of the panel
closablefalseBooleanMake panel closable.
closeSpeed1000IntegerSpeed of closing effect in milliseconds
visibletrueBooleanRenders panel as visible.
closeTitlenullStringTooltip for the close button.
toggleTitlenullStringTooltip for the toggle button.
menuTitlenullStringTooltip for the menu button.
toggleOrientationverticalStringDefines the orientation of the toggling, valid values are vertical and horizontal.
widgetVarnullStringName of the client side widget
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
标头 空值 标题文本
页脚 空值 页脚文字
可切换 布尔型 使面板可切换。
toggleSpeed 1000 整数 切换速度(以毫秒为单位)
崩溃了 布尔型 呈现可折叠面板。
样式 空值 面板样式
styleClass 空值 面板样式类
可关闭 布尔型 使面板可关闭。
closeSpeed 1000 整数 闭合效果的速度(以毫秒为单位)
可见 真正 布尔型 渲染面板可见。
closeTitle 空值 关闭按钮的工具提示。
toggleTitle 空值 切换按钮的工具提示。
menuTitle 空值 菜单按钮的工具提示。
toggleOrientation 垂直 定义切换的方向,有效值为垂直和水平。
widgetVar 空值 客户端小部件的名称

Primefaces面板示例 (Primefaces Panel Example)

Typically, Panel used for encapsulating other components.

通常,面板用于封装其他组件。

panel.xhtml

panel.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panel>
			<p:outputLabel value="Name of tutorial you're looking for:"></p:outputLabel>
			<p:inputText value="#{panelManagedBean.tutorial}"></p:inputText>
			<p:commandButton value="Search" action="#{panelManagedBean.search}" update="result"></p:commandButton>
			<p:dataTable value="#{panelManagedBean.tutorials}" var="tutorial" id="result">
				<p:column>
					<f:facet name="header">
						<p:outputLabel value="Tutorial Name"></p:outputLabel>
					</f:facet>
					<p:outputLabel value="#{tutorial}"></p:outputLabel>
				</p:column>
			</p:dataTable>
		</p:panel>
	</h:form>
</html>

PanelManagedBean.java

PanelManagedBean.java

package com.journaldev.prime.faces.beans;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class PanelManagedBean {
	private String tutorial;
	private List<String> tutorials = new ArrayList<String>();

	public String getTutorial() {
		return tutorial;
	}

	public void setTutorial(String tutorial) {
		this.tutorial = tutorial;
	}
	
	public List<String> getTutorials() {
		return tutorials;
	}

	public void setTutorials(List<String> tutorials) {
		this.tutorials = tutorials;
	}

	public String search(){
		for(int i = 1 ; i < 11; i++){
			this.tutorials.add(this.tutorial+" Tutorial "+i);
		}
		return "";
	}
}

Primefaces面板–页眉和页脚 (Primefaces Panel – Header & Footer)

Primefaces provides you capability of specifying of Header and Footer by adding two facet components; one for header and the other for footer.

Primefaces通过添加两个构面组件为您提供指定页眉页脚的功能; 一个用于页眉,另一个用于页脚。

panel.xhtml

panel.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panel>
			<f:facet name="header">
				<p:outputLabel value="Tutorials Provided"></p:outputLabel>
			</f:facet>
			<p:outputLabel value="Name of tutorial you're looking for:"></p:outputLabel>
			<p:inputText value="#{panelManagedBean.tutorial}"></p:inputText>
			<p:commandButton value="Search" action="#{panelManagedBean.search}" update="result"></p:commandButton>
			<p:dataTable value="#{panelManagedBean.tutorials}" var="tutorial" id="result">
				<p:column>
					<f:facet name="header">
						<p:outputLabel value="Tutorial Name"></p:outputLabel>
					</f:facet>
					<p:outputLabel value="#{tutorial}"></p:outputLabel>
				</p:column>
				<f:facet name="footer">
					<p:outputLabel value="Provided By Jouranldev.com"></p:outputLabel>
				</f:facet>
			</p:dataTable>
		</p:panel>
	</h:form>
</html>

Primefaces面板– Ajax行为事件 (Primefaces Panel – Ajax Behavior Events)

Primefaces provides you custom ajax behavior events that can be listened against Panel component. Toggling and closing are the only ajax events that might be fired and listened as well. By setting toggleable and closeable attribute to true, you are mostly ready for listening these events. One remaining step is by providing p:ajax for determining the methods that are responsible for handling these events.

Primefaces为您提供可针对Panel组件进行监听的自定义Ajax行为事件。 切换和关闭是可能也会触发和监听的唯一ajax事件。 通过将toggleablecloseable属性设置为true,您就可以开始侦听这些事件了。 剩下的一步是通过提供p:ajax来确定负责处理这些事件的方法。

panel.xhtml

panel.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panel id="Panel1" toggleable="true" closable="true">	
			<p:ajax event="toggle" listener="#{panelManagedBean.toggleHandle}"></p:ajax>
			<p:ajax event="close" listener="#{panelManagedBean.closeHandle}"></p:ajax>	
			<f:facet name="header">
				<p:outputLabel value="Tutorials Provided"></p:outputLabel>
			</f:facet>
			<p:outputLabel value="Name of tutorial you're looking for:"></p:outputLabel>
			<p:inputText value="#{panelManagedBean.tutorial}"></p:inputText>
			<p:commandButton value="Search" action="#{panelManagedBean.search}" update="result"></p:commandButton>
			<p:dataTable value="#{panelManagedBean.tutorials}" var="tutorial" id="result">
				<p:column>
					<f:facet name="header">
						<p:outputLabel value="Tutorial Name"></p:outputLabel>
					</f:facet>
					<p:outputLabel value="#{tutorial}"></p:outputLabel>
				</p:column>
				<f:facet name="footer">
					<p:outputLabel value="Provided By Jouranldev.com"></p:outputLabel>
				</f:facet>
			</p:dataTable>
		</p:panel>	
	</h:form>
</html>

PanelManagedBaen.java

PanelManagedBaen.java

package com.journaldev.prime.faces.beans;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.primefaces.event.CloseEvent;
import org.primefaces.event.ToggleEvent;

@ManagedBean
@SessionScoped
public class PanelManagedBean {
	private String tutorial;
	private List<String> tutorials = new ArrayList<String>();

	public String getTutorial() {
		return tutorial;
	}

	public void setTutorial(String tutorial) {
		this.tutorial = tutorial;
	}
	
	public List<String> getTutorials() {
		return tutorials;
	}

	public void setTutorials(List<String> tutorials) {
		this.tutorials = tutorials;
	}

	public String search(){
		for(int i = 1 ; i < 11; i++){
			this.tutorials.add(this.tutorial+" Tutorial "+i);
		}
		return "";
	}
	
	public void toggleHandle(ToggleEvent event){
		System.out.println("Panel #"+event.getComponent().getId()+" Is Toggled");
	}
	
	public void closeHandle(CloseEvent event){
		System.out.println("Panel #"+event.getComponent().getId()+" Is Closed");
	}
}

Primefaces面板–弹出菜单 (Primefaces Panel – Popup Menu)

Panel has built-in support to display a fully customizable popup menu. For make use Panel component as a popup menu, you should define facet options which contained your defined menu.

Panel具有内置支持以显示完全可自定义的弹出菜单。 为了使Panel组件用作弹出菜单,您应该定义包含定义菜单的构面选项

panel-PopupMenu.xhtml

panel-PopupMenu.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panel id="Panel1" closable="true" toggleable="true">	
			<f:facet name="options">
				<p:menu>
					<p:menuitem value="Primefaces Tutorials"></p:menuitem>
					<p:menuitem value="Hibernate Tutorials"></p:menuitem>
					<p:menuitem value="JPA Tutorials"></p:menuitem>
				</p:menu>
			</f:facet>
			<p:ajax event="toggle" listener="#{panelManagedBean.toggleHandle}"></p:ajax>
			<p:ajax event="close" listener="#{panelManagedBean.closeHandle}"></p:ajax>	
			<f:facet name="header">
				<p:outputLabel value="Tutorials Provided"></p:outputLabel>
			</f:facet>
			<p:outputLabel value="Name of tutorial you're looking for:"></p:outputLabel>
			<p:inputText value="#{panelManagedBean.tutorial}"></p:inputText>
			<p:commandButton value="Search" action="#{panelManagedBean.search}" update="result"></p:commandButton>
			<p:dataTable value="#{panelManagedBean.tutorials}" var="tutorial" id="result">
				<p:column>
					<f:facet name="header">
						<p:outputLabel value="Tutorial Name"></p:outputLabel>
					</f:facet>
					<p:outputLabel value="#{tutorial}"></p:outputLabel>
				</p:column>
				<f:facet name="footer">
					<p:outputLabel value="Provided By Jouranldev.com"></p:outputLabel>
				</f:facet>
			</p:dataTable>			
		</p:panel>	
	</h:form>
</html>

Primefaces面板–自定义操作 (Primefaces Panel – Custom Actions)

It’s also permitted to add custom actions into your panel titlebar by using facet actions.

还可以通过使用facet操作将自定义操作添加到面板标题栏中

panel-CustomActions.xhtml

panel-CustomActions.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panel id="Panel1" closable="true" toggleable="true">	
			<f:facet name="actions">
				<p:commandButton value="Search Using Tutorial's Author"></p:commandButton>
				<p:commandButton value="Search Using Tutorial's Name"></p:commandButton>
				<p:commandButton value="Search Using Tutorial's Category"></p:commandButton>
			</f:facet>
			<p:ajax event="toggle" listener="#{panelManagedBean.toggleHandle}"></p:ajax>
			<p:ajax event="close" listener="#{panelManagedBean.closeHandle}"></p:ajax>	
			<f:facet name="header">
				<p:outputLabel value="Tutorials Provided"></p:outputLabel>
			</f:facet>
			<p:outputLabel value="Name of tutorial you're looking for:"></p:outputLabel>
			<p:inputText value="#{panelManagedBean.tutorial}"></p:inputText>
			<p:commandButton value="Search" action="#{panelManagedBean.search}" update="result"></p:commandButton>
			<p:dataTable value="#{panelManagedBean.tutorials}" var="tutorial" id="result">
				<p:column>
					<f:facet name="header">
						<p:outputLabel value="Tutorial Name"></p:outputLabel>
					</f:facet>
					<p:outputLabel value="#{tutorial}"></p:outputLabel>
				</p:column>
				<f:facet name="footer">
					<p:outputLabel value="Provided By Jouranldev.com"></p:outputLabel>
				</f:facet>
			</p:dataTable>			
		</p:panel>	
	</h:form>
</html>

Primefaces PanelGrid (Primefaces PanelGrid)

PanelGrid is an extension to the standard panelGrid component with additional features such as theming and colspan-rowspan.

PanelGrid是对标准panelGrid组件的扩展,具有附加功能,例如主题化和colspan-rowspan。

TagPanelGrid
Component Classorg.primefaces.component.panelgrid.PanelGridRenderer
Component Typeorg.primefaces.component.PanelGrid
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.PanelGridRenderer
Renderer Classorg.primefaces.component.panelgrid.PanelGridRenderer
标签 面板网格
组件类别 org.primefaces.component.panelgrid.PanelGridRenderer
组件类型 org.primefaces.component.PanelGrid
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.PanelGridRenderer
渲染器类 org.primefaces.component.panelgrid.PanelGridRenderer

Primefaces PanelGrid属性 (Primefaces PanelGrid Attributes)

NameDefaultTypeDescription
idnullStringUnique identifier of the component
renderedtrueBooleanBoolean value to specify the rendering of the component, when set to false component will not be rendered.
bindingnullObjectAn el expression that maps to a server side UIComponent instance in a backing bean
columnsfalseIntegerNumber of columns in grid.
stylenullStringInline style of the panel.
styleClassnullStringStyle class of the panel.
columnClassesnullStringComma separated list of column style classes.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
整数 网格中的列数。
样式 空值 面板的内联样式。
styleClass 空值 面板的样式类。
columnClasses 空值 逗号分隔的列样式类列表。

Primefaces PanelGrid示例 (Primefaces PanelGrid Example)

PanelGrid component is used mainly for laying out form’s components into rows and columns. Typically, you specify columns attribute to determine the number of columns your panelGrid component has. However, no need to specify the number of rows, every defined component has occupied one column and once the number of columns has reached a new row will be added.

PanelGrid组件主要用于将表单的组件布置成行和列。 通常,您可以指定columns属性来确定panelGrid组件具有的列数。 但是,无需指定行数,每个定义的组件都占用一列,并且一旦达到列数,便会添加新行。

panelGrid.xhtml

panelGrid.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panelGrid columns="2">
			<p:outputLabel value="Component"></p:outputLabel>
			<p:outputLabel value="Component"></p:outputLabel>
			<p:outputLabel value="Component"></p:outputLabel>
		</p:panelGrid>	
	</h:form>
</html>

Just to clarify, your PanelGrid has defined three components inside, with number of columns equal for 2. The first and second components will occupy first and second columns respectively. A new row will be added into your PanelGrid for holding last defined component and for sure it will be located at the long of the first column. You can make use of different PanelGrid inside each other, every single PanelGrid will occupy one column as well.

需要澄清的是,PanelGrid在内部定义了三个组件,列数等于2。第一个和第二个组件将分别占据第一和第二列。 新行将添加到PanelGrid中,以保存最后定义的组件,并确保它位于第一列的长处。 您可以在彼此之间使用不同的PanelGrid,每一个PanelGrid也将占据一列。

panelGrid.xhtml

panelGrid.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panelGrid columns="2">
			<p:panelGrid columns="2">
				<p:outputLabel value="Component"></p:outputLabel>
				<p:outputLabel value="Component"></p:outputLabel>
			</p:panelGrid>
			<p:outputLabel value="Component"></p:outputLabel>
		</p:panelGrid>	
	</h:form>
</html>

All of your components are located at a single row, for sure that’s happened because of using inner PanelGrid which has located at the first column.

您的所有组件都位于单行中,确保确实发生了这种情况,这是因为使用了位于第一列的内部PanelGrid。

Primefaces PanelGrid –页眉和页脚 (Primefaces PanelGrid – Header And Footer)

PanelGrid provides facets for Header and Footer as Panel component does well.

由于Panel组件表现出色,PanelGrid为页眉和页脚提供了方面。

panelGrid.xhtml

panelGrid.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panelGrid columns="2">
			<f:facet name="header">
				<p:outputLabel value="Header"></p:outputLabel>
			</f:facet>
			<p:panelGrid columns="2">
				<p:outputLabel value="Component"></p:outputLabel>
				<p:outputLabel value="Component"></p:outputLabel>
			</p:panelGrid>
			<p:outputLabel value="Component"></p:outputLabel>
			<f:facet name="footer">
				<p:outputLabel value="Footer"></p:outputLabel>
			</f:facet>			
		</p:panelGrid>	
	</h:form>
</html>

Primefaces PanelGrid – Rowspan和Colspan (Primefaces PanelGrid – Rowspan & Colspan)

PanelGrid supports rowspan and colspan as well, in this case row and column markup should be defined manually.

PanelGrid也支持rowpan和colspan,在这种情况下,应手动定义行和列标记。

panelGrid-Rowspan-Colspan.xhtml

panelGrid-Rowspan-Colspan.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
	<h:head>
		<title>Panel, PanelGrid, PanelMenu</title>
		<script name="jquery/jquery.js" library="primefaces"></script>
	</h:head>
	<h:form>
		<p:panelGrid>
			<p:row>
				<p:column>
					<p:outputLabel value="Enter Username:"></p:outputLabel>
				</p:column>
				<p:column>
					<p:inputText></p:inputText>
				</p:column>
			</p:row>
			<p:row>
				<p:column>
					<p:outputLabel value="Enter Password:"></p:outputLabel>
				</p:column>
				<p:column>
					<p:inputText></p:inputText>
				</p:column>			
			</p:row>
			<p:row>	
				<p:column>		
					<p:commandButton value="Login"></p:commandButton>
				</p:column>
				<p:column>
				</p:column>
			</p:row>
		</p:panelGrid>	
	</h:form>
</html>

Primefaces PanelMenu (Primefaces PanelMenu)

PanelMenu is hybrid component of accordionPanel and tree component.

PanelMenu是AccordionPanel和tree组件的混合组件。

TagPanelMenu
Component Classorg.primefaces.component.panelmenu.PanelMenu
Component Typeorg.primefaces.component.PanelMenu
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.PanelMenuRenderer
Renderer Classorg.primefaces.component.panelmenu.PanelMenuRenderer
标签 面板菜单
组件类别 org.primefaces.component.panelmenu.PanelMenu
组件类型 org.primefaces.component.PanelMenu
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.PanelMenuRenderer
渲染器类 org.primefaces.component.panelmenu.PanelMenuRenderer

Primefaces PanelMenu属性 (Primefaces PanelMenu Attributes)

NameDefaultTypeDescription
idnullStringUnique identifier of the component
renderedtrueBooleanBoolean value to specify the rendering of the component, when set to false component will not be rendered.
bindingnullObjectAn el expression that maps to a server side UIComponent instance in a backing bean
modelnullMenuModelMenuModel instance to build menu dynamically.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the component.
widgetVarnullStringName of the client side widget.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
模型 空值 菜单型号 MenuModel实例以动态构建菜单。
样式 空值 组件的内联样式。
styleClass 空值 组件的样式类。
widgetVar 空值 客户端小部件的名称。

Primefaces PanelMenu示例 (Primefaces PanelMenu Example)

PanelMenu consists of submenus and menuitems. First level of submenu are rendered as AccordionPanel and descendant submenus are rendered as tree nodes. Like in any other menu components had discussed before, menuitems can be used for achieving ajax, non-ajax and simple GET requests.

PanelMenu由子菜单和菜单项组成。 子菜单的第一级呈现为AccordionPanel ,子级子菜单呈现为树节点。 像之前讨论的任何其他菜单组件一样, 菜单项可用于实现ajax,非ajax和简单的GET请求。

panelMenu.xhtml

panelMenu.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<title>Panel, PanelGrid, PanelMenu</title>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form>
	<p:panelMenu style="width:200px">
		<p:submenu label="JournalDev Tutorials">
			<p:submenu label="Links" icon="ui-icon-extlink">
				<p:submenu label="Tutorials" icon="ui-icon-heart">
					<p:menuitem value="Primefaces Tutorials" url="https://www.journaldev.com/dev/primefaces" />
					<p:menuitem value="Java EE Tutorials" url="https://www.journaldev.com/dev/java/j2ee" />
				</p:submenu>
			</p:submenu>
			<p:menuitem value="Go To JournalDev" url="https://www.primefaces.org" />
		</p:submenu>
	</p:panelMenu>
	</h:form>
</html>

Primefaces Panel PanelGrip和PanelMenu摘要 (Primefaces Panel PanelGrip and PanelMenu Summary)

This tutorial provides you a detailed explanation for how can you use Panel, PanelGrid and PanelMenu for organizing and laying out your different components. Contribute us by commenting below and find given source code.

本教程为您提供了详细的说明,说明如何使用Panel,PanelGrid和PanelMenu来组织和布置不同的组件。 通过在下面评论来贡献我们,找到给定的源代码。

翻译自: https://www.journaldev.com/3917/primefaces-panel-panelgrid-panelmenu-example-tutorial

primefaces教程

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PrimeFaces主要标签学习。 1 PrimeFaces综述 3 1.1 安装 3 1.2 配置,JSF2.0环境下用PrimeFace2.x 4 1.3 Hello World入门示例 4 1.4 UI组件: 4 2 UI组件 5 2.1 布局 5 2.1.1 Layout 页面布局 5 2.1.2 Panel用于包含其它组件,提供象windows窗口式的外观。 8 2.1.3 TabView 分页式面板组件 8 2.1.4 OutputPanel 仅用于显示元素 9 2.1.5 Fieldset 9 2.1.6 Dashboard 仪表盘 10 2.1.7 Themeswitcher 主题切换器,动态切换主题 11 2.1.8 Separator空白分隔区域 11 2.1.9 Spacer行内加空格 11 2.2 菜单 11 2.2.1 Menu 11 2.2.2 Menubar 12 2.2.3 MenuButton 13 2.2.4 Toolbar 13 2.2.5 Stack :堆叠式菜单(竖向) 13 2.2.6 Dock :动画鱼眼式菜单(横向) 14 2.3 按钮: 15 2.3.1 Button 15 2.3.2 CommandButton 15 2.3.3 CommandLink 17 2.3.4 ContextMenu 17 2.3.5 HotKey 17 2.4 输入组件 18 2.4.1 文本输入 18 2.4.1.1 Editor 18 2.4.1.2 Password 19 2.4.1.3 Password Strength 19 2.4.1.4 inputMask 输入掩码,实现格式化输入。 19 2.4.1.5 InputText 20 2.4.1.6 InputTextarea 20 2.4.1.7 Watermark :文本输入内容提示 20 2.4.1.8 Keyboard 显示一个虚拟键盘,用以支持输入字符。 21 2.4.1.9 Inplace 替换文本 22 2.4.2 选择式输入 22 2.4.2.1 AutoComplete :自动补全 22 2.4.2.2 PickList 选择列表 25 2.4.2.3 Slider 滑动条 26 2.4.2.4 Spinner 27 2.4.3 其它格式数据的输入: 27 2.4.3.1 Spreadsheet电子表格 27 2.4.3.2 Calendar 各种格式的日期输入与显示 28 2.4.3.3 Schedule 日程计划输入组件 31 2.4.3.4 Captcha :变形字符验证 31 2.4.3.5 Color Picker 32 2.5 集合(复杂格式)数据的输出与显示: 33 2.5.1 BreadCrumb :层次化页面导航条 >…>….> 33 2.5.2 Accordion:一个容器组件,它用tab动态地显示折叠或展开过程。 34 2.5.3 Carousel:多用途,标签式、分布式显示 35 2.5.4 Galleria 图片陈列廊 36 2.5.5 LightBox :图片加亮显示 37 2.5.6 DataGrid 数据栅格 37 2.5.7 DataList 用列表的形式显示数据,每个栅格可显示多个数据项 39 2.5.8 DataTable数据表格 41 2.5.9 Tree 树形显示 46 2.5.10 TreeTable 树表 47 2.5.11 DragDrop 50 2.5.11.1 Draggable组件: 50 2.5.11.2 Droppable组件 51 2.5.12 Charts基于flash的图形生成与显示 52 2.6 数据导出: 54 2.6.1 Data Exporter 54 2.6.2 Printer 56 2.7 状态: 56 2.7.1 ProgressBar 56 2.7.2 NotificationBar 57 2.8 对话框: 58 2.8.1 ConfirmDialog 58 2.8.2 Dialog 58 2.9 图形图像多媒体: 59 2.9.1 ImageCompare :提供丰富的接口比较两副图像 59 2.9.2 Graphic Text 文本图象化显示 60 2.9.3 ImageCropper 60 2.9.4 ImageSwitch 61 2.9.5 Google Maps 地图 61 2.9.6 Dyna Image 63 2.9.7 Media 65 2.9.8 Star Rating 65 2.9.9 Wizard: 66 2.10 消息: 66 2.10.1 Growl Mac风格的消息显示 66 2.10.2 Message/Messages 67 2.10.3 Tooltip 67 2.11 文件处理: 67 2.11.1 FileUpload 上传文件 67 2.11.2 FileDownload 下载文件 69 2.11.3 IdleMonitor 屏幕凝滞 70 2.11.4 Terminal 70 2.12 辅助功能(辅助其它JSF组件,给它们添加新的功能和行为): 71 2.12.1 Ajax Engine 71 2.12.2 Ajax Poll轮询 72 2.12.3 Ajax远程调用p:remoteCommand 72 2.12.4 Ajax Status 显示ajax后台运行状态。 72 2.12.5 Focus 73 2.12.6 Effect: 73 2.12.7 Collector : 74 2.12.8 Resizable 给任何JSF组件添加可调整大小的行为。 74 2.12.9 RequestContext : 75 3 TouchFaces 76 3.1.1 移动UI工具 76 3.1.2 Ajax Push/Comet 77 3.1.3 几分钟实现聊天应用: 78 4 附录 79 4.1 全部UI组件列表 84 4.2 PrimeFaces常用属性集 85
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值