Jump to content
JasperReports Library 7.0 is now available ×

page break before subreport


2005 IR Help

Recommended Posts

By: Steinberger Jonas - steinberger

page break before subreport

2004-01-22 07:54

Hi

 

Im using jasper for the principal wysiwyg .. GUI to paper. So I create the design direct over my program logic. To arrange all elements in there predefined position I use for each data dependent GUI comonent its own subreport. In cases where i have a tabbed folder I intend to start with a new page. The content can be only a chart. So the mentioned tricks with groupbreak and so on wont work. Does anyone have a solution how I can create at a specific point the requested pagebreak.

 

Thaks in advance

 

Jonas

 

 

 

 

By: Teodor Danciu - teodord

RE: page break before subreport

2004-01-24 11:52

 

Hi,

 

Groups are the only way to force page breaks.

I think it can be done in your case too.

You just need to find a way to distribute your

subreports in different bands probably usnig multiple

dummy groups.

 

I hope this helps.

Teodor

 

 

 

 

 

By: Steinberger Jonas - steinberger

RE: page break before subreport

2004-01-27 05:11

Thaks Teodor

 

I've tested your suggestion, but probabely I did something wrong.

 

In my master report I've added a dummy group

StartNewPage = true

MinHeightToStartNewPage = 0

 

and into this group a band, in which the subreport is embedded (previous place was the detail-band).

 

I've tried it with and without group-expression, but I got the same result: No pagebreak. Is it possible that I lack of some information? When the subreport-content is an image I've placed it in the title-band, data-content in the detail-band.

Placed the subreport in the masters detail, it was possible to influence the order by the value of y. Is now the sequence given from the order in which the groups will be added?

 

An other effect was, that I had to increase the memoryspace when using groups to embed my subreports, what seams strange.

 

And at least I can't explain to me the effect, that when the chart-image would start printing on the remaining part of a page and there is not enough space then the expected pagebreak is forced, but the chart-image is then printed twice on the new page. Is that effect a bug or can a specific configuration avoid this problem?

 

Thanks for your help.

 

 

Jonas

 

PS: Teodor, based on my experience with different applications and requirements for printing and archiving in banking, I would like to discuss some ideas. What is the platform to place my thougts? Is such an initiative expected or are you at the point, that you say: "thats it, thats all, thats jasper"?

For example: It's a difference, if you intend to use the reporting for reports in the meaning of your exemple "first jasper" than if your inplementation will support customer output which will be concatinated at the end form a serie of documents to one document with postal information and bar coding for a letter packing streat (Verpackungsstrasse in German). For that use it would be helpful to store the pdf's in a archiv.. and so on. For that question its enough for me to know are you jasper's interested, to raise the scope or not. Who and on what schedule that could be is an other thing.

 

 

 

 

By: Steinberger Jonas - steinberger

RE: page break before subreport

2004-01-30 01:44

Hi Teodor or anybody who is able to answer

 

Based on the experience of my previous described situation I've taken a look in jaspers source. Groupbreaks like Teodor has suggested wont help because in the actual solution groups are executed hierarchically. That means, if I have a non data driven group, the groupfooters are executed at the verry end of the report like this:

 

groupHeader1

Subreport1..

groupHeader2

Subreport2..

groupHeader3

Subreport3..

groupHeader4

Subreport4..

 

groupFooter4

groupFooter3

groupFooter2

groupFooter1

 

only the groupFooter sets "isNewPage = false" so that the next group will execute the pagepreak. in the method:

 

private void fillGroupHeader(JRFillGroup group) throws JRException

..

if ( (group.isStartNewPage() || group.isResetPageNumber()) && !isNewPage )

 

And for others hwo read this message: To get a pagebreak you nead always am groupFooter band otherwise jasper never resets the "isNewPage" flag.

 

 

So the expected pagebreak after a subreport will not take part at its place.

 

Is there a way, to tell the group that after its execution there is a databreak ore something equivalent? If not, then jasper would have been exdended that it has an alternative modus to execute groups like that:

 

groupHeader1

Subreport1..

groupFooter1

 

groupHeader2

Subreport2..

groupFooter2

 

groupHeader3

Subreport3..

groupFooter3

 

groupHeader4

Subreport4..

groupFooter4

 

Please answer my question. I dont like to extend the functionality in my local environment. If there is a way to gide jasper by correct confuguration please let me now, otherwise I would suggest you a solution what could be implemented with no effect to the current functionality.

 

Thanks and please dont let me hang on.

 

Jonas

 

jonas.steinberger@qbic.ch

 

 

 

 

By: Teodor Danciu - teodord

RE: page break before subreport

2004-01-30 05:09

 

Hi,

 

First, I want to assure you that even if don't have

a group footer, the page break should work for

the following group ruptures.

This is because the report filler uses an empty band

with height zero as a group footer even if you don't

have one in your design.

 

As for the solution to your problem, you could either

put all the subreports inside the same group header

band and use <printWhenExpression> to select the

one that should print.

This could work if you know the number of subreports

and if you use a dummy data source (JREmptyDataSource) with as many records as the

number of subreports that you have.

The master dummy group would be based on the

REPORT_COUNT variable to break with every record.

 

A second solution would be to put a single subreport

element inside the detail of the master and supply

the filename for the subreport and other subreport

data as fields in a custom data source passed to

the master that would have one record per subreport.

 

I hope this helps.

Teodor

 

 

 

 

 

By: Steinberger Jonas - steinberger

RE: page break before subreport

2004-02-03 12:29

Hi Teodor

 

I've tested your advice but there is still a problem:

 

Based on your principle that you expect groups to be hierarchically printed, you reset the flag "hasChanged" from the assingned level do all child levels.

That leads to the consequence that I don't have a real control over my groups in sequence because a group, that is lower then my actual detail that controls printing of my subreport is not printed but effects a pagebreak if its level schould break.

 

My current group control Code:

 

subreportList.add(String.valueOf(designMap.size()));

 

JRDesignExpression grpExpr = new JRDesignExpression();

grpExpr.setValueClass(java.lang.Boolean.class);

String exprText = "new Boolean($V{REPORT_COUNT}.intValue() == "+designMap.size()+")";

grpExpr.setText(exprText);

group.setExpression(grpExpr);

 

JRDesignExpression prtWhenExpr = new JRDesignExpression();

prtWhenExpr.setValueClass(java.lang.Boolean.class);

String expText = "new Boolean($V{REPORT_COUNT}.intValue() == "+designMap.size()+")";

prtWhenExpr.setText(expText);

jrHeaderBand.setPrintWhenExpression(prtWhenExpr);

 

Do you have any idea how I can avoid this effect?

 

In my temporary solution I've fixed it as shown below but it does not really fit to your consequent principles

 

 

private void fillGroupHeaders(boolean isFillAll) throws JRException

{

if (groups != null && groups.length > 0)

{

for(int i = 0; i < groups.length; i++)

{

if(isFillAll)

{

this.fillGroupHeader(groups);

/* if ("sequence".equals(groups.getName().substring(0,8))){

byte evaluation = (isFillAll)?JRExpression.EVALUATION_DEFAULT:JRExpression.EVALUATION_OLD;

this.fillGroupFooter(groups,evaluation);

} */

}

 

Thanks for your answer

 

Jonas

 

 

 

 

By: Steinberger Jonas - steinberger

RE: page break before subreport

2004-02-07 16:55

Hi Teodor

 

Just that! Can I expect an answer or do I have to live with it. I don't like to have a solution that differs from the standard. So if I can contribute to a solution in the standard of jr for subreports in sequence as an aditional modus to the cascaded solution, pleas let me know.

 

Thanks for any answer

 

Jonas

 

 

 

 

By: Teodor Danciu - teodord

RE: page break before subreport

2004-02-14 05:27

 

Hi,

 

I don't see why none of the two solutions I suggested

in my last post do not work.

You are talking about some group hierarchy,

but in those solutions I was talking about a single

group. No multiple groups anymore.

 

Thank you,

Teodor

 

 

 

 

 

By: Steinberger Jonas - steinberger

RE: page break before subreport

2004-01-30 20:03

Teodor

 

Cool architecture, complements. I've catched it.

 

Thanks

 

Jonas

 

Just to know, could you answer my question in the 2nd message. I'm not ready right now to see what's really missing from my point of view. But I would know where I can place effectivly ideas, not just for fun. (jonas.steinberger@qbic.ch)

 

 

 

 

 

 

By: Steinberger Jonas - steinberger

RE: page break before subreport

2004-02-16 15:25

Hi Teodor

 

If I have all subreports in the same HeaderBand(your first suggestion) or all are breaking with the changing detail (socond suggestion), all subreports have a pageBreak. But I want specific subreports to have a pagebreak. That’s why I have used multiple groups. If you intend to support me for my problem, what would be great, then go on in my explanations. Otherwise thanks. But I think, that I’m not the only one with this requirement.

 

To the solution like I’ve tried to implement it:

I have added for each subreport a specific group with its own Expression to compare the detail_no (REPORT_COUNT)

To avoid that more groups will be printed in one band I’ve added a PrintWhenExpression in the headerBand of its group.

 

But adding of groups has the consequence in the horizontal- or vertical-filler of a cascading handling

 

group_1

group_2

group_3

...

 

So if I set a “page break” to group_2, all child-groups (group_3, .. )inherit the flag "hasChanged". The code in

 

private void fillGroupHeaders(boolean isFillAll) throws JRException

 

....

if (groups.hasChanged())

{

this.fillGroupHeader(groups);

}

 

 

executes for each of the "hasChanged" groups (group_2, group_3,.. ) the method fillGroupHeader and there the it

 

if ( (group.isStartNewPage() || group.isResetPageNumber()) && !isNewPage )

{

fillPageBreak(...

 

performs for each of this groups "fillPageBreak".

 

In my solution for example I would like to have a “page break” in group_2, group_7, group_11. That’s not possible by using the current handling.

 

My suggestion if there is no other way:

On the page-setup (<!ATTLIST jasperReport...) we can set a parameter what controls the handling of groups in the fill process. You would have to implement the solution and the parameter and I could test it. Default value specifies the current modus.

something like that:

cascaded (current modus)

or

sequential (new)

 

 

 

My implementation in combination with your suggestions is like that:

 

For each group I've added a detail in the Datasource of the Masterreport as following

detail_1 for subreport_1

detail_2 for subreport_2

detail_3 for subreport_3

....

 

Based on that I was able to control the expressions by using "REPORT_COUNT"

 

MasterDesign

Parameter (DatasourseSubreport_1)

Parameter (Subreport_1)

design.addGroup(Group_1)

(Group_1

setExpression(..REPORT_COUNT = 1..)

group.setGroupHeader(jrHeaderBand_1);

jrHeaderBand_1

jrHeaderBand_1.setPrintWhenExpression(..REPORT_COUNT = 1..)

jrHeaderBand_1.addElement(Subreport_1)

Subreport_1 setExpression(...DatasourseSubreport_1...

setDataSourceExpression(...DatasourseSubreport_1...)

design.addGroup(Group_2)

(Group_2

setExpression(..REPORT_COUNT = 2..)

group.setGroupHeader(jrHeaderBand_2);

jrHeaderBand_2

jrHeaderBand_2.setPrintWhenExpression(..REPORT_COUNT = 2..)

jrHeaderBand_2.addElement(Subreport_2)

Subreport_2 setExpression(...DatasourseSubreport_2...

setDataSourceExpression(...DatasourseSubreport_2...)

design.addGroup(Group_3)

(Group_3

setExpression(..REPORT_COUNT = 3..)

group.setGroupHeader(jrHeaderBand_3);

jrHeaderBand_3

jrHeaderBand_3.setPrintWhenExpression(..REPORT_COUNT = 3..)

jrHeaderBand_3.addElement(Subreport_3)

Subreport_3 setExpression(...DatasourseSubreport_3...

setDataSourceExpression(...DatasourseSubreport_3...)

..

 

 

 

 

Subreport_1Design

Parameter (DatasourseSubreport1)

..

 

Subreport_2Design

Parameter (DatasourseSubreport2)

..

 

Subreport_3Design

Parameter (DatasourseSubreport3)

..

 

 

If you still have a solution for my problem by using the current functionality, it would be great.

 

Thanks a lot Teodor

 

Jonas

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...