I have a report controller having code:
#Controller
public class ReportsController {
#RequestMapping(value="report.htm",method=RequestMethod.GET)
public String showReport() throws JRException{
...
InputStream reportStream = this.getClass().getResourceAsStream("/report.jrxml");
JRDataSource dataSource = new JRBeanCollectionDataSource(reportData);
HashMap params = new HashMap();
params.put("Title", "Report");
JasperDesign jd = JRXmlLoader.load(reportStream);
JasperReport jr = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport(jr, params, dataSource);
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
//EXPORTING REPORT TO A FILE "myreport.html"
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "E:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html"); //--------statement (1)
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, false);
exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, true);
exporter.exportReport();
return "report";
}
}
In statement (1) I am exporting my generated report to a file myreport.html.
My report template file (report.jrxml) is:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report5" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="count" class="java.lang.Integer"/>
<field name="status" class="java.lang.String"/>
<background>
<band/>
</background>
<detail>
<band height="343">
<textField>
<reportElement mode="Transparent" x="8" y="14" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{count}]]></textFieldExpression>
</textField>
<textField>
<reportElement mode="Transparent" x="267" y="14" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{status}]]></textFieldExpression>
</textField>
<staticText>
<reportElement mode="Transparent" x="146" y="14" width="100" height="20"/>
<textElement/>
<text><![CDATA[status]]></text>
</staticText>
<barChart>
<chart>
<reportElement mode="Transparent" x="108" y="119" width="200" height="100"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[""]]></seriesExpression>
<categoryExpression><![CDATA[$F{status}]]></categoryExpression>
<valueExpression><![CDATA[$F{count}]]></valueExpression>
<itemHyperlink/>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
</barPlot>
</barChart>
</band>
</detail>
</jasperReport>
Problem is that my generated report in myreport.html is showing everything but does not show any bar chart, instead showing blank white space in place of chart.
Any suggestions?
EDIT:
Data to chart is provided by statement JasperPrint jp = JasperFillManager.fillReport(jr, params, dataSource); in the above code.
Moreover there is a folder generated, by jasper reports API, in the same dir in which there is my output file (myreport.html) lies as:
/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html (Output file)
/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html_files (generated folder)
This generated folder (myreport.html_files) contains generated chart images according to template and are correct but these chart images are not being shown up in the output file myreport.html along with other text output of report.
Thanks...
If there are bars of multiple colors, they will be displayed in a weaker and weaker shade. Export to PDF and you may see them
Related
I am working on a new Jaspert Report. It should print all data of a xml text.
The xml text looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<invoice:invoiceMessage>
<invoice>
<invoiceIdentification></invoiceIdentification>
<seller>
<address>
<name></name>
<city></city>
<cityCode></cityCode>
</address>
</seller>
</invoice>
</invoice:invoiceMessage>
And the Jasper Report looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 7.1.0.final using JasperReports Library version 6.4.3 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="main_report_xml1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="24a4119c-6e8f-4411-bbb5-c069ab379330">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="ireport.jasperserver.url" value="http://10.100.10.236/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="reko"/>
<property name="ireport.jasperserver.reportUnit" value="/Reko/main_report_xml1"/>
<subDataset name="pageHeader" uuid="cf87fcbb-cbcd-4c3b-bf87-3cf147854adb">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<queryString language="xPath">
<![CDATA[//seller/address]]]>
</queryString>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="streetAdressOne" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="streetAdressOne"/>
<fieldDescription><![CDATA[streetAdressOne]]></fieldDescription>
</field>
<field name="cityCode" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="cityCode"/>
<fieldDescription><![CDATA[cityCode]]></fieldDescription>
</field>
<field name="city" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="city"/>
<fieldDescription><![CDATA[city]]></fieldDescription>
</field>
</subDataset>
<parameter name="xmlString" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[xmlText]]></defaultValueExpression>
</parameter>
<parameter name="XML_INPUT_STREAM" class="java.io.InputStream">
<defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{xmlString}.getBytes("ISO-8859-1"))]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[/invoiceMessage/invoice[invoiceIdentification/entityIdentification=9000009029]]]>
</queryString>
<field name="value" class="java.lang.String">
<fieldDescription><![CDATA[creationDateTime]]></fieldDescription>
</field>
<pageHeader>
<band height="38"/>
</pageHeader>
<columnHeader>
<band height="31" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="488" splitType="Stretch">
<componentElement>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="21" width="552" height="30" isRemoveLineWhenBlank="true" uuid="fc7d22c7-8c60-4ecb-974f-c842becc4bf7"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="pageHeader" uuid="1e20fa2b-bb3a-475f-b721-5a13d3c374eb">
<datasetParameter name="XML_DATE_PATTERN">
<datasetParameterExpression><![CDATA[$P{XML_DATE_PATTERN}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_NUMBER_PATTERN">
<datasetParameterExpression><![CDATA[$P{XML_NUMBER_PATTERN}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_LOCALE">
<datasetParameterExpression><![CDATA[$P{XML_LOCALE}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="XML_TIME_ZONE">
<datasetParameterExpression><![CDATA[$P{XML_TIME_ZONE}]]></datasetParameterExpression>
</datasetParameter>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//*[entityIdentification=9000009029]/parent::*/seller")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30">
<textField isStretchWithOverflow="true">
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="552" height="15" uuid="eac696b9-e20f-48a3-b70d-b186f5e649d6"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
</jasperReport>
My question is:
What should my dataSourceExpression in the componentElement be, so I can get the data out of it?
I also have some data in the invoice node that I need to show and thats why i set it like this in the query string. And I need to filter by the parameter that is stored inside of invoiceIdentification node.
I've been struggling with my problem since 7 days.
I have 1 XML input data and want to convert that into desired PDF file with line chart
XML
<?xml version="1.0" encoding="utf-8"?>
<sample-data xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:ht="urn:xyz.com/xslt/extensions">
<section name="relative-performance">
<historic-valuations>
<valuation-list>
<valuation>
<value>890000</value>
<date>2014-12-01T00:00:00</date>
</valuation>
<valuation>
<value>923789</value>
<date>2015-12-01T00:00:00</date>
</valuation>
<valuation>
<value>897978</value>
<date>2016-12-01T00:00:00</date>
</valuation>
<valuation>
<value>957883</value>
<date>2017-12-01T00:00:00</date>
</valuation>
<valuation>
<value>919203</value>
<date>2018-12-01T00:00:00</date>
</valuation>
<valuation>
<value>950000</value>
<date>2019-12-01T00:00:00</date>
</valuation>
</valuation-list>
</historic-valuations>
<local-market-index>
<local-market>HA7 3</local-market>
<index-value-list>
<index-value>
<value>890000</value>
<date>2014-12-01T00:00:00</date>
</index-value>
<index-value>
<value>931069</value>
<date>2015-12-01T00:00:00</date>
</index-value>
<index-value>
<value>912244</value>
<date>2016-12-01T00:00:00</date>
</index-value>
<index-value>
<value>980893</value>
<date>2017-12-01T00:00:00</date>
</index-value>
<index-value>
<value>948882</value>
<date>2018-12-01T00:00:00</date>
</index-value>
<index-value>
<value>988654</value>
<date>2019-12-01T00:00:00</date>
</index-value>
</index-value-list>
</local-market-index>
</section>
</sample-data>
My JRXML
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f3e693aa-b906-4972-95b4-4a7430cabd45">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="NewData"/>
<subDataset name="subData" uuid="87538cc6-4a9e-4953-acaa-3190030517a8">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="NewData"/>
<queryString language="xPath">
<![CDATA[/sample-data/section[#name='relative-performance']/historic-valuations/valuation-list/valuation]]>
</queryString>
<field name="value" class="java.lang.Integer">
<property name="net.sf.jasperreports.xpath.field.expression" value="value"/>
<fieldDescription><![CDATA[value]]></fieldDescription>
</field>
<field name="date" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="date"/>
<fieldDescription><![CDATA[date]]></fieldDescription>
</field>
</subDataset>
<queryString language="xPath">
<![CDATA[/sample-data/section[#name='relative-performance']/local-market-index/index-value-listindex-value]]>
</queryString>
<field name="value1" class="java.lang.Integer">
<property name="net.sf.jasperreports.xpath.field.expression" value="value1"/>
<fieldDescription><![CDATA[value]]></fieldDescription>
</field>
<field name="date1" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="date1"/>
<fieldDescription><![CDATA[date]]></fieldDescription>
</field>
<detail>
<band height="370" splitType="Stretch">
<lineChart>
<chart evaluationTime="Report">
<reportElement x="0" y="40" width="550" height="290" uuid="9bdc21fd-9b73-4ea9-919e-2c8807153f78"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset resetType="Report"/>
<categorySeries>
<seriesExpression><![CDATA["Estimated capital value"]]></seriesExpression>
<categoryExpression><![CDATA[$F{date}]]></categoryExpression>
<valueExpression><![CDATA[$F{value}]]></valueExpression>
<labelExpression><![CDATA[""]]></labelExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["Local market index"]]></seriesExpression>
<categoryExpression><![CDATA[$F{date1}]]></categoryExpression>
<valueExpression><![CDATA[$F{value1}]]></valueExpression>
<labelExpression><![CDATA[""]]></labelExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</detail>
</jasperReport>
I searched a lot and come to know that In my situation I need to make subDataSource so I did from
How to use multiple xpath datasets on XML datasource using PHP Jasper?
But I'm still getting this error
There are compilation error please fix the design
Field not found:date ---net.sf.jasperreports.xpath.field.expression#95d1b2c
Field not found:date ---net.sf.jasperreports.xpath.field.expression#62032410
I want to make line chart in jasper report then make it pdf in java which is another part but main issue is I'm not able to make a desired PDF which is
In my Netbeans 7.11 application I have an additional separated topcomponent in an editor mode that does not respect the minimum size that I specified using the GUI-builder.
The option for "Respect Minimum Size When Resizing Windows" in the Window System tab of the branding is checked.
My .wsmode file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mode PUBLIC
"-//NetBeans//DTD Mode Properties 2.0//EN"
"http://www.netbeans.org/dtds/mode-properties2_0.dtd">
<mode version="2.0">
<name unique="myTopComponent" />
<kind type="view" />
<state type="separated" />
<constraints>
<path orientation="horizontal" number="0" weight="1" />
<path orientation="vertical" number="0" weight="1" />
</constraints>
<bounds x="150" y="150" width="1200" height="670" />
<frame state="0"/>
<empty-behavior permanent="true" />
</mode>
What am I doing wrong or what am I missing?
I need to pass to my subreport a list of integers which will be used as parameter for a IN statement in my query like this:
SELECT * FROM my_tables WHERE $X{IN, table.id || '', PARAMETER_LIST}
I have tried various syntax to instance a list on my master report but none of them lead to
a functional report ; eg :
<subreportParameter name="PARAMETER_LIST">
<subreportParameterExpression><![CDATA[[1,2]]]></subreportParameterExpression>
</subreportParameter>
Is there a solution to my problem?
I've tried to use $X{IN, attributeName, parameterName} with List component.
The main steps (parameters names are from the sample below):
Declare listParam parameter as java.util.List in main report
Declare quantityParam parameter as java.util.List in subDataset
Make mapping from listParam parameter to quantityParam parameter with help of ArrayList constructor
Add $X{} expression to subDataset query.
The working sample with language property as Java:
<jasperReport ...>
...
<subDataset name="dataset1">
<parameter name="ProductId" class="java.lang.Integer"/>
<parameter name="quantity" class="java.util.List"/>
<queryString>
<![CDATA[SELECT
POSITIONS."DOCUMENTID" AS POSITIONS_DOCUMENTID,
POSITIONS."POSITIONNO" AS POSITIONS_POSITIONNO,
POSITIONS."PRODUCTID" AS POSITIONS_PRODUCTID,
POSITIONS."QUANTITY" AS POSITIONS_QUANTITY,
POSITIONS."PRICE" AS POSITIONS_PRICE
FROM
"PUBLIC"."POSITIONS" POSITIONS WHERE PRODUCTID=$P{ProductId} AND $X{IN, QUANTITY, quantityParam}]]>
</queryString>
<field name="POSITIONS_DOCUMENTID" class="java.lang.Integer"/>
<field name="POSITIONS_POSITIONNO" class="java.lang.Integer"/>
<field name="POSITIONS_PRODUCTID" class="java.lang.Integer"/>
<field name="POSITIONS_QUANTITY" class="java.lang.Integer"/>
<field name="POSITIONS_PRICE" class="java.math.BigDecimal"/>
</subDataset>
<parameter name="listParam" class="java.util.List" isForPrompting="false">
<defaultValueExpression><![CDATA[Arrays.asList("1", "2")]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT
PRODUCT."ID" AS PRODUCT_ID,
PRODUCT."NAME" AS PRODUCT_NAME,
PRODUCT."COST" AS PRODUCT_COST
FROM
"PUBLIC"."PRODUCT" PRODUCT]]>
</queryString>
<field name="PRODUCT_ID" class="java.lang.Integer"/>
<field name="PRODUCT_NAME" class="java.lang.String"/>
<field name="PRODUCT_COST" class="java.math.BigDecimal"/>
...
<detail>
...
<componentElement>
<reportElement x="200" y="2" width="313" height="29"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="dataset1">
<datasetParameter name="ProductId">
<datasetParameterExpression><![CDATA[$F{PRODUCT_ID}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="quantityParam">
<datasetParameterExpression><![CDATA[new ArrayList($P{listParam})]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:listContents height="29" width="313">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{POSITIONS_QUANTITY}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{POSITIONS_PRICE}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
...
</jasperReport>
The sample is also works with report's language property as groovy.
I think that this solution can be applied to subreport.
I can't reach component by id in the included .zul page. I have one main.zul with a controller and I need to get a component in included zul page through the java controller class, but it returns null.
I know the included method creates new id space but is there any way to get this component?
UPDATE
Here is my code:
the main zul page
<?page title="DealerVizard.zul"?>
<?page id="main" ?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./Dealer" ?>
<zk>
<style src="/resources/css/default.css" />
<window id="Dealer" class="index"
apply="com.i2i.prm.controller.IndexController">
<div class="content" width="100%">
<tabbox id="tb" forward="onSelect=onSelect">
<tabs id="tabs">
<tab id="info" label="INFO" />
<tab id="create" label="CREATE" />
<tab id="edit" label="EDIT" />
<tab id="test" label="TEST PANEL(LIST BOX)" />
</tabs>
<tabpanels>
<tabpanel id="DealerInfo">
<include id="DealerInfoContent"
src="View/Dealer/DealerInfo.zul" />
</tabpanel>
<tabpanel id="DealerCreate">
<include id="DealerCreateContent"
src="View/Dealer/DealerCreate.zul" />
</tabpanel>
<tabpanel id="DealerEdit">
<include id="DealerEditContent"
src="View/Dealer/DealerEdit.zul" />
</tabpanel>
<tabpanel id="PagingListBox">
<include id="PagingListBoxContent" // Included here
src="View/TEST/PagingListBox.zul" />
</tabpanel>
</tabpanels>
</tabbox>
</div>
</window>
</zk>
PagingListBox.zul (Included page)
<?page id="list" ?>
<zk>
<grid width="100%">
<columns>
<column label="" />
</columns>
<rows>
<row>
<listbox id="listModel" width="100%" height="100%"
visible="true" span="true" pagingPosition="top" rows="20"
selectedItem="#{DealerController.selected}"
model="#{DealerController.userList}"
forward="onSelect=//main/Dealer.onSelect">
<auxhead>
<auxheader colspan="1">
<textbox
value="#{DealerController.searchUser.name}" maxlength="9"
id="searchCO_ID" forward="onChanging=//main/Dealer.onSearch"
width="100%">
</textbox>
</auxheader>
<auxheader colspan="1">
<textbox
value="#{DealerController.searchUser.surname}" maxlength="21"
id="searchMSISDN" forward="onChanging=//main/Dealer.onSearch"
width="100%">
</textbox>
</auxheader>
<auxheader colspan="1">
</auxheader>
</auxhead>
<listhead>
<listheader label="Name"
sort="auto(UPPER(name))" />
<listheader label="Surname"
sort="auto(UPPER(surname))" />
<listheader label="Delete ?" />
</listhead>
<listitem self="#{each=USERLIST}">
<listcell>
<label value="#{USERLIST.user.name}" />
<textbox
value="#{DealerController.tmpUser.name}" visible="false" />
</listcell>
<listcell>
<label value="#{USERLIST.user.surname}" />
<textbox
value="#{DealerController.tmpUser.surname}" visible="false" />
</listcell>
<listcell>
<button label="Update"
forward="onClick=//main/Dealer.onUpdate" visible="false" />
<button image="icons/edit-delete.png"
label="Delete" forward="onClick=//main/Dealer.onDelete"
width="100%" disabled="true" />
<button label="Save"
forward="onClick=//main/Dealer.onSave" visible="false" />
<button label="Cancel"
forward="onClick=//main/Dealer.onCancel" visible="false" />
</listcell>
</listitem>
</listbox>
<paging id="pagingData" pageSize="20" />
</row>
</rows>
</grid>
</zk>
IndexCOntroller.java
public class IndexController extends GenericForwardComposer {
private List<User> userList = new ArrayList<User>() ;
AnnotateDataBinder binder;
Tabbox tb;
Window Dealer;
private int pageCount=0;
#Override
public void doAfterCompose(Component comp) throws Exception {
// TODO Auto-generated method stub
super.doAfterCompose(comp);
comp.setVariable(comp.getId() + "Controller", this, true);
binder = (AnnotateDataBinder) Dealer.getVariable("binder", true);
System.out.println(Path.getComponent("//list/listModel"));
}
public IndexController() {
// TODO Auto-generated constructor stub
}
}
Normally I wouldn't recommend using Path.getComponent() way to access other components as your application code becomes tightly coupled with your component structure in your view page.
In your case you simplest way is to use AbstractComponent#getFellow(String compId) method so for eg.
Include inc = (Include) Dealer.getFellow("PagingListBoxContent");
Listbox listModel = (Listbox) inc.getFellow("listModel");
System.out.println(listModel);
So in future even if you insert any other component in your ZUML page before your listbox your code will still work.
UPDATE: BTW there was an interesting blogpost on this very topic on ZK blog recently
if your include have id, you can use dollar sign to get the inner components
<zk>
<include id="inc" src="test.zul />
</zk>
test.zul
<zk>
<label id="lab1" value="test1" />
</zk>
you can use "inc$lab1" get the label in test.zul
You can access any component in any other id space using zscript or java. if it is on the same page, but different window then (component B in window A):
Path.getComponent("/A/B");
if it is on a different page then (component B in window A on page P):
Path.getComponent("//P/A/B");
You can find documentation here: http://books.zkoss.org/wiki/ZK%20Developer%27s%20Reference/UI%20Composing/ID%20Space
You can add in your IndexController.java:
...
private Include DealerInfoContent;
...
this way you can access the included component within the parent composer.
(I would suggest to use camelCase ids for it, though).