prinsesajade Posted April 8, 2009 Share Posted April 8, 2009 hi!it's me again..do u have any idea how i can do this?i have this report that will generate a payroll..one of the fields is taxCode (Integer)..here is my question..say for example the value of taxCode for this certain employee is 20 i have to replace this value with a constant that wil be coming from a java class (TaxCategoryConstant)..here is my class:so if the employee's taxCode is 20, S should be displayed in the result..have any idea on this?thank you!Code:public class TaxCategoryConstants { public static final int Z=0; public static final int S=20; public static final int HF=25; public static final int ME=32; public static final int HF1=33; public static final int HF2=41; public static final int HF3=49; public static final int HF4=57; public static final int ME1=40; public static final int ME2=48; public static final int ME3=56; public static final int ME4=64;} Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted April 8, 2009 Share Posted April 8, 2009 You have 2 options:1. Write an helper class to performe a decode:MyHelperClass.decode( $F{taxCode} )2. Use a big switch of if/else. The basic syntax is (<condition>) ? <exp on true> : <exp on false>That means that you would have something like:($F{taxCode}.intValue() == 0) ? "Z" : ( ($F{taxCode}.intValue() == 20) ? "S" : ( ($F{taxCode}.intValue() == 25) ? "HF" : [.....] ( ($F{taxCode}.intValue() == 56) ? "ME3" : "ME4" ) ) ) [....] ))it is long, it is not very much readable, but it works (you are in charge to fill the [...] sections and fix the parenthesis...)Giulio Link to comment Share on other sites More sharing options...
prinsesajade Posted April 14, 2009 Author Share Posted April 14, 2009 hi!thanks for ur reply..maybe i wud try the second option..i was trying to do the helper class but i can't add my bean to my datasources..thanks for ur help! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now