rasikow Posted January 14, 2009 Share Posted January 14, 2009 Hi all,I am fetching data from database.when field comes as "1", i want to display as "India"when field comes as "2", i want to display as "USA"when field comes as "3", i want to display as "Japan"when field comes as "4", i want to display as "China"...etc.How to do this in jrxml file? your swift reply shall be highly appreciated.Thanks in advance. - Gnaniyar Zubair Link to comment Share on other sites More sharing options...
vickirk Posted January 15, 2009 Share Posted January 15, 2009 There are two easy ways: * Change your query to do this, assuming you don't have table with country codes to join on to you could use a database specific query, e.g. in oracle use a decode ala DECODE(field, 1, 'India', 2, 'USA', 3, ...)* Or a more portable way try using an expression like $F{f}.intValue() == 1 ? "India" : $F{f}.intValue() == 2 ? "USA" : $F{f}.intValue() == 3 ? "Japan" : "China"If the above is something you need to do often I'd create a utilty method in java and add it to the class path.Personally, if it was possible, I'd create a table for enumerated values and change the query to a join to pull in the country name, e.g.SELECT p.name, c country_name FROM person p, country c WHERE p.country_id = c.country_idRegards, Vic Link to comment Share on other sites More sharing options...
drlaz Posted January 15, 2009 Share Posted January 15, 2009 Another method. Declare an array in a Scriptlet, then reference the appropriate index Link to comment Share on other sites More sharing options...
rasikow Posted January 15, 2009 Author Share Posted January 15, 2009 Dear friend, Thanks for your swift reply which would be most helpful to me. I will try as you have told. Thanks once again. - Gnaniyar Zubair Link to comment Share on other sites More sharing options...
rasikow Posted January 15, 2009 Author Share Posted January 15, 2009 i dont know how to use scriptlet.. if you dont mind, can you give more explanation on this. Thanks in advance. Link to comment Share on other sites More sharing options...
rasikow Posted January 15, 2009 Author Share Posted January 15, 2009 how to display images depends on value? For example, if i get 1, 1 stars(img) if 2, 2 stars, if 3, 3 stars blah..blah... how to write code for this in jrxml? Thanks in advance. Link to comment Share on other sites More sharing options...
rasikow Posted January 21, 2009 Author Share Posted January 21, 2009 Hi all, how can i give 2 conditions in printwhenexpression?For example, if value is 1, that field should print, for that i have written this coding in printwhenexpression:$F{value} = 1But i want to check 2 conditions like if value is equal to 1 and 2, For that can i write like this?$F{value} = 1 || $F{value} = 2 ( But i got the error that i cant use this OR symbol || in jrxml).. Then How to write?Thanks in advance - Gnaniyar Zubair 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