Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 使用primefaces导出到excel时出现的问题_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Jsf 使用primefaces导出到excel时出现的问题

Jsf 使用primefaces导出到excel时出现的问题,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,基本上我是JSF和primefaces的新手。 我在primefaces中执行导出到excel时遇到以下异常 javax.faces.FacesException - Cannot find component with expression "dataTableId" referenced from "Export". 我不明白当我将数据表的正确id传递给commandbutton时,为什么它无法识别该组件。请按以下代码查找 命令按钮代码: <p:commandButton id="E

基本上我是JSF和primefaces的新手。 我在primefaces中执行导出到excel时遇到以下异常

javax.faces.FacesException - Cannot find component with expression "dataTableId" referenced from "Export".
我不明白当我将数据表的正确id传递给commandbutton时,为什么它无法识别该组件。请按以下代码查找

命令按钮代码:

<p:commandButton id="Export" ajax="false" value="Export">    
  <f:facet name="Exporters">                        
   <p:dataExporter type="xls" target="dataTableId" fileName="cars" /> 
   </f:facet>             
    </p:commandButton>  

数据表代码

<p:panel style="width:800%;height:100%">            
<h:outputLabel value="Search Results" style="font-weight: bold;font-size:14px;"></h:outputLabel>
<p:dataTable scrollWidth="100%" id="dataTableId" var="dataTableId"
value="#{someBean.value}"
selection="#{someBean.value}"
rowKey="#{someBean.id}" scrollable="true" rowSelectMode="multiple" scrollHeight="100%">


这是我错过的。非常感谢任何帮助。

尝试提及完整的目标,例如,如果您有一个表单或命名容器,并且datatable在其中,那么它应该是这个
target=“:form:dataTableId”
。或者,如果您没有任何命名容器(我对此表示怀疑),请更全局地引用组件
target=“:dataTableId”
。无论如何,通过谷歌搜索,你可以找到答案。我强烈支持它,我得到的错误是因为我在dataTable上面编写了导出代码。正如您所说,如果我用表单名引用它,我就可以得到它。谢谢你的建议。如果你能粘贴你的答案,我也能接受。