📅  最后修改于: 2021-01-08 04:05:05             🧑  作者: Mango
PrimeFaces提供了组件来创建布尔复选框。它用于从用户获取布尔值。它是具有主题集成功能的标准复选框的扩展版本。
下表包含SelectBooleanCheckbox组件的属性。
Attribute | Default value | Return type | Description |
---|---|---|---|
id | null | String | It is an unique identifier of the component. |
rendered | true | Boolean | It is used to render component. It takes boolean value. |
binding | null | Object | It is used to set an expression that maps to a server side UIComponent instance in a backing bean |
value | null | Object | It is used to set value of the component referring to a List. |
converter | null | Converter/String | It is used to set text that defines a converter for the component. |
required | false | Boolean | It is used to make component as required. |
widgetVar | null | String | It is a name of the client side widget. |
disabled | false | Boolean | It is used to disable the component. |
label | null | String | It is used to set user presentable name. |
onchange | null | String | It is used to call script on value change. |
style | null | String | It is used to set CSS of the component. |
styleClass | null | String | It is used to set style class of the container. |
itemLabel | null | String | It is used to set label displayed next to checkbox. |
tabindex | null | String | It is used to specify tab order for tab key navigation. |
onfocus | null | String | It is used to execute script when checkbox receives focus. |
onblur | null | String | It is used to execute script when checkbox loses focus. |
title | null | String | It is used to set tooltip information. |
Style Class | Applies |
---|---|
.ui-chkbox | It is a main container element. |
.ui-chkbox-box | It is a container of checkbox icon. |
.ui-chkbox-icon | It is used for checkbox icon. |
在下面的示例中,我们正在实现组件。本示例包含以下文件。
// boolean-checkbox.xhtml
Boolean Checkbox
Boolean Checkbox
// BooleanCheckbox.java
package com.javatpoint;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
@ManagedBean
public class BooleanCheckbox {
private boolean value;
public boolean isValue() {
return value;
}
public void setValue(boolean value) {
this.value = value;
}
public void addMessage() {
String summary = value ? "Checked" : "Unchecked";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(summary));
}
}
输出:
当我们在下面检查时,它显示消息。