简体   繁体   English

我可以用虚拟数据填充Primefaces Datatable吗?

[英]Can I fill Primefaces Datatable with Dummy Data?

I want to fill a primefaces datatable with dummy data. 我想用虚拟数据填充一张primefaces数据表。 Can I do this in any way like in normal HTML pages? 我可以像普通HTML页面一样以任何方式执行此操作吗? In plain HTML, I can do this for example: 在纯HTML中,我可以例如这样做:

 <table>
  <tr>
    <th>Berlin</th>
    <th>Hamburg</th>
    <th>München</th>
  </tr>
  <tr>
    <td>Miljöh</td>
    <td>Kiez</td>
    <td>Bierdampf</td>
   </tr>
   <tr>
     <td>Buletten</td>
     <td>Frikadellen</td>
     <td>Fleischpflanzerl</td>
   </tr>
</table>

I want to hardcode the same in an primefaces datatable (because I need this datatable only for demonstration purposes but I would like to keep its layout). 我想在primefaces数据表中对其进行硬编码(因为我仅出于演示目的需要此数据表,但我想保留其布局)。 Is there a way to do this with my <p:datatable> , without having to code a backing bean which fills it? 有没有办法用我的<p:datatable>做到这一点,而不必编写填充它的后备bean的代码?

Thanks! 谢谢!

No you can't. 不,你不能。 p:datatable value="..." attribute must resolve to a data source which is (recieved from) a managed bean eg of type Collection or DataModel . p:datatable value="..."属性必须解析为数据源,该数据源是(从中)托管bean,例如CollectionDataModel类型。

Maybe you can somehow make up a List of Maps hard coded in faces-config.xml , but how ugly is this? 也许您可以以某种方式组成一个faces-config.xml硬编码Maps List ,但这有多丑? Better create a managed bean with hard coded demo data. 使用硬编码的演示数据更好地创建托管bean。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM