Jump to content
Changes to the Jaspersoft community edition download ×

how to create sub datasource


2004 IR Help

Recommended Posts

By: HSL - lhshyong

how to create sub datasource

2005-08-13 09:55

dear all

 

here my xml source.

 

<stock>

<book>

<title></title>

<price></price>

<author></author>

<author></author>

<author></author>

</book>

<book>

<title></title>

<price></price>

<author></author>

</book>

<book>

<title></title>

<price></price>

<author></author>

<author></author>

</book>

</stock>

 

I create datasource for my master report with

mysource = new JRXmlDataSource("source.xml","/stock/book"); and it work.

 

now i try to create sub datasource for the subreport with

mysource.subDatasource("author") but it return JRException.

 

 

what should i put in the subDatasource string ? i try with * , / , // ... all return error..

 

Please help, Thanks in advance

 

 

 

 

 

 

By: jorge - sirion_oef

RE: how to create sub datasource

2005-08-13 15:35

this class uses the XPAth sintax

 

http://www.zvon.org/xxl/XPathTutorial/Output/example1.html

 

 

 

 

By: HSL - lhshyong

RE: how to create sub datasource

2005-08-13 20:37

Hi,

 

Thanks for you, that a good tutorial for me.. but i still cant get it.. i keep get this when i enter any syntax

 

net.sf.jasperreports.engine.JRException: No node available. Iterate or rewind the data source.

 

Now i got node list with "/stock/book", i try to create the "/stock/book/author" list base on the node list before. but i didnt work

 

 

 

 

By: Lucian Chirita - lucianc

RE: how to create sub datasource

2005-08-15 00:45

Hi

 

At which point are you trying to create the sub datasource? Posting your report design would help..

 

Regards,

Lucian

 

 

 

 

By: jorge - sirion_oef

RE: how to create sub datasource

2005-08-15 08:56

try creating the subdatasource before use the datasource

 

 

 

 

By: HSL - lhshyong

RE: how to create sub datasource

2005-08-15 18:57

Hi, here is my code

 

JRXmlDataSource jrsource = new JRXmlDataSource("book.xml","/stock/book");

 

i can use this source very weel, it return all the 'book' node in the list.

 

but now i need to select the 'author' node within the 'book' node, i try to create a sub datasource and pass it to sub report.

 

 

JRXmlDataSource subJRsource2 = subJRsource.subDataSource("/stock/book/author");

JasperPrint subPrint = JasperFillManager.fillReport( subReport,subMap,subJRsource2);

 

but it return net.sf.jasperreports.engine.JRException: No node available. Iterate or rewind the data source

no matter i pass in what string as parameter to subDatasource method, it also return this error..

 

I think i miss out some thing there.

 

 

 

 

By: Lucian Chirita - lucianc

RE: how to create sub datasource

2005-08-16 00:08

You should use subDataSource("author").

 

Are you iterating the master data source before calling subDataSource? You need to call next() on jrsource so that you have a context node when creating the sub datasource.

 

HTH,

Lucian

 

 

 

 

By: HSL - lhshyong

RE: how to create sub datasource

2005-08-16 01:20

Hi, then how to call next() in the ireport..?

 

after i call next() once , there is no exception but

it say document is no page..

then i try with call next() twice.. still same..

 

 

 

 

 

By: Lucian Chirita - lucianc

RE: how to create sub datasource

2005-08-16 01:39

You shouldn't call next() explicitly. It gets called when before the detail band is rendered. If your subreport is inside the detail band, it should work fine. Post your design if it doesn't work.

 

Also, you should use subDataSource("book/author").

 

HTH,

Lucian

 

 

 

 

By: HSL - lhshyong

RE: how to create sub datasource

2005-08-16 02:25

Hi, its work !!

 

 

Actually i think i also try before this but dont know why didnt work..

 

Just now my subreport put in the form header and it didnt work.. Then i move to details band. suddenly work !!! amazing..

 

then i try move back to header again.. still working .. i also dont know what the problem.. weird..

 

Anyway, dont care, thansk a lot lot lot.. i find this for 5 days already. Thanks again

 

 

 

 

 

 

By: HSL - lhshyong

RE: how to create sub datasource

2005-08-16 00:52

Hi, thanks a lot..

 

I will check it out.;)

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...