Jump to content
We've recently updated our Privacy Statement, available here ×

How to use JRDesignComponentElement (add Barbecue)


arturoi

Recommended Posts

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

  • 3 years later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 year later...

I only found the guide of how to create a report without .jrxml

http://stackoverflow.com/questions/4456779/how-do-i-compile-jrxml-to-get-jasper

But 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...