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

print when expression will solve my problem?how?


yogarajkhanal

Recommended Posts

hi,

in my report template i have static text field for the labels

and correspoding name filed for the parameter that i will pass from my program.

So my use case is like this

First Name:Yogaraj

Middle Name:Null

Last Name:Khanal

 

I have to remove the static text field Middle Name when the value is null can you please tell me how do i achieve it?

I saw something called print when expression in the properties of static text i am not sure if that will solve it ?can you please give me small example of print when expression if that solves it?

Thanks,

Yogaraj

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

hi Yogaraj,

I can give u one simple example,
say there is a parameter called "OFFICE_ID", If u dont want to display one static text in your report when this "OFFICE_ID" parameter is null, Then do the following..

1. In printWhenExpression give this expression

            new Boolean($P{OFFICE_ID}==null) and also
              
           Set  RemoveLineWhenBlank is true.
 

The Code should be like the following,

 <staticText>
                    <reportElement x="196" y="0" width="100" height="20" isRemoveLineWhenBlank="true">
                          <printWhenExpression><![CDATA[new Boolean($P{OFFICE_ID}==null)]]>     </printWhenExpression>
                    </reportElement>
                    <textElement/>
                    <text><![CDATA[static text]]></text>
   </staticText>

 

Please try out this.

 

Thanks,
Keerthi

Link to comment
Share on other sites

Hi Keerthi,

I tried as below but didn't work.Anything I am doing wrong here?

 

<staticText>

<reportElement

x="17"

y="286"

width="420"

height="19"

key="staticText-19"

isRemoveLineWhenBlank="true">

<printWhenExpression><![CDATA[new Boolean($P{rtf}==null)]]></printWhenExpression>

</reportElement>

<box></box>

<textElement>

<font fontName="Times New Roman" pdfFontName="Helvetica-Bold" size="12" isBold="true"/>

</textElement>

<text><![CDATA[Refusal to File Reasons:]]></text>

</staticText>

Link to comment
Share on other sites

Have you ever spent some time in searching the forum before doing wild posts!?!??!?!? /tools/fckeditor/editor/images/smiley/msn/whatchutalkingabout_smile.gif

 

Anyway:

Take a look at the Attributes "RemoveLineWhenBlank " and also at "PositionType"

set "RemoveLineWhenBlank" of your elements that should be removed to "true" and "PositionType" of every element that should move upwards to "float".

There are also some samples provided with full JasperReports Download package that helps a lot.

Just my two cents

C-Box

Link to comment
Share on other sites

I am sorry I should have tried all options first.

Its getting 5 and i wanted to wrap my work so tried getting feedback from user community.

Anyway figured that out before you send me the suggestions.

I was opening new thread with the hope that if new users find the similar problems they will have more references.

I will read next time before I post.

Thanks for your suggestion.

Yogaraj

Link to comment
Share on other sites

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