📅  最后修改于: 2021-01-08 04:12:48             🧑  作者: Mango
它用于从给定选项中选择多个值。当我们想从一个集合中获取多个用户输入时,这很有用。我们可以使用组件在JSF应用程序中创建SelectManyCheckbox。
它具有下表列出的各种属性。
Attribute | Default value | Return type | Description |
---|---|---|---|
id | null | String | It is an unique identifier of the component. |
rendered | true | Boolean | It is used to specify the rendering of the component. |
value | null | obejct | It is used to set value of the component. |
required | false | Boolean | It is used to mark component as required. |
requiredMessage | null | String | It is used to set message to be displayed when required field validation fails. |
disabled | false | Boolean | It is used to disable the component. |
label | null | String | It is used to set user presentable name. |
layout | lineDirection | String | It is used to set layout of the checkboxes. |
columns | 0 | Integer | It is used to specify number of columns in grid layout. |
onchange | null | String | It is used to execute script on value change. |
style | null | String | It is used to set inline CSS of the component. |
tabindex | null | String | It is used to set position of the component in the tabbing order. |
下表包含SelectManyCheckbox的结构样式类。
Style Class | Applies |
---|---|
.ui-selectmanycheckbox | It applies on the main container element. |
.ui-chkbox | It applies on the container of a checkbox. |
.ui-chkbox-box | It applies on container of checkbox icon. |
.ui-chkbox-icon | It applies on checkbox icon. |
在下面的示例中,我们正在实现组件。本示例包含以下文件。
// selectManyCheckbox.xhtml
Primefaces ManyCheckBox
Select Courses
Course Name
#{example}
// ManyCheckBox.java
package com.javatpoint;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class ManyCheckBox {
private String[] selectedCourse;
public String[] getSelectedCourse() {
return selectedCourse;
}
public void setSelectedCourse(String[] selectedCourse) {
this.selectedCourse = selectedCourse;
}
}
输出: