2001 JI Open Discussion Posted August 17, 2006 Share Posted August 17, 2006 By: Joseph Wu - thwu Help! string selecting on expression 2002-10-27 22:49I would like to dynamic selecting string on textfields, for example: <txetField> if $F{Grade}.floatValue > 90 return String("A") else if ${Grade}.floatValue > 80 & ${Grade}.floatValue <= 90 return String("B") </textField> Or, can I create a custom class and function to execture selection statement like, <textField> myClass.myFunction{$Grade} </textField> where my.Class.myFunction(Stirng Grade){ if (Grade > 90){ return String("A"); }else if (Grade > 80 & Grade <= 90){ return String("B"); } } Please help, Thanks! By: Giulio Toffoli - gt78 RE: Help! string selecting on expression 2002-10-28 00:46I have make the same for printing a date in a my custom manner. I have writed a class MyDate that expose a static mehtod like String formatMyDate(java.util.Date date) The textfield expression was: formatMyDate( $F{DATE} ) and set the class of field to java.lang.String It works fine. Giulio mypackage.maysubpackage.MyDate. By: tihua - meggie RE: Help! string selecting on expression 2002-10-28 08:31how could we let the application know your MyDate class? if we put it in the lib or jar under tomcat, will it recognize? or we have to do some special configuration? By: Teodor Danciu - teodord RE: Help! string selecting on expression 2002-10-28 12:29 Hi, Question: How do you let your Web application know any of your classes? Response: You either put them in the /WEB-INF/classes directory of your Web application or in JAR that you place under /WEB-INF/lib Of course, if you insist, you could place the JAR under the /lib directory of Tomcat, but I don't think anybody would recommend you to do that. JasperReports can use any class that your Web application can use. You only have to make sure that in the report expressions you use the complete name of the class, including the package (com.mypackage.MyClass). I hope this helps. Teodor By: Teodor Danciu - teodord RE: Help! string selecting on expression 2002-10-28 12:33 Hi, It looks like you already know the solution. Why didn't you try it? Go for the custom class! You could also use imbricate conditional operators (?:), just like you would normally do in a very complex Java expression. The custom class is more appropriate as you can easy debug you code. Good luck! Teodor 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