arturoi Posted August 26, 2010 Share Posted August 26, 2010 Hi forum,I need to create a report with no previous .jrxml (on the fly) and add a Barbacue element on it.In the jrxml I need create something similar to this:<componentElement><reportElement x="38" y="171" width="200" height="64"/><jr:barbecue xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" type="EAN128" drawText="true" checksumRequired="true" barHeight="40"><jr:codeExpression>"1234567890"</jr:codeExpression></jr:barbecue></componentElement> Can anyone help me please?I saw the nojrxml example but don't see anything similar to a componentElement created on the fly.Thanks in advance for your reply.Code:I tried with this portion of code: JRDesignComponentElement barCode = new JRDesignComponentElement(); barCode.setX(Integer.valueOf(fieldValues.get("x"))); barCode.setY(Integer.valueOf(fieldValues.get("y"))); barCode.setHeight(Integer.valueOf(fieldValues.get("height")) + 25); barCode.setWidth(Integer.valueOf(fieldValues.get("width"))); StandardBarbecueComponent stdBBQComponent = new StandardBarbecueComponent(); stdBBQComponent.setType("EAN128"); stdBBQComponent.setDrawText(false); stdBBQComponent.setChecksumRequired(false); stdBBQComponent.setBarHeight(Integer.valueOf(fieldValues.get("height"))); stdBBQComponent.setEvaluationTimeValue(EvaluationTimeEnum.REPORT); JRDesignExpression designExpression = new JRDesignExpression(); designExpression.setText("$F{" + fieldValues.get("fieldExp") + "}"); stdBBQComponent.setCodeExpression(designExpression); barCode.setComponent(stdBBQComponent);.... but when I try to compile the report design it throws methe following exception:java.lang.NullPointerException at net.sf.jasperreports.engine.component.ComponentsEnvironment.getComponentManager(ComponentsEnvironment.java:138) at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:1364) at net.sf.jasperreports.engine.design.JRDesignComponentElement.collectExpressions(JRDesignComponentElement.java:95) at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:567) at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:547) at net.sf.jasperreports.engine.JRExpressionCollector.collect(JRExpressionCollector.java:434) at net.sf.jasperreports.engine.JRExpressionCollector.collector(JRExpressionCollector.java:99) at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:137) at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215) Link to comment Share on other sites More sharing options...
annabaker732 Posted July 1, 2014 Share Posted July 1, 2014 You want to create EAN 128 barcode with defined sizing properties in JR? If yes, you may check following barcode reading and generation related thread.http://community.jaspersoft.com/questions/543613/barcode-size Link to comment Share on other sites More sharing options...
cathyben3 Posted July 17, 2015 Share Posted July 17, 2015 I only found the guide of how to create a report without .jrxmlhttp://stackoverflow.com/questions/4456779/how-do-i-compile-jrxml-to-get-jasperBut for adding barbecue. I'm also looking for solution, hope any one can share a result.Beside, I also need to create barcode in jasper reports, I need to add code 128 rather than ean 128, but still thanks for upper solution. 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