primefaces_Primefaces单选按钮,复选框示例

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

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值