sebastianr Posted February 27, 2008 Share Posted February 27, 2008 Hi, I have the below snippet in my report xml. <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false"> <reportElement x="870" y="67" width="189" height="20" forecolor="#00AAAA" key="textField" /> <textElement textAlignment="Right" /> <textFieldExpression class="java.lang.String"> <![CDATA["Page " + String.valueOf($V{PAGE_NUMBER})]]> </textFieldExpression> </textField> I am getting this exception. 1. Syntax error on token "{", delete this token value = (java.lang.String)("Page " + String.valueOf($V{));//$JR_EXPR_ID=21$ ^ since i am using velocity, i modified the above snippet like below then it is working fine. <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false"> <reportElement x="870" y="67" width="189" height="20" forecolor="#00AAAA" key="textField" /> <textElement textAlignment="Right" /> #set( $pageno = '$V{PAGE_NUMBER}' ) <textFieldExpression class="java.lang.String"> <![CDATA["Page " + String.valueOf($pageno)]]> </textFieldExpression> </textField> is this anything related jasper or velocity that i am using? What i have done is, i have prepared a .jrxml and i renamed it as .vm for velocity use. is this causing problem? Link to comment Share on other sites More sharing options...
lucianc Posted February 29, 2008 Share Posted February 29, 2008 Velocity uses $ for variables. If you want to get proper JRXML output form velocity, you'll have to escape $ characters that need to be preserved as is:Code:"Page " + String.valueOf($V{PAGE_NUMBER} Otherwise, Velocity would produce invalid JRXML files. Regards,Lucian Link to comment Share on other sites More sharing options...
thevoice Posted April 22, 2008 Share Posted April 22, 2008 Hello Lucianc,Can you tell me how to escape '$' characters to get proper .jrxml output from the velocity?Actually i don't understand how to preserved '$' character in .jrxml file.so can you give some more information related to it Thank you,thevoice. Link to comment Share on other sites More sharing options...
lucianc Posted April 25, 2008 Share Posted April 25, 2008 thevoice wrote:Can you tell me how to escape '$' characters to get proper .jrxml output from the velocity? This is exactly what I've explained in the previous post. To escape $ characters in velocity templates, you need to prefix them with a backslash. My example again:Code:"Page " + String.valueOf($V{PAGE_NUMBER}) Regards,Lucian 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