<p:selectBooleanButton /> 始终将后备 bean 布尔属性设置为 false



我有一个项目的列表,我的内容显示在一个网页上。每个项目都有一个布尔值来表示它是否已被选中。下面给出了.xhtml文件和支持bean项目。问题是每次我在网页中选择或取消选择布尔按钮时,它总是将backing bean中的布尔属性设置为false。

名为. xhtml的

<p:outputPanel layout="inline">
<p:repeat id="projectSelect" 
value="#{checkoutRulesBean.projectList}" 
var="project">
<p:selectBooleanButton id="project"
value="#{project.selected}"
onLabel="#{project.name}" 
offLabel="#{project.name}" 
onIcon="fa fa-check"
offIcon="fa fa-square-o"
style="margin: 5px; padding: 5px;" >
<p:ajax listener="#{checkoutRulesBean.toggleProjectSelection()}"
process="@this"
update="@(.project-boards-table)"/>
</p:selectBooleanButton>
</p:repeat>
</p:outputPanel>

Project.java (Backing Bean)

public class Project implements Serializable{

private List<BoardCheckoutRules> boardCheckoutList = new ArrayList<>();
private Boolean selected = true;
private String name;

/**
* Creates a new instance of Project
*/
public Project() {
}

public Project(String name){
this.name = name;
}

public List<BoardCheckoutRules> getBoardCheckoutList() {
return boardCheckoutList;
}
public void setBoardCheckoutList(List<BoardCheckoutRules> boardCheckoutList) {
this.boardCheckoutList = boardCheckoutList;
}
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean clicked) {
PayaraLogger.logDebug(this.name + " has been " + ((clicked) ? "selected" : "unselected"));
this.selected = clicked;
}

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}    
}

我找到了问题所在。selectBooleanButton应该用

最新更新