【问题标题】:primefaces autocomplete and it search properly. But it is not works properlyprimefaces 自动完成并正确搜索。但它不能正常工作
【发布时间】:2013-01-15 13:17:32
【问题描述】:

我使用 primefaces 自动完成并正确搜索。当我单击 Save 时,显示此错误消息。

/entryPages/usDistributorDetails/Create.xhtml @95,71 itemLabel="#{territory.territoryName}": Property 'territoryName' not found on type java.lang.String

我的 xhtml 代码:

 <p:autoComplete id="territoryId11"
     value="#{usDistributorDetailsController.selected.territoryId}"
     completeMethod="#{usDistributorDetailsController.completeTerritory}"
     var="territory" itemLabel="#{territory.territoryName}"
     itemValue="#{territory.territoryId}"
     size="37"
     style="width: 264px" >

</p:autoComplete>

我的 Java 代码:

public List<UsTerritory> completeTerritory(String query11) {

    List<UsTerritory> results = new ArrayList<UsTerritory>();
    List<UsTerritory> territoryListA = getJpaTerritoryController().findUsTerritoryEntities();

    for (UsTerritory abc : territoryListA) {

         if (abc.getTerritoryName().startsWith(query11)) {
            results.add(abc);
        }

    }

    return results;
}

【问题讨论】:

  • 您当前的问题是由以下任一原因引起的 1) UsTerritory 类确实没有名为 territoryName 的 java-bean 样式成员 2.) 支持 bean 之间存在类型不匹配绑定属性usDistributorDetailsController.selected.territoryId 以及您尝试将其强制转换为的类型(自动完成项返回的类型)。

标签: jsf-2 primefaces


【解决方案1】:

在使用 POJO 时,您可能必须使用转换器。看一看:Primfaces Autocomplete Pojo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-26
    • 2020-10-12
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多