add image to openbravo report (ireport)

some image, when used properly, make your report more impressive. static report in openbravo, through iReport, you can add static image too. this tutorial will share how to add a static image to openbravo static report. this tutorial is follow-through sub-reports in openbravo blog post. you can read it first if you not confident enough to develop openbravo static report.

when openbravo render a jasper report, openbravo build and pass default parameter BASE_WEB. simmilar with BASE_DESIGN, this parameter resolved at runtime, and point you to <tomcat_home>/webapps/<openbravo_context_name>/web. to avoid your module’s files overlap with core or other module, here is the modularity convention regarding this matter:

  1. create a folder named web insed your module folder
  2. create a folder with name equal to your module’s javapackage, put inside web folder that just created in step #1
  3. create a folder named image inside folder that created in step #2
  4. you can put image asset to this folder, latter used to make your report more impressive.
  5. when you compile openbravo, let say ant smartbuilt, this folder will be synchronized to tomcat webapps folder

when image asset already exists, we can now continue to add those image to our report:

  1. add new parameter named BASE_WEB with default value set to <BASE_DESIGN>/web/<javapackage>/image. so, in my case, default value for BASE_WEB is <openbravo_home>/modules/org.wirabumi.gen.oez/web/org.wirabumi.gen.oez/image. change <openbravo_home> to openbravo installation folder.
  2. add image to your main report.
  3. right click on image box, select properties. open image tab, then click find. browse your image file. this will hardcoded your image path. no worry, let it be for now.
  4. run your image to get preview
  5. your report now containing an static image, but still hardcoded it’s path. now right click image box. open image tab, then change image expression to: $P{BASE_WEB}+”<javapackage>/image/<image asset file name>”. in my case this image expression is set to $P{BASE_WEB}+”/org.wirabumi.gen.oez/image/infinite-erp.png”
  6. run your report, now you get report with static image, but image path not hardcoded. in the run time, BASE_WEB will be resolved to<tomcat_home>/webapps/<openbravo_context_name>/web.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s