Jump to content
We've recently updated our Privacy Statement, available here ×

nusa

Members
  • Posts

    10
  • Joined

  • Last visited

nusa's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. Anyone could help me out please ? I'm really stuck in here. Thanks.
  2. Could anyone help me or give me some pointers/advices ? Thanks.
  3. Hi everyone, I have a nested subreport that I can't display it. I have a master report (MR), a subreport (SR), and a nested subreport inside that SR (NSR). I tried the following code : Code: -- in the MR <parameter name="SR" isForPrompting="false" class="net.sf.jasperreports.engine.JasperReport"/> ... <subreport isUsingCache="true"> <reportElement .../> <subreportParameter name="XML_DATA_DOCUMENT"> <subreportParameterExpression><![CDATA[$P{XML_DATA_DOCUMENT}]]></subreportParameterExpression> </subreportParameter> <!-- Embedded load the NSR ??? --> <subreportParameter name="NSR"> <subreportParameterExpression> net.sf.jasperreports.engine.util.JRLoader.loadObject(getClass().getClassLoader().getResourceAsStream("WEB-INF/jasper/NSR.jasper"«»)) </subreportParameterExpression> </subreportParameter> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{SR}]]> </subreportExpression> </subreport> ... -- in the SR <parameter name="NSR" isForPrompting="false" class="net.sf.jasperreports.engine.JasperReport"/> ... <subreport isUsingCache="true"> <reportElement .../> <subreportParameter name="XML_DATA_DOCUMENT"> <subreportParameterExpression><![CDATA[$P{XML_DATA_DOCUMENT}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/root_element/..."«»)]]> </dataSourceExpression> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{NSR}]]> </subreportExpression> </subreport> ... -- the Java code ... Map param = new HashMap(); param.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, doc); String subReport; subReport = request.getSession().getServletContext().getRealPath("WEB-INF/jasper/SR.jasper"«»); System.out.println("===> Load subreport " + subReport); JasperReport bankReport = (JasperReport)JRLoader.loadObject(subReport); param.put("SR", bankReport); System.out.println("===> Fill the report "«»); String reportFilename = request.getSession().getServletContext().getRealPath("WEB-INF/jasper/MR.jasper"«»); JasperPrint reportPrint = JasperFillManager.fillReport(reportFilename, param); System.out.println("===> Export to PDF"«»); String finalfilename = "test.pdf"; JasperExportManager.exportReportToPdfFile(reportPrint ,finalfilename); ... The above code does not display the SR nor the NSR. Anybody knows what's wrong with the above code ( both jrxml and java )? Thanks for any help/suggestion.
  4. Anyone please ? I'm stuck, I really need your help/suggestions ... Lucian, walmillard, Teodor, or anyone ? Thanks.
  5. I have the following XML schema : Code: <shop shop1="Y" shop2="Y" shop3="N"> <shop1> <section_1> <field lable="a" value="1"/> <field lable="b" value="2"/> </section_1> <section_2> <field lable="A" value="11"/> <field lable="B" value="22"/> </section_2> </shop1> <shop2> <section_1> <field lable="aa" value="10"/> <field lable="bb" value="20"/> </section_1> <section_2> <field lable="AA" value="110"/> <field lable="BB" value="220"/> </section_2> </shop2> <shop3> <section_1> <field lable="aaa" value="100"/> <field lable="bbb" value="200"/> </section_1> <section_2> <field lable="AAA" value="111"/> <field lable="BBB" value="222"/> </section_2> </shop3> <shop> I have a master report and I would like to create just ONE subreport. The tag <shop1>, <shop2>, and <shop3> have the same structure of descendant. The master displays the number of subreport based on the values of the attributes in the <shop> tag. If shop1 attr is 'Y', then display subreport shop1/section_1 and shop1/section_2. Same with shop2, but not shop3 as the value of the attribute is 'N'. My questions are : 1. how the master display the subreport based on the value shop/@shop1 ,shop/@shop2, and shop/@shop3 ? I think this is within the scope of printwhenExpression. If I define $F{shop1_field} as shop/@shop1, what'll be the printwhenExpression ? Something like : $F{shop1_field} ? 'Y' : display_shop1 Similarly : $F{shop2_field} ? 'Y' : display_shop2 and $F{shop3_field} ? 'Y' : display_shop3 2. in the master report, what will be the subreportParameter, subreportParameterExpression, subreportExpression, etc, if any ? 3. The subreport, either for shop1, shop2, or shop3 will display the rows like this : Code:[code] $F{field1_label} : $F{field1_value} $F{field2_label} : $F{field2_value} where $F{field1_label} is section_1/field/@label $F{field1_value} is section_1/field/@value $F{field2_label} is section_2/field/@label $F{field2_value} is section_2/field/@value The following code for subreport, of course, is incorrect : Code:[code] <queryString language="xPath"><![CDATA[/shop/$F{parm_from_master}]]></queryString> <field name="field1_label" class="java.lang.String"> <fieldDescription><![CDATA[section_1/*/@label]]></fieldDescription> </field> <field name="field1_value" class="java.lang.String"> <fieldDescription><![CDATA[section_1/*/@value]]></fieldDescription> </field> <field name="field2_label" class="java.lang.String"> <fieldDescription><![CDATA[section_2/*/@label]]></fieldDescription> </field> <field name="field2_value" class="java.lang.String"> <fieldDescription><![CDATA[section_2/*/@value]]></fieldDescription> </field> What will be the XPath and field descriptions ? I think the $F{parm_from_master} is related with my question 1 or 2, is it ? I really appreciate your help/suggestions. Thanks.
  6. Thanks Lucian, but according to this page http://www.zvon.org/xxl/XPathTutorial/General/examples.html ( see example 5 ), they use title[@value] and not title/@value. Also, if I have Code: <Northwind> <Customers> <title value="1"/> <CustomerID>ALFKI</CustomerID> ... <a> <b label="1" value="A"/> <b label="2" value="B"/> </a> <Customers> ... why the following field desription : Code:[code] a/*/@label return only 1 row ( the first occurence ) ? Thanks for your help/suggestion.
  7. nusa wrote: Hi, I have a problem using the following expression : Code: <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : "Good morning : " + $F{name} ]]></printWhenExpression> /Code:[code] Basically, I just want to print a blank or "Good morning : " + $F{name}. The above expression gave me a class cast exception. Any help would be appreciated. Thanks. Sorry, error in formating the code, it should be : Code:[code] <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : "Good morning : " + $F{name} ]]></printWhenExpression> Any help how to fix the above code ? The other thing is, how can I print a set of fields based on a condition of a field ? Say, if I want to print each address, city, country, phone nb, email, etc ( not concatenation of those ), if $F{name} is not emptry or null ? Do I need to do : Code:[code] <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : $F{address} ]]></printWhenExpression> <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : $F{city} ]]></printWhenExpression> <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : $F{country} ]]></printWhenExpression> <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : $F{phone nb} ]]></printWhenExpression> <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : $F{email} ]]></printWhenExpression> Is there any other way ? Thanks for any help/suggestion.
  8. Hi, I have a problem using the following expression : Code: <printWhenExpression><![CDATA[$F{name}.equals( "" ) ? null : "Good morning : " + $F{name} ]]></printWhenExpression> /[code] Basically, I just want to print a blank or "Good morning : " + $F{name}. The above expression gave me a class cast exception. Any help would be appreciated. Thanks.
  9. Hi, I looked into the xmldatasource example, and modified the northwind.xml by adding a new element 'title' into something like this : Code: <Northwind> <Customers> <title value="1"/> <CustomerID>ALFKI</CustomerID> ... </Customers> <Customers> <title value="2"/> <CustomerID>ANATR</CustomerID> ... Then, I modified as well the CustomerReport.jrxml : Code:[code] ... <field name="Title" class="java.lang.String"> <fieldDescription><![CDATA[title[@value]]]></fieldDescription> </field> ... <textFieldExpression class="java.lang.String"><![CDATA[$F{CustomerID} + " ==> " + $F{Title}]]></textFieldExpression> ... Can someone tell me why it prints a 'null' in the pdf generated ? What's wrong with my XPath expression above ? Thanks for any help/suggestions.
×
×
  • Create New...