PrimeFaces Dropdown在复合组件内部自动完成

时间:2012-06-23 07:50:04

标签: jsf primefaces composite-component

我正在尝试在复合组件中嵌入primefaces自动完成方法。

但是,尝试访问“完整”方法时失败。

这是我的代码:

..
<composite:interface>
  <composite:attribute name="car" required="true" />
  <composite:attribute name="brandList" required="true" method-signature="java.util.List complete(java.lang.String)" />
  <composite:attribute name="style" required="false" />
</composite:interface>

<composite:implementation>
  ..

  <h:outputLabel value="DropDown :" for="dd" />
  <p:autoComplete id="dd" dropdown="true" value="#{cc.attrs.car.brand}" completeMethod="#{cc.attrs.brandList}" />
  ..
</composite:implementation>

电话:

<cp:carPropertiesAutoComplete car="#{carController.car}" brandList="#carController.complete}" />

支持bean:

public List<String> complete(String query) {
  List<String> brandList = new ArrayList<String>();

  brandList.add("brand0");
  brandList.add("brand1");

  for (String brand : brandList) {
    if(brand.contains(query)) {
      brandList.add(brand);
    }
  }
  return brandList;
}

日志:

  

警告:/ newCarAutoComplete.xhtml @ 17,112   brandList =“#{carController.complete}”:类'CarController'可以   没有财产'完整'。 javax.el.PropertyNotFoundException:   /newCarAutoComplete.xhtml @ 17,112   brandList =“#{carController.complete}”:类'CarController'可以   没有财产'完整'。在   com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)     在   com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:190)     在   com.sun.faces.facelets.tag.TagAttributeImpl $ AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:450)     在   org.primefaces.component.autocomplete.AutoComplete.broadcast(AutoComplete.java:340)     在   javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)     在   javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:935)     在   com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)     在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)at   com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)     在javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)at   org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)     在   org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)     在   org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)     在   org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)     在   com.sun.enterprise.v3.services.impl.ContainerMapper $ AdapterCallable.call(ContainerMapper.java:317)     在   com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)     在   com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)     在   com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)     在   com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)     在   com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)     在   com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)     在   com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)     在   com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)     在   com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)     在   com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)     在   com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)     在com.sun.grizzly.ContextTask.run(ContextTask.java:71)at   com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)     在   com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)     在java.lang.Thread.run(Thread.java:722)

我已经google了一下,发现了这个问题(没有解决方案同样的问题) http://forum.primefaces.org/viewtopic.php?f=3&t=1884

我使用Mojarra 2.1.6和PrimeFaces 3.3.1运行Glassfish服务器3.1.2

你能帮帮我吗?我已经挣扎了几个小时=(

1 个答案:

答案 0 :(得分:1)

为什么你不在@FacesComponent中创建完整的方法?然后使用{cc.brandList}而不是{cc.attrs.brandList}