sub report file not seen 1.3 beta version

Help
joe joseph
2011-09-07
2012-10-10
  • joe joseph
    joe joseph
    2011-09-07

    Hi, I am willing to use a subreport with version beta 1.3. For that purpose I
    used the subrepordir attribute of the tag.

    First of all, must I use it with the SUBREPORT_DIR Parameter of ireport? Or
    use one or the other?

    Secondly, must I give the full path with the file or only the path? What I did
    is to give the full path with the directory, but I get this exception:

    net.......ReportNotFoundException.
    xhtml

    <rich:panel style="width: 780px; height: 700px;">
    
                                        <jr:dataSource 
                                            type="bean" 
                                            id="dataSource" 
                                            value="#{commandListPanel.reportViewer.principalDataSource}"/>
    
                                        <jr:report  
                                            title="Bon de Commande"
                                            format="pdf" 
                                            name="BondeCommande" 
                                            dataSource="dataSource" 
                                            path="#{commandListPanel.reportViewer.reportFileName}"
                                            style="width: 750px; height: 650px;"
                                            subreportDir="#{commandListPanel.reportViewer.subReportFileName}">
    
                                            <f:param name="REPORT_PARAMETERS_MAP" value="#{commandListPanel.reportViewer.parameters}"/>
    
                                        </jr:report>
    
                                </rich:panel>
    

    Java code:

    _ the reportViewer model_

    .
    .
    .
    .
    .
    
    /**
         * Methode d'obtention du Chemin vers le fichier de report
         * @return Chemin vers le fichier de report
         */
        public String getReportFileName() {
            return this.reportRootDiretory + "/" + reportFileName;
        }
    
            /**
         * Methode d'obtention du fichier du sous état
         * @return the subReportFileName fichier du sous état
         */
        public String getSubReportFileName() {
            return this.reportRootDiretory + "/" + subReportFileName;
        }
    

    setting the reportviemer properties:

    .
    .
    .
    .
                           // Fichier de l'etat
                reportViewer.setReportFileName("BonCommande.jasper");
    
                // Fichier du sous état
                reportViewer.setSubReportFileName("detailCommande.jasper");
    

    The main report is seen while the subreport is not seen.

    Thanks for your help.

     
  • mmmm, subreport feature has been always an experimental feature... in versions
    prior to 1-beta-4 the way to deal with that was using that "subreportDir"
    attribute which was supposed to point to a directory where JasperReport could
    find all the subreports. In that case, "subreportDir" maps directly to the
    "SUBREPORT_DIR" parameter of iReport...

    However, this way of dealing with subreports wasn't good enough, mainly
    because the resource handling mechanism of versions prior to beta 4 wasn't
    good enough. So it was changed in v1-beta-4. In this last version a
    "jr:subreport" component was added to the taglib, you can use it to:
    - give a specific reference to the subreport to parent one: parent report will receive a "net.sf.jasperreports.engine.JasperReport" parameter with the name of the subreport ("name" attribute)
    - to pass parameters to the subreport
    The attribute "subreportDir" has been removed but you can still use the
    iReport "SUBREPORT_DIR" parameter using a "f:param" tag inside your parent
    component.

    Just let me say at last that plugin's support for subreport is still
    experimental, I'm trying to find out the best way to deal with it and any
    ideas you may have are very welcome.

    Regards,
    Alonso

     
  • joe joseph
    joe joseph
    2011-09-07

    I switched to beta 4. Just wondering if you could provide a detailed example.
    Thank you

     
  • As I said, the subreport feature is quite experimental yet, however I expect
    to give full support for it as it's one of the most common thing we come
    across in report development.

    In beta 4 version this is suppose to work as it said in page (scroll to the
    end): http://jasperreportjsf.sourceforge.net/web/rendering_reports.html

    <jr:reportFrame id="parentReport" value="...">
        <f:param name="ORDER_ID" value="..." />
        <jr:subreport id="subreport" name="orderLines" source="..." value="...">
            <f:param name="FROM_DATE" value="..." />
            <f:param name="TO_DATE" value="..." />
        </jr:subreport>
    </jr:reportFrame>
    

    In that example, the report "parentReport" contains a subreport with the
    id="subreport" and name="orderLines". That means that parentReport will
    receive a parameter with the name "orderLines" which is an already compiled
    report instance (and that can be used in iReport as a report expression). Sub
    report also has a reference to a "source" instance and that means that
    parentReport will receive a parameter "orderLines.connection" or
    "orderLines.dataSource" (depending wheter the source component references a
    SQL connection or a JRDataSource) that could be used as the connection
    expression for that subreport. Additionally, "parentReport" will receive
    parameters in the form of "orderLines.{subreport_param_name}" for each of the
    parameters established inside the subreport component.

    Anyway, this is just the way it's intended to work but doesn't mean that it'll
    work (I'm still testing that functionality), but having a look at your code I
    think the easiest way to workaround it would be to use the same
    connection/dataSource in your subreport than the one of the parentReport
    and
    injecting a parameter inside the parentReport pointing to the subreport file
    (using that method "getSubReportFileName" method from your "reportViewer"
    bean).

    My apologies for not being able to give you more support on this. I'm working
    hard in future beta 5 in order to give full support to this feature...
    Regards,
    Alonso

     
  • joe joseph
    joe joseph
    2011-09-25

    Any updates about the SUBREPORT issue?

     
  • Well, didn't have enough time to make any serious improvement. I did some
    changes regarding subreports in the code for the next release but, as I said,
    I'm quite busy and didn't tested them properly.

    By the way, could you please provide me with feedback about what you've tried
    and the problems you faced? It'll help me a lot to understand your problem and
    address it properly in the future release.

    Regards.
    Alonso