使用JSF基于数据库值动态选择复选框

时间:2018-04-03 12:25:48

标签: primefaces jsf-2

UI中有一个项目列表,每一行都附有唯一的ID。首先,此列仅对某些用户可见。根据特定条件,复选框必须为checked + disabled。截至目前,该复选框已被禁用,除第一行外,所有其他复选框都将被检查。有人可以建议一些想法来实现这一目标吗?

布尔值 partTypeAwarded 不是数据库列的一部分。我正在使用JSF 2.1 + Primefaces 3.5

xhtml页面:

<c:if test="#{(authorizationBean.abcRestrictedUser and authorizationBean.hasAbcPageAccess())}">
    <p:column headerText="#{msgs.abcAwarded}" styleClass="menuHeader" style="text-align:left">
        <p:selectBooleanCheckbox styleClass="margin_left_10" value="#{abcBean.partTypeAwarded}"
                 disabled="#{true}">
        </p:selectBooleanCheckbox>
    </p:column>
</c:if>

AbcBean

@URLAction(onPostback = false)
    public void load() {
        currentProject = projectService.findProject(projectId);
        allBajajVersions = bajajService.getBajajVersionsForProject(currentProject);
        awardedPartsTypeList = bajajPartSheetService.findQAPartTypeAwarded(projectId);    

    }

public boolean isPartTypeAwarded() {
        return partTypeAwarded;
}

public void setPartTypeAwarded(boolean partTypeAwarded) {
    this.partTypeAwarded = partTypeAwarded;
}



public boolean isPartTypeAwardedinAbc() {

        if (null != currentProject.getProjectPartTypes() && currentProject.getProjectPartTypes().size() > 0) {
            for (ProjectPartType projectPartType : currentProject.getProjectPartTypes()) {
                for (BajajPartsType awardedPartsType : awardedPartsTypeList) {                        
                    if (projectPartType.getBajajProjectPartsType().getName().equals(awardedPartsType.getName())) {                            
                        setPartTypeAwarded(true);
                    }
                }
            }
        }
        return partTypeAwarded;
    }

0 个答案:

没有答案