primefaces 6.1选择一个菜单已填充但拒绝显示值

时间:2018-11-21 14:02:18

标签: filter primefaces selectonemenu

我正在尝试使用PrimeFaces 6.1的“选择一个菜单”进行过滤。但是菜单不会下拉以显示其值。它就像被禁用一样。我用<h:form>包装了datable,并检查菜单是否已填充在浏览器检查窗口中。

enter image description here

编辑:

enter image description here

这是桌子:

        <h:form>
            <p:dataTable var="left" value="#{dataFilterView.leftGrid}"
                widgetVar="leftTable"
                filteredValue="#{dataFilterView.filteredLeftGrid}">
                <ui:debug />
                <p:column headerText="Project">
                    <h:outputText value="#{left.projectName}" />
                </p:column>
                <p:column headerText="Company">
                    <h:outputText value="#{left.companyName}" />
                </p:column>
                <p:column headerText="Location" filterBy="left.projectLocation">
                    <h:outputText value="#{left.projectLocation}" />
                </p:column>
                <p:column headerText="Request Name">
                    <h:outputText value="#{left.requestName}" />
                </p:column>
                <p:column headerText="Request Type" filterBy="#{left.requestType}"
                    filterMatchMode="exact">
                    <f:facet name="filter">
                        <p:selectOneMenu onchange="PF('leftTable').filter()"
                            style="width:70%; box-sizing: border-box;">
                            <f:selectItem itemLabel="Select One" itemValue="#{null}"
                                noSelectionOption="true" />
                            <f:selectItems
                                value="#{dataFilterView.uniqueRequestTypes.entrySet()}"
                                var="data" itemValue="#{data.key}" itemLabel="#{data.value}" />
                        </p:selectOneMenu>
                    </f:facet>
                    <h:outputText value="#{left.requestType}" />
                </p:column>
            </p:dataTable>
        </h:form>

ManagedBean是:

@ManagedBean(name = "dataFilterView")
@SessionScoped
public class DataFilterView {

private String reqType;

private List<LeftGridBean> leftGrid;
private List<LeftGridBean> filteredLeftGrid;

private List<String> uniqueLocations;
private Map<String, String> uniqueRequestTypes;

@ManagedProperty("#{supplierRequestsService}")
private SupplierRequestsService service;

@PostConstruct
public void init() {
    leftGrid = service.populateLeftGrid();
}

public void setService(SupplierRequestsService service) {
    this.service = service;
}

public List<LeftGridBean> getLeftGrid() {
    return leftGrid;
}

public List<LeftGridBean> getFilteredLeftGrid() {
    return filteredLeftGrid;
}

public void setFilteredLeftGrid(List<LeftGridBean> filteredLeftGrid) {
    this.filteredLeftGrid = filteredLeftGrid;
}

public String getReqType() {
    return reqType;
}

public void setReqType(String reqType) {
    this.reqType = reqType;
}

public List<String> getUniqueLocations() {
    Set<String> locations = new HashSet<>();
    for (LeftGridBean lg : getLeftGrid()) {
        locations.add(lg.getProjectLocation());
    }
    uniqueLocations = new ArrayList<String>(locations);
    return uniqueLocations;
}

public Map<String, String> getUniqueRequestTypes() {
    Map<String, String> requestTypes = new HashMap<>();
    for (LeftGridBean lg : getLeftGrid()) {
        requestTypes.put(lg.getRequestType(), lg.getRequestType());
    }
    uniqueRequestTypes = requestTypes;
    return uniqueRequestTypes;
}
}

域:

public class LeftGridBean {
private String projectName;
private String projectLocation;
private String requestType;
private String requestName;
private String companyName;

public String getProjectLocation() {
    return projectLocation;
}

public void setProjectLocation(String projectLocation) {
    this.projectLocation = projectLocation;
}

public String getRequestType() {
    return requestType;
}

public void setRequestType(String requestType) {
    this.requestType = requestType;
}

public String getRequestName() {
    return requestName;
}

public void setRequestName(String requestName) {
    this.requestName = requestName;
}

public String getProjectName() {
    return projectName;
}

public void setProjectName(String projectName) {
    this.projectName = projectName;
}

public String getCompanyName() {
    return companyName;
}

public void setCompanyName(String companyName) {
    this.companyName = companyName;
}
}

最后是服务:

@ManagedBean(name="supplierRequestsService")
@SessionScoped
public class SupplierRequestsService {

@ManagedProperty("#{userManager}")
private UserManager usr;

public List<LeftGridBean> populateLeftGrid() {
    List<LeftGridBean> lgbList = usr.getSupplierLeftGridData();
    return lgbList;
}

public List<RightGridBean> populateRightGrid() {
    List<RightGridBean> rgbList = usr.getSupplierRightGridData();
    return rgbList;
}

public void setUsr(UserManager usr) {
    this.usr = usr;
}
}

0 个答案:

没有答案