开发者

Hide multiple detail bands

开发者 https://www.devze.com 2023-03-06 00:56 出处:网络
I have a report with a subreport to add a logo to the main report. In this subreport I have 2 detail bands to support two differently sized logos; one is long and the other is about a 3rd a long (widt

I have a report with a subreport to add a logo to the main report. In this subreport I have 2 detail bands to support two differently sized logos; one is long and the other is about a 3rd a long (width). kind of like this...

...........................
|---------logo------------|
address 1, address 2
...........................
|__logo__|    address 1
|        |    address 2
...........................

Between the 1st and 2nd row of periods is the Details 1 band and between the 2开发者_JAVA技巧nd and 3rd is Details 2 band.

I am trying to use the "Print When Expression" to toggle the 1st or 2nd Detail band depending on the value of $F{LogoName}.

Detail 1 band:

new Boolean($F{LogoName}=="acompanyname")

Detail 2 band:

new Boolean($F{LogoName}!="acompanyname")

but it does not work.

Have also tried these:

(($F{LogoName}=="acompanyname")?Boolean.TRUE:Boolean.FALSE)
(($F{LogoName}!="acompanyname")?Boolean.TRUE:Boolean.FALSE)

The $F{LogoName} is "acompanyname".

Every time I run the report only Detail 2 band shows. I can not get details 1 to show at all and I am not getting any error messages.

Any help is welcome.

Thank You


Try this:

$F{LogoName}.equals( "acompanyname" )

In Java, the equality operator (==), when used on objects, checks to see if they are the same reference to the same object. This one catches all report developers without a lot of Java programming experience. You could write:

$F{LogoName} == $F{LogoName}

That would return true, as you expect, because both objects on either side of the equals operator are the same. Consider the following:

public class T { 
  public static void main( String args[] ) {                                    
    String s1 = "hello";                                                        
    String s2 = (new StringBuilder( s1 )).toString();                           

    System.out.println( s1 );
    System.out.println( s2 );
    System.out.println( s1 == s2 );
  }
}

This prints:

hello
hello
false

The values of the strings objects are the same, but the references to the strings are different. The equals operation compares the references, not the values.

0

精彩评论

暂无评论...
验证码 换一张
取 消