【问题标题】:how can i pass a DataTable as a parameter from view to backing bean?如何将 DataTable 作为参数从视图传递到支持 bean?
【发布时间】:2013-06-29 06:56:52
【问题描述】:

我正在实现一个自定义 pdf 导出器,但我需要将我的数据表从视图传递到我的支持 bean,但我不知道该怎么做。

在视图中,我将有一个如下所示的命令链接:

  <h:commandLink action="#{procesos.exportPDF( mytable , 'procesos')}">
     </h:commandLink>

这是接收 DataTable 作为参数的方法:

public void exportPDF(DataTable table, String filename) throws IOException {
        FacesContext context = FacesContext.getCurrentInstance();
        Exporter exporter = new CustomPDFExporter();
        exporter.export(context, table, filename, false, false, "iso-8859-1", null, null);
        context.responseComplete();
    }

无论如何.. 我想做的是使用 custompdf 导出器修改列宽,因为 dataexporter 和 primefaces 的导出器扩展不允许该功能,所以如果有人知道或有一个允许它的自定义 pdf 导出器非常感谢展示一点(更好的全部)代码:)!

谢谢。

【问题讨论】:

    标签: jsf-2 primefaces datatable parameter-passing exporter


    【解决方案1】:

    我遇到了同样的问题。 我没有直接通过桌子。我只是传递了表单和表格的 id 并使用了 findComponent

    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot viewRoot = context.getViewRoot();
    
    // find table by form- and table-id
    UIComponent component = viewRoot.findComponent(formId).findComponent(tableId);
    DataTable table = (DataTable) component;
    

    【讨论】:

      猜你喜欢
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      相关资源
      最近更新 更多