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组件。
- SelectBooleanButton 选择布尔按钮
- SelectBooleanCheckbox SelectBoolean复选框
- SelectCheckboxMenu 选择复选框菜单
- SelectManyButton SelectManyButton
- SelectManyCheckbox SelectMany复选框
- SelectManyMenu 全选菜单
- SelectOneButton 选择一个按钮
- SelectOneListbox SelectOneListbox
- SelectOneMenu 选择一个菜单
- 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用于通过切换按钮选择二进制决策。
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</ |
---|