Jump to content
Changes to the Jaspersoft community edition download ×

TextField Expression - register as blank problems


diego_scunha

Recommended Posts

Good afternoon,

I'm having a problem in a report where I have a $ F {field} in which you can receive a value from database (String), null or a blank ("")...

When this field are equals to null or correct value (I mean "abc", "xyz"), it executes the expression on Text field expression and print the diseired value. But when the value is blank ("") the expression aren't executed.

Expression on Text Filed expression: ($ F {field}. trim (). equals ("")? "Not reported": $ F {field})

I've tried changing the expression to: ($ F {field}! = null? ($ F {field}. trim (). equals ("")? "Not reported": $ F {field}): "No informed ")
But it doesn't worked out ...

I've tried using Blank When Null flag with no success.

Any suggestions?

Best regards,

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

There are too many extra blank spaces in your expression, and some of them do affect the correct syntax.

Try with this one:

($F{field} != null ? ($F{field}.trim().equals ("") ? "Not reported" : $F{field}) : "No informed ")

Hope this helps,

sanda



Post Edited by shertage at 02/03/2011 11:06
Link to comment
Share on other sites

Ok, then.

So, I understand that when your field value is "abc", it gets printed out correctly. When the field value is null, then "No informed " is printed instead, and it works as expected.

The only problem appears when the field value is "", or " ", or "     ", etc. What is printed out in these situations? Could you post a printscreen here? I tried the expression on a local sample and the "Not reported" fragment was printed out.

Since the expression is well formed, then is possible that the field value is not actually an empty String, perhaps it may contain some hidden chars.

Hope this helps,

sanda

Link to comment
Share on other sites

Hi Sanda,

 

In order to prevent invalid chars, I executed an SQL like that: UPDATE my_table SET my_field = '' WHERE ...

 

With that one, Im pretty sure that there is no invalid char.

 

I don't know how to attach files on this forum, so I've shared the prnt screen image from iReport on the following link: http://tinypic.com/r/5wbbr6/7

 

Best regards,

Link to comment
Share on other sites

Hi again,

This print screen shows only how you set the field expression in iReport, and we already know that it's well formed. But let's see what happens when you run the report. Try to preview the report in iReport, and post a printscreen of the generated report, in order to see what is printed when field values are empty.

You can attach the printscreen here if you save it as image file first, and then fill in the Attachment1 textbox available on this page when you are in edit mode.

Regards,

sanda

Link to comment
Share on other sites

Hi,
It's attached here an printscreen with report area and a result query from database (raw data).

The null fields in database are printed like "Não Informado" (Not informed - portuguese) and the "" fields print blank on report (This is the problem , I would like to get the same message here ("Não informado")).

ps: I've hide some information once they are private.

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