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. SelectBooleanCheckboxSelectBoolean复选框
  3. SelectCheckboxMenu选择复选框菜单
  4. SelectManyButtonSelectManyButton
  5. SelectManyCheckboxSelectMany复选框
  6. SelectManyMenu全选菜单
  7. SelectOneButton选择一个按钮
  8. SelectOneListboxSelectOneListbox
  9. SelectOneMenu选择一个菜单
  10. SelectOneRadioSelectOneRadio

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用于通过切换按钮选择二进制决策。

Tag SelectBooleanButton
Component Class org.primefaces.component.selectbooleanbutton.SelectBooleanButton
Component Type org.primefaces.component.SelectBooleanButton
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectBooleanButtonRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
converter null Converter/ String An 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
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null Method Expr A method expression that refers to a method validationg the input
valueChangeListener null Method Expr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Callback to execute on value change.
style null String Inline style of the component.
styleClass null String Style class of the container.
onLabel null String Label to display when button is selected.
offLabel null String Label to display when button is unselected.
onIcon null String Icon to display when button is selected.
offIcon null String Icon 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是具有主题集成功能的标准复选框的扩展版本。

Tag SelectBooleanCheckbox
Component Class org.primefaces.component.selectbooleancheckbox.SelectBooleanCheckbox
Component Type org.primefaces.component.SelectBooleanCheckbox
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectBooleanCheckboxRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
converter null Converter/ String An 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
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Callback to execute on value change.
style null String Inline style of the component.
styleClass null String Style class of the container.
itemLabel null String Label displayed next to checkbox.
tabindex null String Specifies 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

Method Params Return Type Description
check() void Checks the checkbox.
uncheck() void Unchecks the checkbox.
toggle() void Toggles 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是一个多选组件,可在覆盖图中显示选项。

Tag SelectCheckboxMenu
Component Class org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenu
Component Type org.primefaces.component.SelectCheckboxMenu
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectCheckboxMenuRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
converter null Converter/ String An 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
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Callback to execute on value change.
style null String Inline style of the component.
styleClass null String Style class of the container.
scrollHeight null Integer Height of the overlay.
onShow null String Client side callback to execute when overlay is displayed.
onHide null String Client side callback to execute when overlay is hidden.
filter false Boolean Renders an input field as a filter.
filterMatchMode startsWith String Match mode for filtering, valid values are startsWith, contains, endsWith and custom.
filterFunction null String Client side function to use in custom filtering.
caseSensitive false Boolean Defines if filtering would be case sensitive.
panelStyle null String Inline style of the overlay.
panelStyleClass null String Style class of the overlay.
appendTo null String Appends the overlay to the element defined by search expression. Defaults to document body.
tabindex null String Position 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(){}@PostConstructpublic 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事件的详细列表。

Event Listener Parameter Fired
toggleSelect org.primefaces.event.ToggleSelectEvent When toggle all checkbox changes
事件 侦听器参数 被解雇
toggleSelect org.primefaces.event.ToggleSelectEvent 切换所有复选框时

SelectManyButton基本信息 (SelectManyButton Basic Info)

SelectManyButton is a multi select component using button UI.

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

Tag SelectManyButton
Component Class org.primefaces.component.selectmanybutton.SelectManyButton
Component Type org.primefaces.component.SelectManyButton
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectManyButton
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
converter null Converter/ String An 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
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Callback to execute on value change.
style null String Inline style of the component.
styleClass null String Style 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>();@PostConstructpublic 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的扩展版本。

Tag SelectManyCheckbox
Component Class org.primefaces.component.selectmanycheckbox.SelectManyCheckbox
Component Type org.primefaces.component.SelectManyCheckbox
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectManyCheckboxRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
converter null Converter/St ring An 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
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
layout lineDirection String Layout of the checkboxes, valid values are lineDirection, pageDirection and grid.
columns 0 Integer Number of columns in grid layout.
onchange null String Callback to execute on value change.
style null String Inline style of the component.
styleClass null String Style 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(){}@PostConstructpublic 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的扩展版本。

Tag SelectManyMenu
Component Class org.primefaces.component.selectmanymenu.SelectManyMenu
Component Type org.primefaces.component.SelectManyMenu
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectManyMenuRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Callback to execute on value change.
onclick null String Callback for click event.
ondblclick null String Callback for dblclick event.
style null String Inline style of the component.
styleClass null String Style class of the container.
tabindex null String Position of the input element in the tabbing order.
var null String Name of iterator to be used in custom content display.
showCheckbox false Boolean When true, a checkbox is displayed next to each item.
filter false Boolean Displays an input filter for the list.
filterMatchMode null String Match mode for filtering, valid values are startsWith (default), contains, endsWith and custom.
filterFunction null String Client side function to use in custom filterMatchMode.
caseSensitive false Boolean Defines if filtering would be case sensitive.
scrollHeight null Integer Defines the height of the scrollable area
converter null Converter/String An 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(){}@PostConstructpublic 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是执行单个选择的输入组件。

Tag SelectOneButton
Component Class org.primefaces.component.selectonebutton.SelectOneButton
Component Type org.primefaces.component.SelectOneButton
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectOneButtonRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Callback to execute on value change.
style null String Inline style of the component.
styleClass null String Style class of the container.
converter null Converter/St ring An 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 = "";@PostConstructpublic 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组件的扩展版本。

Tag SelectOneListbox
Component Class org.primefaces.component.selectonelistbox.SelectOneListbox
Component Type org.primefaces.component.SelectOneListbox
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectOneListboxRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
converter null Converter/ String An 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
immediate false Boolean When set true, process validations logic is executed at apply request values phase for this component.
required false Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Callback to execute on value change.
onclick null String Callback for click event.
ondblclick null String Callback for dblclick event.
style null String Inline style of the component.
styleClass null String Style class of the container.
tabindex null String Position of the input element in the tabbing order.
value null String Name of iterator to be used in custom content display.
var null String Name of iterator to be used in custom content display.
filter false Boolean Displays an input filter for the list.
filterMatchMode null String Match mode for filtering, valid values are startsWith (default), contains, endsWith and custom.
filterFunction null String Client side function to use in custom filterMatchMode.
caseSensitive false Boolean Defines if filtering would be case sensitive.
scrollHeight null Integer Defines 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 = "";@PostConstructpublic 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的扩展版本。

Tag SelectOneMenu
Component Class org.primefaces.component.selectonemenu.SelectOneMenu
Component Type org.primefaces.component.SelectOneMenu
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectOneMenuRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component.
converter null Converter/ String An 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
immediate 0 Boolean When set true, process validations logic is executed at apply request values phase for this component.
required 0 Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
effect blind String Name of the toggle animation.
effectSpeed 400 Integer Duration of toggle animation in milliseconds.
disabled false Boolean Disables the component.
label null String User presentable name.
onchange null String Client side callback to execute on value change.
onkeyup null String Client side callback to execute on keyup.
onkeydown null String Client side callback to execute on keydown.
style null String Inline style of the component.
styleClass null String Style class of the container.
var null String Name of the item iterator.
height auto Integer Height of the overlay.
tabindex null String Tabindex of the input.
editable false Boolean When true, input becomes editable.
filter false Boolean Renders an input field as a filter.
filterMatchMode starts With String Match mode for filtering, valid values are startsWith, contains, endsWith and custom.
filterFunction null String Client side function to use in custom filtering.
caseSensitive false Boolean Defines if filtering would be case sensitive.
maxlength null Integer Number of maximum characters allowed in editable selectOneMenu.
appendTo null String Appends 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 = "";@PostConstructpublic 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)

Tag SelectOneRadio
Component Class org.primefaces.component.selectoneradio.SelectOneRadio
Component Type org.primefaces.component.SelectOneRadio
Component Family org.primefaces.component
Renderer Type org.primefaces.component.SelectOneRadioRenderer
Renderer Class org.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)

Name Default Type Description
id null String Unique identifier of the component
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean
value null Object Value of the component referring to a List.
converter null Converter/ String An 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
immediate 0 Boolean When set true, process validations logic is executed at apply request values phase for this component.
required 0 Boolean Marks component as required
validator null MethodExpr A method expression that refers to a method validationg the input
valueChangeListener null MethodExpr A method expression that refers to a method for handling a valuechangeevent
requiredMessage null String Message to be displayed when required field validation fails.
converterMessage null String Message to be displayed when conversion fails.
validatorMessage null String Message to be displayed when validation fields.
widgetVar null String Name of the client side widget.
disabled false Boolean Disables the component.
label null String User presentable name.
layout line Direction String Layout of the radiobuttons, valid values are lineDirection, pageDirection, custom and grid.
columns 0 Integer Number of columns in grid layout.
onchange null String Callback to execute on value change.
style null String Inline style of the component.
styleClass null String Style class of the container.
tabindex null String Specifies the tab order of element in tab navigation.
plain false Boolean Plain 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.

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

Download Primefaces Selection Project下载Primefaces选择项目

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

primefaces

primefaces_Primefaces单选按钮,复选框示例相关推荐

  1. eazy ui 复选框单选_UI备忘单:单选按钮,复选框和其他选择器

    eazy ui 复选框单选 重点 (Top highlight) Pick me! Pick me! No, pick me! In today's cheat sheet we will be lo ...

  2. Java学习day078 Swing用户界面组件(四:选择组件)(复选框、单选钮、边框、组合框、滑动条)

    使用的教材是java核心技术卷1,我将跟着这本书的章节同时配合视频资源来进行学习基础java知识. day078   Swing用户界面组件(四:选择组件)(复选框.单选钮.边框.组合框.滑动条) 前 ...

  3. fluent design_Fluent Design单选按钮,复选框,选择框,Java菜单

    fluent design 这次我对JMetro进行了重大更新. 3.8版带来了以下新的Fluent Design (FDS)启发风格(深色和浅色)和更新: 新的单选按钮样式: 复选框的新样式: 菜单 ...

  4. Fluent Design单选按钮,复选框,选择框,Java菜单

    这次我对JMetro进行了重大更新. 3.8版引入了以下新的Fluent Design (FDS)启发风格(深色和浅色)和更新: 新的单选按钮样式: 复选框的新样式: 菜单的新样式: 更新了上下文菜单 ...

  5. 单选按钮必填会有红色选中提示吗_为什么单选按钮和复选框不能共存?

    以下内容由摹客团队翻译整理,仅供学习交流,摹客设计+协作一站式云平台,从产品.设计到开发,摹客来解决. 单选按钮和复选框长期以来一直都是容易导致用户困惑的组件.这两个组件通常用于相同的情景下,但看起来 ...

  6. JavaFX --- 标签、文本框、密码框、下拉框、按钮、单选按钮、复选框

    目录 JavaFX的基本结构和概念 Application --- 代表了JavaFX的应用程序 Stage --- 舞台 --- 代表了一个窗体. 在Application的start方法中,提供了 ...

  7. fluent_Fluent Design单选按钮,复选框,选择框,Java菜单

    fluent 这次我对JMetro进行了重大更新. 3.8版带来了以下新的Fluent Design (FDS)启发风格(深色和浅色)和更新: 新的单选按钮样式: 复选框的新样式: 菜单的新样式: 更 ...

  8. Android基础入门教程——2.3.5.RadioButton(单选按钮)Checkbox(复选框)

    Android基础入门教程--2.3.5.RadioButton(单选按钮)&Checkbox(复选框) 标签(空格分隔): Android基础入门教程 本节引言: 本节给大家带来的是Ando ...

  9. js 实现多选框(复选框) 和单选框,下拉框功能完整示例代码附效果图

    <!DOCTYPE html> <html><head><meta charset="utf-8" /><script src ...

最新文章

  1. CSS3 animation-timing-function steps()
  2. python从命令行获取参数_python从命令行获取参数操作
  3. java 生产配置文件管理_JAVA基础——使用配置文件
  4. Hexo搭建git博客
  5. python生成奇数列表_python3:列出一个不需要迭代的奇数列表
  6. 一个程序员的逗逼瞬间(三)
  7. python pyqt eric_python+PyQT+Eric安裝配置 | 學步園
  8. 谷歌资助OSTIF审计8个重要开源项目,提升软件供应链安全
  9. 简单python脚本实例-python常用运维脚本实例
  10. 为ASP.NET MVC Client-side Resource Combine 添加中文支持
  11. 计算机基础(三):srpintf()函数小结
  12. x86_64-linux-gnu/libgdk-x11-2.0.so: error adding symbols: DSO missing from command line
  13. 网页滚动截屏怎么截长图
  14. 利用微信聊天记录,送女友个小礼物
  15. CSP—— 登机牌条码(多项式的求解以及多项式的除法)
  16. 【学习笔记】Android Fragments
  17. 各省数字普惠金融指数(2015-2019年)
  18. proxmox PVE 安装 黑苹果
  19. 关于Linux中的SIGABRT信号
  20. 互信息(Mutual Information)

热门文章

  1. 软件开发中的完整测试所包括的环节UT、IT、ST、UAT
  2. shell(九)几个字符转换命令
  3. Google Java编程风格指南中文版(转)
  4. 动态sql语句基本语法
  5. 操作 SQL Server Mobile 2005 数据库的常用 C# 代码 (转自黎波)
  6. pip “Cannot uninstall ‘pip包‘. It is a distutils installed project...“ 解决方法
  7. [转载] 消息中间件学习总结(8)——RocketMQ之RocketMQ捐赠给Apache那些鲜为人知的故事
  8. springboot 全局捕获异常
  9. 洛谷 2633 BZOJ 2588 Spoj 10628. Count on a tree
  10. 洛谷——P1155 双栈排序