p:dataExporter does not recognize p:cellEditor

前端 未结 2 1741
天涯浪人
天涯浪人 2020-11-29 04:36

I have an editable with and I want to export the content of that table into PDF format using

2条回答
  •  情歌与酒
    2020-11-29 05:30

    I agree, I also find this approach to customize the Exporter behaviour the most flexible and least painful.

    Anyone interested in using the preProcessor/postProcessor methods with this? Here's an example how to do that.

    I dared to slightly modify the method from the answer above:

    public void exportPDF(DataTable table, String filename, 
            String preProcessor, String postProcessor) throws IOException {
    
        FacesContext context = FacesContext.getCurrentInstance();
        ExpressionFactory factory = context.getApplication().getExpressionFactory();
    
        MethodExpression preProcessorME = factory.createMethodExpression(
            context.getELContext(), preProcessor, null, new Class[] {Object.class});
        MethodExpression postProcessorME = factory.createMethodExpression(
            context.getELContext(), postProcessor, null, new Class[] {Object.class});
    
        Exporter exporter = new ExtendedPDFExporter();
        exporter.export(context, table, filename, false, false, "UTF-8", 
            preProcessorMe, postProcessorME);
    
        context.responseComplete();
    
    }
    

    And this is how you use it in your page (again, I just modified the above example):

    
        ...
        ...
        ...
        
    
    
    

    Notice that there ARE NO NESTED EL STATEMENTS (that is not allowed anyway), the last two arguments are simple Strings containing EL expressions.

提交回复
热议问题