0

カスタム 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();
    }

とにかく.. dataexporterとprimefacesのエクスポーター拡張機能ではその機能が許可されていないため、custompdfエクスポーターで列幅を変更することです。コードの一部 (より良いすべて) を表示します :)!

ありがとう。

4

1 に答える 1

2

私も同じ問題を抱えていました。テーブルを直接渡しませんでした。フォームとテーブルの 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;
于 2013-07-02T08:06:18.093 に答える