primefaces_Primefaces单选按钮,复选框示例

本文介绍了Primefaces的多种选择组件,包括SelectBooleanButton、SelectBooleanCheckbox、SelectCheckboxMenu等,提供了详细的属性、入门示例和客户端API。这些组件适用于实现不同的单选和复选功能,支持自定义内容和过滤操作。
摘要由CSDN通过智能技术生成

primefaces

Primefaces Radio Button and checkbox are select elements. Below are the primefaces components for different kinds of radio button and checkbox implementations.

Primefaces单选按钮和复选框是选择元素。 以下是用于不同类型的单选按钮和复选框实现的primefaces组件。

  1. SelectBooleanButton

    选择布尔按钮
  2. SelectBooleanCheckbox

    SelectBoolean复选框
  3. SelectCheckboxMenu

    选择复选框菜单
  4. SelectManyButton

    SelectManyButton
  5. SelectManyCheckbox

    SelectMany复选框
  6. SelectManyMenu

    全选菜单
  7. SelectOneButton

    选择一个按钮
  8. SelectOneListbox

    SelectOneListbox
  9. SelectOneMenu

    选择一个菜单
  10. SelectOneRadio

    SelectOneRadio

Let’s explore these components thoroughly and see how can we leverage them into your application.

让我们深入研究这些组件,看看如何将它们用于您的应用程序中。

SelectBooleanButton基本信息 (SelectBooleanButton Basic Info)

SelectBooleanButton is used to select a binary decision with a toggle button.

SelectBooleanButton用于通过切换按钮选择二进制决策。

TagSelectBooleanButton
Component Classorg.primefaces.component.selectbooleanbutton.SelectBooleanButton
Component Typeorg.primefaces.component.SelectBooleanButton
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectBooleanButtonRenderer
Renderer Classorg.primefaces.component.selectbooleanbutton.SelectBooleanButtonRenderer
标签 选择布尔按钮
组件类别 org.primefaces.component.selectbooleanbutton.SelectBooleanButton
组件类型 org.primefaces.component.SelectBooleanButton
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectBooleanButtonRenderer
渲染器类 org.primefaces.component.selectbooleanbutton.SelectBooleanButtonRenderer

SelectBooleanButton属性 (SelectBooleanButton 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
valuenullObjectValue of the component referring to a List.
converternullConverter/ StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethod ExprA method expression that refers to a method validationg the input
valueChangeListenernullMethod ExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringCallback to execute on value change.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
onLabelnullStringLabel to display when button is selected.
offLabelnullStringLabel to display when button is unselected.
onIconnullStringIcon to display when button is selected.
offIconnullStringIcon to display when button is unselected.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法展开 引用方法验证输入的方法表达式
valueChangeListener 空值 方法展开 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 回调以执行值更改。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
onLabel 空值 选择按钮时显示的标签。
关闭标签 空值 取消选择按钮时显示的标签。
onIcon 空值 选择按钮时显示的图标。
offIcon 空值 取消选择按钮时显示的图标。

SelectBooleanButton入门 (Getting Started With SelectBooleanButton)

selectBooleanButton.xhtml

selectBooleanButton.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:500px">
	<p:growl id="message"></p:growl>
	<p:outputLabel value="Turn your system:"></p:outputLabel>
		<p:selectBooleanButton offLabel="On" onLabel="Off" value="#{selectBooleanButton.status}" ></p:selectBooleanButton>
		<p:separator></p:separator>
	<p:commandButton value="Display System Status" action="#{selectBooleanButton.displaySystemStatus}" update="message"></p:commandButton>
</h:form>
</html>

SelectBooleanButton.java

SelectBooleanButton.java

package com.journaldev.prime.faces.beans;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class SelectBooleanButton {
	private boolean status;

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public String displaySystemStatus(){
		FacesContext.getCurrentInstance().addMessage(null,
				new FacesMessage("Your System Is: "+(status == true ? "Truned On":"Turned Off")));
		return "";
	}
}

SelectBooleanCheckbox基本信息 (SelectBooleanCheckbox Basic Info)

SelectBooleanCheckbox is an extended version of the standard checkbox with theme integration.

SelectBooleanCheckbox是具有主题集成功能的标准复选框的扩展版本。

TagSelectBooleanCheckbox
Component Classorg.primefaces.component.selectbooleancheckbox.SelectBooleanCheckbox
Component Typeorg.primefaces.component.SelectBooleanCheckbox
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectBooleanCheckboxRenderer
Renderer Classorg.primefaces.component.selectbooleancheckbox.SelectBooleanCheckbox Renderer
标签 SelectBoolean复选框
组件类别 org.primefaces.component.selectbooleancheckbox.SelectBooleanCheckbox
组件类型 org.primefaces.component.SelectBooleanCheckbox
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectBooleanCheckboxRenderer
渲染器类 org.primefaces.component.selectbooleancheckbox.SelectBooleanCheckbox渲染器

SelectBooleanCheckbox属性 (SelectBooleanCheckbox 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
valuenullObjectValue of the component referring to a List.
converternullConverter/ StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringCallback to execute on value change.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
itemLabelnullStringLabel displayed next to checkbox.
tabindexnullStringSpecifies tab order for tab key navigation.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 回调以执行值更改。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
itemLabel 空值 标签显示在复选框旁边。
标签索引 空值 指定选项卡键导航的选项卡顺序。

SelectBooleanCheckbox入门 (Getting Started With SelectBooleanCheckbox)

selectBooleanCheckbox.xhtml

selectBooleanCheckbox.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:500px">
	<p:growl id="message"></p:growl>
	<p:outputLabel value="Turn your system:"></p:outputLabel>
		<p:selectBooleanCheckbox value="#{selectBooleanCheckbox.status}" ></p:selectBooleanCheckbox>
		<p:separator></p:separator>
	<p:commandButton value="Display System Status" action="#{selectBooleanCheckbox.displaySystemStatus}" update="message"></p:commandButton>
</h:form>
</html>

SelectBooleanCheckbox.java

SelectBooleanCheckbox.java

package com.journaldev.prime.faces.beans;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class SelectBooleanCheckbox {
	private boolean status;

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public String displaySystemStatus(){
		FacesContext.getCurrentInstance().addMessage(null,
				new FacesMessage("Your System Is: "+(status == true ? "Truned On":"Turned Off")));
		return "";
	}
}

SelectBooleanCheckbox客户端API (SelectBooleanCheckbox Client Side API)

Widget: PrimeFaces.widget.SelectBooleanCheckbox

窗口小部件:PrimeFaces.widget.SelectBooleanCheckbox

MethodParamsReturn TypeDescription
check()voidChecks the checkbox.
uncheck()voidUnchecks the checkbox.
toggle()voidToggles check state.
方法 参数 返回类型 描述
check() 虚空 选中复选框。
uncheck() 虚空 取消选中该复选框。
toggle() 虚空 切换检查状态。
  • PF implicit object is used for controlling the component from the client side. The expression used is PF('WidgetVarValue')

    PF隐式对象用于从客户端控制组件。 使用的表达式是PF('WidgetVarValue')

SelectCheckboxMenu基本信息 (SelectCheckboxMenu Basic Info)

SelectCheckboxMenu is a multi select component that displays options in an overlay.

SelectCheckboxMenu是一个多选组件,可在覆盖图中显示选项。

TagSelectCheckboxMenu
Component Classorg.primefaces.component.selectcheckboxmenu.SelectCheckboxMenu
Component Typeorg.primefaces.component.SelectCheckboxMenu
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectCheckboxMenuRenderer
Renderer Classorg.primefaces.component.selectcheckboxmenu.SelectCheckboxMenuRenderer
标签 选择复选框菜单
组件类别 org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenu
组件类型 org.primefaces.component.SelectCheckboxMenu
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectCheckboxMenuRenderer
渲染器类 org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenuRenderer

SelectCheckboxMenu属性 (SelectCheckboxMenu 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
valuenullObjectValue of the component referring to a List.
converternullConverter/ StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringCallback to execute on value change.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
scrollHeightnullIntegerHeight of the overlay.
onShownullStringClient side callback to execute when overlay is displayed.
onHidenullStringClient side callback to execute when overlay is hidden.
filterfalseBooleanRenders an input field as a filter.
filterMatchModestartsWithStringMatch mode for filtering, valid values are startsWith, contains, endsWith and custom.
filterFunctionnullStringClient side function to use in custom filtering.
caseSensitivefalseBooleanDefines if filtering would be case sensitive.
panelStylenullStringInline style of the overlay.
panelStyleClassnullStringStyle class of the overlay.
appendTonullStringAppends the overlay to the element defined by search expression. Defaults to document body.
tabindexnullStringPosition of the element in the tabbing order.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 回调以执行值更改。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
scrollHeight 空值 整数 叠加层的高度。
展出 空值 显示覆盖时执行的客户端回调。
隐藏 空值 隐藏叠加层时执行的客户端回调。
过滤 布尔型 将输入字段呈现为过滤器。
filterMatchMode 以。。开始 用于过滤的匹配模式,有效值是startsWith,contains,endsWith和custom。
filterFunction 空值 在自定义过滤中使用的客户端功能。
区分大小写 布尔型 定义过滤是否区分大小写。
panelStyle 空值 叠加层的内联样式。
panelStyleClass 空值 叠加层的样式类。
appendTo 空值 将叠加层附加到搜索表达式定义的元素上。 默认为文档正文。
标签索引 空值 元素在跳位顺序中的位置。

SelectCheckboxMenu入门 (Getting started with SelectCheckboxMenu)

selectCheckboxMenu.xhtml

selectCheckboxMenu.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:outputLabel value="Select wanted tutorials:"></p:outputLabel>
		<p:selectCheckboxMenu value="#{selectCheckboxMenu.selectedTutorials}">
			<f:selectItems value="#{selectCheckboxMenu.tutorials}" var="tutorial" itemLabel="#{tutorial}" itemValue="#{tutorial}"></f:selectItems>
		</p:selectCheckboxMenu>
		<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectCheckboxMenu.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectCheckboxMenu.java

SelectCheckboxMenu.java

package com.journaldev.prime.faces.beans;

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

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class SelectCheckboxMenu {

	private List<String> tutorials = new ArrayList<String>();

	private List<String> selectedTutorials = new ArrayList<String>();

	public SelectCheckboxMenu(){

	}

	@PostConstruct
	public void init(){
		this.tutorials = new ArrayList<String>();
		this.tutorials.add("Primefaces");
		this.tutorials.add("Hibernate");
		this.tutorials.add("Spring");
	}

	public List<String> getTutorials() {
		return tutorials;
	}

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

	public List<String> getSelectedTutorials() {
		return selectedTutorials;
	}

	public void setSelectedTutorials(List<String> selectedTutorials) {
		this.selectedTutorials = selectedTutorials;
	}

	public String register(){
		String message = "";
		for(String s : this.selectedTutorials){
			message = message + s + ",";
		}
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You've Registered In:", message));
		return "";
	}
}

SelectCheckboxMenu过滤 (SelectCheckboxMenu Filtering)

It’s possible for you to make use some sort of filtering against your viewed list. This mechanism will help you got a fast reach into the desired wanted item easily. To make your component applicable to filter its result, just follow below steps:

您可以对查看列表进行某种过滤。 这种机制将帮助您轻松轻松地快速找到所需的物品。 要使您的组件适用于过滤其结果,只需执行以下步骤:

  • Make sure filter attribute is set to true.

    确保将filter属性设置为true。
  • Setting your filter mode; startsWith (by default), endsWith and custom.

    设置您的过滤模式; startsWith (默认情况下), endsWithcustom
  • In case you’ve set custom as a mode of your filter you must provide filterFunction attribute which normally associated with a JavaScript function.

    如果您已将custom设置为过滤器的模式,则必须提供通常与JavaScript函数关联的filterFunction属性。

selectCheckboxMenu.xhtml

selectCheckboxMenu.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:outputLabel value="Select wanted tutorials:"></p:outputLabel>
		<p:selectCheckboxMenu value="#{selectCheckboxMenu.selectedTutorials}" filter="true">
			<f:selectItems value="#{selectCheckboxMenu.tutorials}" var="tutorial" itemLabel="#{tutorial}" itemValue="#{tutorial}"></f:selectItems>
		</p:selectCheckboxMenu>
		<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectCheckboxMenu.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectCheckboxMenu Ajax行为事件 (SelectCheckboxMenu Ajax Behavior Events)

Most of Primefaces’ components have associated in with a lot of Ajax events. The way in which those events can be leveraged is discussed deeply at Ajax Behavior Tutorial where you can get back into. Here’s, a detailed list of Ajax events that you can use against SelectCheckboxMenu.

Primefaces的大多数组件都与许多Ajax事件相关联。 可以利用这些事件的方式在Ajax Behavior Tutorial中进行了深入讨论。 这是可用于SelectCheckboxMenu的Ajax事件的详细列表。

EventListener ParameterFired
toggleSelectorg.primefaces.event.ToggleSelectEventWhen toggle all checkbox changes
事件 侦听器参数 被解雇
toggleSelect org.primefaces.event.ToggleSelectEvent 切换所有复选框时

SelectManyButton基本信息 (SelectManyButton Basic Info)

SelectManyButton is a multi select component using button UI.

SelectManyButton是使用按钮UI的多选组件。

TagSelectManyButton
Component Classorg.primefaces.component.selectmanybutton.SelectManyButton
Component Typeorg.primefaces.component.SelectManyButton
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectManyButton
Renderer Classorg.primefaces.component.selectmanybutton.SelectManyButton
标签 SelectManyButton
组件类别 org.primefaces.component.selectmanybutton.SelectManyButton
组件类型 org.primefaces.component.SelectManyButton
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectManyButton
渲染器类 org.primefaces.component.selectmanybutton.SelectManyButton

SelectManyButton属性 (SelectManyButton 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
valuenullObjectValue of the component referring to a List.
converternullConverter/ StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringCallback to execute on value change.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 回调以执行值更改。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。

SelectManyButton入门 (Getting Started With SelectManyButton)

selectManyButton.xhtml

selectManyButton.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:selectManyButton value="#{selectManyButton.selectedTutorials}">
		<f:selectItems value="#{selectManyButton.tutorials}"></f:selectItems>
	</p:selectManyButton>
	<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectManyButton.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectManyButton.java

SelectManyButton.java

package com.journaldev.prime.faces.beans;

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

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

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

	private List<String> selectedTutorials = new ArrayList<String>();

	@PostConstruct
	public void init(){
		this.tutorials = new ArrayList<String>();
		this.tutorials.add("Primefaces");
		this.tutorials.add("Hibernate");
		this.tutorials.add("Spring");
	}

	public List<String> getTutorials() {
		return tutorials;
	}

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

	public List<String> getSelectedTutorials() {
		return selectedTutorials;
	}

	public void setSelectedTutorials(List<String> selectedTutorials) {
		this.selectedTutorials = selectedTutorials;
	}

	public String register(){
		String message = "";
		for(String s : this.selectedTutorials){
			message = message + s + ",";
		}
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You've Registered In:", message));
		return "";
	}
}

SelectManyCheckbox基本信息 (SelectManyCheckbox Basic Info)

SelectManyCheckbox is an extended version of the standard SelectManyCheckbox with theme integration.

SelectManyCheckbox是具有主题集成功能的标准SelectManyCheckbox的扩展版本。

TagSelectManyCheckbox
Component Classorg.primefaces.component.selectmanycheckbox.SelectManyCheckbox
Component Typeorg.primefaces.component.SelectManyCheckbox
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectManyCheckboxRenderer
Renderer Classorg.primefaces.component.selectmanycheckbox.SelectManyCheckboxRenderer
标签 SelectMany复选框
组件类别 org.primefaces.component.selectmanycheckbox.SelectManyCheckbox
组件类型 org.primefaces.component.SelectManyCheckbox
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectManyCheckboxRenderer
渲染器类 org.primefaces.component.selectmanycheckbox.SelectManyCheckboxRenderer

SelectManyChcekbox属性 (SelectManyChcekbox 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
valuenullObjectValue of the component referring to a List.
converternullConverter/St ringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
layoutlineDirectionStringLayout of the checkboxes, valid values are lineDirection, pageDirection and grid.
columns0IntegerNumber of columns in grid layout.
onchangenullStringCallback to execute on value change.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
转换器 空值 转换器/ St环 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
布局 lineDirection 复选框的布局,有效值为lineDirection,pageDirection和grid。
0 整数 网格布局中的列数。
不断变化 空值 回调以执行值更改。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。

SelectManyCheckbox入门 (Getting Started With SelectManyCheckbox)

selectManyCheckbox.xhtml

selectManyCheckbox.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:selectManyCheckbox value="#{selectManyCheckbox.selectedTutorials}">
		<f:selectItems value="#{selectManyCheckbox.tutorials}"></f:selectItems>
	</p:selectManyCheckbox>
	<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectManyCheckbox.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectManyCheckbox.java

SelectManyCheckbox.java

package com.journaldev.prime.faces.beans;

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

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class SelectManyCheckbox {

	private List<String> tutorials = new ArrayList<String>();

	private List<String> selectedTutorials = new ArrayList<String>();

	public SelectManyCheckbox(){

	}

	@PostConstruct
	public void init(){
		this.tutorials = new ArrayList<String>();
		this.tutorials.add("Primefaces");
		this.tutorials.add("Hibernate");
		this.tutorials.add("Spring");
	}

	public List<String> getTutorials() {
		return tutorials;
	}

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

	public List<String> getSelectedTutorials() {
		return selectedTutorials;
	}

	public void setSelectedTutorials(List<String> selectedTutorials) {
		this.selectedTutorials = selectedTutorials;
	}

	public String register(){
		String message = "";
		for(String s : this.selectedTutorials){
			message = message + s + ",";
		}
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You've Registered In:", message));
		return "";
	}
}

SelectManyMenu基本信息 (SelectManyMenu Basic Info)

SelectManyMenu is an extended version of the standard SelectManyMenu.

SelectManyMenu是标准SelectManyMenu的扩展版本。

TagSelectManyMenu
Component Classorg.primefaces.component.selectmanymenu.SelectManyMenu
Component Typeorg.primefaces.component.SelectManyMenu
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectManyMenuRenderer
Renderer Classorg.primefaces.component.selectmanymenu.SelectManyMenuRenderer
标签 全选菜单
组件类别 org.primefaces.component.selectmanymenu.SelectManyMenu
组件类型 org.primefaces.component.SelectManyMenu
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectManyMenuRenderer
渲染器类 org.primefaces.component.selectmanymenu.SelectManyMenuRenderer

SelectManyMenu属性 (SelectManyMenu 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
valuenullObjectValue of the component referring to a List.
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringCallback to execute on value change.
onclicknullStringCallback for click event.
ondblclicknullStringCallback for dblclick event.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
tabindexnullStringPosition of the input element in the tabbing order.
varnullStringName of iterator to be used in custom content display.
showCheckboxfalseBooleanWhen true, a checkbox is displayed next to each item.
filterfalseBooleanDisplays an input filter for the list.
filterMatchModenullStringMatch mode for filtering, valid values are startsWith (default), contains, endsWith and custom.
filterFunctionnullStringClient side function to use in custom filterMatchMode.
caseSensitivefalseBooleanDefines if filtering would be case sensitive.
scrollHeightnullIntegerDefines the height of the scrollable area
converternullConverter/StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s static text, it must refer to a converter id
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 回调以执行值更改。
点击 空值 点击事件的回调。
ondblclick 空值 dblclick事件的回调。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
标签索引 空值 输入元素在制表顺序中的位置。
变种 空值 自定义内容显示中使用的迭代器名称。
showCheckbox 布尔型 如果为true,则每个项目旁边都会显示一个复选框。
过滤 布尔型 显示列表的输入过滤器。
filterMatchMode 空值 用于过滤的匹配模式,有效值为startsWith(默认值),contains,endsWith和custom。
filterFunction 空值 在自定义filterMatchMode中使用的客户端功能。
区分大小写 布尔型 定义过滤是否区分大小写。
scrollHeight 空值 整数 定义可滚动区域的高度
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID

SelectManyMenu入门 (Getting Started With SelectManyMenu)

selectManyMenu.xhtml

selectManyMenu.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:selectManyMenu value="#{selectManyMenu.selectedTutorials}">
		<f:selectItems value="#{selectManyMenu.tutorials}"></f:selectItems>
	</p:selectManyMenu>
	<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectManyMenu.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectManyMenu.java

SelectManyMenu.java

package com.journaldev.prime.faces.beans;

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

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class SelectManyMenu {

	private List<String> tutorials = new ArrayList<String>();

	private List<String> selectedTutorials = new ArrayList<String>();

	public SelectManyMenu(){

	}

	@PostConstruct
	public void init(){
		this.tutorials = new ArrayList<String>();
		this.tutorials.add("Primefaces");
		this.tutorials.add("Hibernate");
		this.tutorials.add("Spring");
	}

	public List<String> getTutorials() {
		return tutorials;
	}

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

	public List<String> getSelectedTutorials() {
		return selectedTutorials;
	}

	public void setSelectedTutorials(List<String> selectedTutorials) {
		this.selectedTutorials = selectedTutorials;
	}

	public String register(){
		String message = "";
		for(String s : this.selectedTutorials){
			message = message + s + ",";
		}
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You've Registered In:", message));
		return "";
	}
}

SelectManyMenu –自定义内容 (SelectManyMenu – Custom Content)

It’s possible for you to write in your own custom content for every single item. By providing whatever you want of Primefaces/jsf components that enclosed within SelectManyMenu open/end Tags, you can provide your own custom content. Following below sample shows you the same used example with a different images.

您可以为每个项目编写自己的自定义内容。 通过提供包含在SelectManyMenu打开/结束标签内的Primefaces / jsf组件的所需内容,您可以提供自己的自定义内容。 下面的示例向您展示了相同的示例以及不同的图像。

selectManyMenu.xhtml

selectManyMenu.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:selectManyMenu value="#{selectManyMenu.selectedTutorials}" var="tutorial">
		<f:selectItems value="#{selectManyMenu.tutorials}"/>
		<p:column>
			<p:graphicImage value="/resources/images/#{tutorial}.jpg" width="40"></p:graphicImage>
		</p:column>
		<p:column>
			<p:outputLabel value="#{tutorial}"></p:outputLabel>
		</p:column>
	</p:selectManyMenu>
	<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectManyMenu.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectManyMenu –过滤 (SelectManyMenu – Filtering)

You can make use of filter functionality in SelectManyMenu same as the same usage by SelectCheckboxMenu.

您可以在SelectManyMenu中使用过滤器功能,与通过以下方式使用相同的功能: 选择复选框菜单。

SelectOneButton基本信息 (SelectOneButton Basic Info)

SelectOneButton is an input component to do a single select.

SelectOneButton是执行单个选择的输入组件。

TagSelectOneButton
Component Classorg.primefaces.component.selectonebutton.SelectOneButton
Component Typeorg.primefaces.component.SelectOneButton
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectOneButtonRenderer
Renderer Classorg.primefaces.component.selectonebutton.SelectOneButtonRenderer
标签 选择一个按钮
组件类别 org.primefaces.component.selectonebutton.SelectOneButton
组件类型 org.primefaces.component.SelectOneButton
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectOneButtonRenderer
渲染器类 org.primefaces.component.selectonebutton.SelectOneButtonRenderer

SelectOneButton属性 (SelectOneButton 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
valuenullObjectValue of the component referring to a List.
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringCallback to execute on value change.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
converternullConverter/St ringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 回调以执行值更改。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
转换器 空值 转换器/ St环 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID

SelectOneButton入门 (Getting Started With SelectOneButton)

selectOneButton.xhtml

selectOneButton.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:selectOneButton value="#{selectOneButton.selectedTutorial}">
		<f:selectItems value="#{selectOneButton.tutorials}"></f:selectItems>
	</p:selectOneButton>
	<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectOneButton.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectOneButton.java

SelectOneButton.java

package com.journaldev.prime.faces.beans;

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

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

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

	private String selectedTutorial = "";

	@PostConstruct
	public void init(){
		this.tutorials = new ArrayList<String>();
		this.tutorials.add("Primefaces");
		this.tutorials.add("Hibernate");
		this.tutorials.add("Spring");
	}

	public List<String> getTutorials() {
		return tutorials;
	}

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

	public String getSelectedTutorial() {
		return selectedTutorial;
	}

	public void setSelectedTutorial(String selectedTutorial) {
		this.selectedTutorial = selectedTutorial;
	}

	public String register(){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You've Registered In:", this.selectedTutorial));
		return "";
	}
}

SelectOneListbox基本信息 (SelectOneListbox Basic Info)

SelectOneListbox is an extended version of the standard selectOneListbox component.

SelectOneListbox是标准selectOneListbox组件的扩展版本。

TagSelectOneListbox
Component Classorg.primefaces.component.selectonelistbox.SelectOneListbox
Component Typeorg.primefaces.component.SelectOneListbox
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectOneListboxRenderer
Renderer Classorg.primefaces.component.selectonelistbox.SelectOneListBoxRenderer
标签 SelectOneListbox
组件类别 org.primefaces.component.selectonelistbox.SelectOneListbox
组件类型 org.primefaces.component.SelectOneListbox
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectOneListboxRenderer
渲染器类 org.primefaces.component.selectonelistbox.SelectOneListBoxRenderer

SelectOneListbox属性 (SelectOneListbox 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
valuenullObjectValue of the component referring to a List.
converternullConverter/ StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediatefalseBooleanWhen set true, process validations logic is executed at apply request values phase for this component.
requiredfalseBooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringCallback to execute on value change.
onclicknullStringCallback for click event.
ondblclicknullStringCallback for dblclick event.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
tabindexnullStringPosition of the input element in the tabbing order.
valuenullStringName of iterator to be used in custom content display.
varnullStringName of iterator to be used in custom content display.
filterfalseBooleanDisplays an input filter for the list.
filterMatchModenullStringMatch mode for filtering, valid values are startsWith (default), contains, endsWith and custom.
filterFunctionnullStringClient side function to use in custom filterMatchMode.
caseSensitivefalseBooleanDefines if filtering would be case sensitive.
scrollHeightnullIntegerDefines the height of the scrollable area.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 回调以执行值更改。
点击 空值 点击事件的回调。
ondblclick 空值 dblclick事件的回调。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
标签索引 空值 输入元素在制表顺序中的位置。
空值 自定义内容显示中使用的迭代器名称。
变种 空值 自定义内容显示中使用的迭代器名称。
过滤 布尔型 显示列表的输入过滤器。
filterMatchMode 空值 用于过滤的匹配模式,有效值为startsWith(默认值),contains,endsWith和custom。
filterFunction 空值 在自定义filterMatchMode中使用的客户端功能。
区分大小写 布尔型 定义过滤是否区分大小写。
scrollHeight 空值 整数 定义可滚动区域的高度。

SelectOneListbox入门 (Getting Started With SelectOneListbox)

selectOneListbox.xhtml

selectOneListbox.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:selectOneListbox value="#{selectOneListBox.selectedTutorial}">
		<f:selectItems value="#{selectOneListBox.tutorials}"></f:selectItems>
	</p:selectOneListbox>
	<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectOneListBox.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectOneListbox.java

SelectOneListbox.java

package com.journaldev.prime.faces.beans;

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

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

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

	private String selectedTutorial = "";

	@PostConstruct
	public void init(){
		this.tutorials = new ArrayList<String>();
		this.tutorials.add("Primefaces");
		this.tutorials.add("Hibernate");
		this.tutorials.add("Spring");
	}

	public List<String> getTutorials() {
		return tutorials;
	}

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

	public String getSelectedTutorial() {
		return selectedTutorial;
	}

	public void setSelectedTutorial(String selectedTutorial) {
		this.selectedTutorial = selectedTutorial;
	}

	public String register(){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You've Registered In:", this.selectedTutorial));
		return "";
	}
}

SelectOneMenu基本信息 (SelectOneMenu Basic Info)

SelectOneMenu is an extended version of the standard SelectOneMenu.

SelectOneMenu是标准SelectOneMenu的扩展版本。

TagSelectOneMenu
Component Classorg.primefaces.component.selectonemenu.SelectOneMenu
Component Typeorg.primefaces.component.SelectOneMenu
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectOneMenuRenderer
Renderer Classorg.primefaces.component.selectonemenu.SelectOneMenuRenderer
标签 选择一个菜单
组件类别 org.primefaces.component.selectonemenu.SelectOneMenu
组件类型 org.primefaces.component.SelectOneMenu
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectOneMenuRenderer
渲染器类 org.primefaces.component.selectonemenu.SelectOneMenuRenderer

SelectOneMenu属性 (SelectOneMenu 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
valuenullObjectValue of the component.
converternullConverter/ StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediate0BooleanWhen set true, process validations logic is executed at apply request values phase for this component.
required0BooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
effectblindStringName of the toggle animation.
effectSpeed400IntegerDuration of toggle animation in milliseconds.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
onchangenullStringClient side callback to execute on value change.
onkeyupnullStringClient side callback to execute on keyup.
onkeydownnullStringClient side callback to execute on keydown.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
varnullStringName of the item iterator.
heightautoIntegerHeight of the overlay.
tabindexnullStringTabindex of the input.
editablefalseBooleanWhen true, input becomes editable.
filterfalseBooleanRenders an input field as a filter.
filterMatchModestarts WithStringMatch mode for filtering, valid values are startsWith, contains, endsWith and custom.
filterFunctionnullStringClient side function to use in custom filtering.
caseSensitivefalseBooleanDefines if filtering would be case sensitive.
maxlengthnullIntegerNumber of maximum characters allowed in editable selectOneMenu.
appendTonullStringAppends the overlay to the element defined by search expression. Defaults to document body.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 组件的值。
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 0 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 0 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
影响 切换动画的名称。
effectSpeed 400 整数 切换动画的持续时间(以毫秒为单位)。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
不断变化 空值 客户端回调在值更改时执行。
按键 空值 客户端回调以对keyup执行。
按键 空值 客户端回调在keydown上执行。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
变种 空值 项目迭代器的名称。
高度 汽车 整数 叠加层的高度。
标签索引 空值 输入的Tabindex。
可编辑的 布尔型 为true时,输入变为可编辑。
过滤 布尔型 将输入字段呈现为过滤器。
filterMatchMode 以。。开始 用于过滤的匹配模式,有效值是startsWith,contains,endsWith和custom。
filterFunction 空值 在自定义过滤中使用的客户端功能。
区分大小写 布尔型 定义过滤是否区分大小写。
最长长度 空值 整数 可编辑的selectOneMenu中允许的最大字符数。
appendTo 空值 将叠加层附加到搜索表达式定义的元素上。 默认为文档正文。

SelectOneMenu入门 (Getting Started With SelectOneMenu)

selectOneMenu.xhtml

selectOneMenu.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>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form style="width:400px">
	<p:growl id="message" showDetail="true" showSummary="true"></p:growl>
	<p:selectOneMenu value="#{selectOneMenu.selectedTutorial}">
		<f:selectItems value="#{selectOneMenu.tutorials}"></f:selectItems>
	</p:selectOneMenu>
	<p:separator></p:separator>
	<p:commandButton value="Register" action="#{selectOneMenu.register}" update="message"></p:commandButton>
</h:form>
</html>

SelectOneMenu.java

SelectOneMenu.java

package com.journaldev.prime.faces.beans;

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

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

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

	private String selectedTutorial = "";

	@PostConstruct
	public void init(){
		this.tutorials = new ArrayList<String>();
		this.tutorials.add("Primefaces");
		this.tutorials.add("Hibernate");
		this.tutorials.add("Spring");
	}

	public List<String> getTutorials() {
		return tutorials;
	}

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

	public String getSelectedTutorial() {
		return selectedTutorial;
	}

	public void setSelectedTutorial(String selectedTutorial) {
		this.selectedTutorial = selectedTutorial;
	}

	public String register(){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You've Registered In:", this.selectedTutorial));
		return "";
	}
}

SelectOneRadio基本信息 (SelectOneRadio Basic Info)

TagSelectOneRadio
Component Classorg.primefaces.component.selectoneradio.SelectOneRadio
Component Typeorg.primefaces.component.SelectOneRadio
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.SelectOneRadioRenderer
Renderer Classorg.primefaces.component.selectoneradio.SelectOneRadioRenderer
标签 SelectOneRadio
组件类别 org.primefaces.component.selectoneradio.SelectOneRadio
组件类型 org.primefaces.component.SelectOneRadio
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.SelectOneRadioRenderer
渲染器类 org.primefaces.component.selectoneradio.SelectOneRadioRenderer

SelectOneRadio属性 (SelectOneRadio 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
valuenullObjectValue of the component referring to a List.
converternullConverter/ StringAn el expression or a literal text that defines a converter for the component. When it’s an EL expression, it’s resolved to a converter instance. In case it’s a static text, it must refer to a converter id
immediate0BooleanWhen set true, process validations logic is executed at apply request values phase for this component.
required0BooleanMarks component as required
validatornullMethodExprA method expression that refers to a method validationg the input
valueChangeListenernullMethodExprA method expression that refers to a method for handling a valuechangeevent
requiredMessagenullStringMessage to be displayed when required field validation fails.
converterMessagenullStringMessage to be displayed when conversion fails.
validatorMessagenullStringMessage to be displayed when validation fields.
widgetVarnullStringName of the client side widget.
disabledfalseBooleanDisables the component.
labelnullStringUser presentable name.
layoutline DirectionStringLayout of the radiobuttons, valid values are lineDirection, pageDirection, custom and grid.
columns0IntegerNumber of columns in grid layout.
onchangenullStringCallback to execute on value change.
stylenullStringInline style of the component.
styleClassnullStringStyle class of the container.
tabindexnullStringSpecifies the tab order of element in tab navigation.
plainfalseBooleanPlain mode displays radiobuttons using native browser rendering instead of themes.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
空值 目的 引用列表的组件的值。
转换器 空值 转换器/字符串 El表达式或文字文本,定义了组件的转换器。 当是EL表达式时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
即时 0 布尔型 设置为true时,将在此组件的应用请求值阶段执行流程验证逻辑。
需要 0 布尔型 根据需要标记组件
验证器 空值 方法专家 引用方法验证输入的方法表达式
valueChangeListener 空值 方法专家 方法表达式,该方法表达式引用用于处理valuechangeevent的方法
requiredMessage 空值 必填字段验证失败时显示的消息。
converterMessage 空值 转换失败时显示的消息。
验证器消息 空值 验证字段时显示的消息。
widgetVar 空值 客户端小部件的名称。
残障人士 布尔型 禁用组件。
标签 空值 用户可显示的名称。
布局 线方向 单选按钮的布局,有效值为lineDirection,pageDirection,custom和grid。
0 整数 网格布局中的列数。
不断变化 空值 回调以执行值更改。
样式 空值 组件的内联样式。
styleClass 空值 容器的样式类。
标签索引 空值 指定选项卡导航中元素的选项卡顺序。
平淡 布尔型 普通模式使用本机浏览器呈现而不是主题显示单选按钮。

SelectOneRadio入门 (Getting Started With SelectOneRadio)

SelectOneRadio usage is same as the using of SelectOneMenu with one difference is that a set of radio controls are rendered rather using of menu control.

SelectOneRadio的用法与SelectOneMenu的用法相同,不同之处在于,呈现了一组单选控件,而不是使用菜单控件。

摘要 (Summary)

All of Selective components are collected and explored in a one location. A detailed explanations, figures and examples are provided for all of them. Contribute us by commenting below and find downloaded source code.

在一个位置收集和探索所有的选择性成分。 提供了详细的解释,图形和示例。 通过在下面评论来贡献我们,并找到下载的源代码。

翻译自: https://www.journaldev.com/4490/primefaces-radio-button-checkbox-example

primefaces

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值