mpintor Posted July 10, 2012 Share Posted July 10, 2012 Hi there, this is my 1st post here as I'm just trying do use JasperSoft Studio 1.1.1...I'm facing the following issue when I'm trying to give some color to a smiley depending on its value.The smileys are using the Wingdings font (anyone know of another font for smileys ?) and L is sad while J is happy. I just want sad to be displayed in red color and happy in green. /tools/fckeditor/editor/images/smiley/msn/regular_smile.gif Now, I set up a conditional style, names "Statut PEC" as follow : <style name="Statut PEC" forecolor="#00FF00" fontName="Wingdings" isBold="true"> <conditionalStyle> <conditionExpression><![CDATA[new Boolean ( $F{Statut_PEC}.contentEquals( "L" ))]]></conditionExpression> <style forecolor="#FF0000"/> </conditionalStyle> </style>This means that the default color is green except when field "Statut_PEC" is valued to "L" where the color turns to red. It's working fine : I can see green and red smileys.The trouble is... they're all smiling, even the red ones ! (when they should not...).Any idea ?Thanks.Post Edited by mpintor at 07/20/2012 10:11 Link to comment Share on other sites More sharing options...
mpintor Posted July 16, 2012 Author Share Posted July 16, 2012 Well... let's forget the smileys and say you'd like to see OK and KO instead, depending on the "status" field value that could be J for OK and L for KO.[EDIT] I mean, so far I see OK and OK, instead of KOWhat the conditional style should look like ?TIA. Post Edited by mpintor at 07/16/2012 15:42 Link to comment Share on other sites More sharing options...
Massimo Rabbi Posted July 18, 2012 Share Posted July 18, 2012 Hi,I tested conditional style in both JSS 1.1.1 and the new one JSS 1.1.2.Everything seems to be working fine for me.In my dummy case scenario I have a xls data source and in the detail band I print usernames read from the excel source file.I've put a condition that print with a different color only when the $F{NAME} is equals to "User1".So this is my style that is actually working fine.<style name="Statut PEC" forecolor="#00FF00" isBold="true"> <conditionalStyle> <conditionExpression><![CDATA[new Boolean ( $F{NAME}.equals("User1"))]]></conditionExpression> <style forecolor="#FF0000"/> </conditionalStyle></style>When I preview, I can see all username with the default color and the "User1" with a different one.From you posts it seems that the foreground color generation is correct. What seems to be wrong is the textual content. Are you sure the element you are applying the style is correct and it is not for example a static text you put there for test? In my case in fact I applied the style to a text field which expression is $F{NAME}.Regards,Massimo. Link to comment Share on other sites More sharing options...
mpintor Posted July 19, 2012 Author Share Posted July 19, 2012 Hi, thanks for replying Massimo (nice pic for your avatar !)No, I was not using static text, but the "Statut_PEC" field values. Anyway I switched to iReport 4.6.0 where conditional styles were (kind of) easier to set up. Link to comment Share on other sites More sharing options...
Massimo Rabbi Posted July 19, 2012 Share Posted July 19, 2012 Ok. Just in case, would you please attach your jrxml, that one for printing OK / KO.I would like to give a try and see why in your JSS 1.1.1 it doesn't work.Regards,Massimo.P.S: when you say that in iReport it's more easy what do you mean? We're open to suggestion on improving JSS ;-)Post Edited by mrabbi at 07/19/2012 07:34 Link to comment Share on other sites More sharing options...
mpintor Posted July 19, 2012 Author Share Posted July 19, 2012 Massimo, here's the "style" section : <style name="Statut PEC" forecolor="#000000" fontName="SansSerif" isBold="true"> <conditionalStyle> <conditionExpression><![CDATA[EQUALS($F{Statut_PEC},"KO") ? true : false]]></conditionExpression> <style forecolor="#FF0000" fontName=""/> </conditionalStyle> <conditionalStyle> <conditionExpression><![CDATA[EQUALS($F{Statut_PEC},"OK") ? true : false]]></conditionExpression> <style forecolor="#00FF00" fontName=""/> </conditionalStyle> </style>And the "textField" section : <textField evaluationTime="Report" pattern="" isBlankWhenNull="false"> <reportElement uuid="ad339782-97ee-42b0-a6ea-9eb8cbf35f44" style="Statut PEC" x="345" y="0" width="46" height="15"/> <box> <pen lineWidth="1.0" lineColor="#000000"/> <topPen lineWidth="1.0" lineColor="#000000"/> <leftPen lineWidth="1.0" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineColor="#000000"/> <rightPen lineWidth="1.0" lineColor="#000000"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font fontName="SansSerif" size="12" isBold="true" pdfFontName="" pdfEncoding=""/> </textElement> <textFieldExpression><![CDATA[$F{Statut_PEC} ]]></textFieldExpression> </textField>This gives me OK and OK, instead of OK and KO.Hope this helps. Link to comment Share on other sites More sharing options...
Massimo Rabbi Posted July 19, 2012 Share Posted July 19, 2012 Hi,looking at your source jrxml seems that the problem is in the evaluation time attribute of your text field.Right now it is set to "Report"... I don't know if it is set to this value for a particular reason, but to obtain what you want it should be set to "Now".I tried on my test report and setting the evaluation time property to report on the field, I was able to reproduce your problem.I got (with evaluation time Report):User4User4User4User4While I should have (with evaluation time Now)User1User2User3User4So try to fix the property. It should work ;-)Regards,Massimo. Link to comment Share on other sites More sharing options...
mpintor Posted July 20, 2012 Author Share Posted July 20, 2012 That was it Massimo ! Thanks for your help. Link to comment Share on other sites More sharing options...
Massimo Rabbi Posted July 20, 2012 Share Posted July 20, 2012 Hi,glad you were able to solve the problem.One last question: some posts ago you said that you "switched to iReport 4.6.0 where conditional styles were (kind of) easier to set up.". Could you please clarify what are the main differences you find out when defining the style? Suggestions on how to improve and what should looks like. It's always good to have feedbacks.Thanks in advance.Regards,Massimo. Link to comment Share on other sites More sharing options...
mpintor Posted July 20, 2012 Author Share Posted July 20, 2012 Well, it's just that when you start using JSS you just find far less informations on the Web on "how to do this and that" than with iReport.I has not much to do with Studio's quality and functionnalities, it's just, you know, when you don't have much time to spend to find out solutions for doing this or that. Since iReport was on the place large before, it's then kind of easier to sort these things out faster.Sorry if my sentence was interpreted in another way. Link to comment Share on other sites More sharing options...
Massimo Rabbi Posted July 20, 2012 Share Posted July 20, 2012 Hi,thanks for the reply and explaination.What you said it's true. There are tons of tutorials and documentation about iReport. Unfortunately right now documentation/tutorials for Jaspersoft Studio are still missing.Next weeks/months we will do our best to write down a set of tutorials and articles that will go from beginner to advanced user level. Our effort will be initially to provide tutorials similar to the actual ones linked in the iReport project home page.So stay tuned and check the web site home page next weeks.Regards,Massimo. 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