📅  最后修改于: 2021-01-08 04:07:02             🧑  作者: Mango
用于选择覆盖中显示的多个项目。我们可以使用组件来创建它。它在叠加中显示选项。它提供了下表中列出的属性。
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 the specify component. |
binding | null | Object | It binds 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. |
converter | null | Converter/String | It is used to define a converter for the component. |
required | false | Boolean | It is used to mark component as required. |
requiredMessage | null | String | It is used to set a message to be displayed when required field validation fails. |
style | null | String | It is used to set inline style of the component. |
onShow | null | String | It is a method that executes when overlay is displayed. |
onHide | null | String | It is a method that executes when overlay is hidden. |
multiple | false | Boolean | It is used to set selected itemds as multiple labels. |
SelectCeckboxMenu除了常见的dom事件(如change,selectCheckboxMenu)外,还提供Ajax事件。
Event | Listener Parameter | Executed |
---|---|---|
toggleSelect | org.primefaces.event.ToggleSelectEvent | When toggle all checkbox changes. |
在下面的示例中,我们在这里实现组件。本示例包含以下文件。
// calendar.xhtml
Checkbox Menu
// CheckboxMenu.java
package com.javatpoint;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class CheckboxMenu {
private String[] selectedCities;
private List cities;
@PostConstruct
public void init() {
cities = new ArrayList<>();
cities.add("Greater Noida");
cities.add("New Delhi");
cities.add("Paris");
cities.add("Tokyo");
cities.add("Newyork");
cities.add("Moscow");
cities.add("Rome");
cities.add("California");
cities.add("Shanghai");
}
public String[] getSelectedCities() {
return selectedCities;
}
public void setSelectedCities(String[] selectedCities) {
this.selectedCities = selectedCities;
}
public List getCities() {
return cities;
}
}
该JSF应用程序产生以下输出。
输出:
我们可以看到它允许我们从菜单中选择多个项目。