How to integrate iText with Jspresso?

13 posts / 0 new
Last post
prakash
Offline
Joined: 10/07/2009
How to integrate iText with Jspresso?

Hi,

 

I am currently evaluating this nice framework, I would like to know how to integrate iText with Jspresso, we also need to integrate with charting systems like JFreechart and jQuery visualize, is it possible to integrate these?

  Thanks for the Nice Framework

 

-Regards

-Prakash

vvandens
Offline
Joined: 05/29/2008
How to integrate iText with Jspresso?

Hi Prakash,

Welcome to Jspresso and thanks for the good words !

As of now, there is no built-in integration of either iText or Charting libraries in Jspresso UI. But there is a built-in integration of JasperReports that allows you to dynamically generate and visualize JasperReports (in PDF and including charts) into the browser running the frontend. It is not documented yet but I could give you the directions if this may fit what you're looking for.

Best regards,
Vincent

prakash
Offline
Joined: 10/07/2009
Jasper Integration

Hi vincent,

 

That would be very helpful,as I am planning to present it on friday, even a small piece of integration would help very much. Thanks for the help.

 

Regards

Prakash

vvandens
Offline
Joined: 05/29/2008
Hi Prakash, I did my homework

Hi Prakash,

I did my homework Wink. Here are the basic steps to integrate a simple Jasper report into a Jspresso application.

Forewords :

  1. The jasper reports / jfree / iText dependencies were a little outdated in the Jspresso root pom. I've upgraded them to :
    Jasper 3.5.2
    iText 2.1.5
    jfree 1.0.13
  2. I slightly reworked the integration to make it more straightforward. So everything detailed in this post relies on 3.0.1-SNAPSHOT.
  3. I've implemented a working example on the HR sample application. You can checkout the complete source code here :

    svn co https://svn.jspresso.org/jspresso/app-hrsample/trunk/

  4. Once checked-out, the report is located here :

    core/src/main/jasperreports/org/jspresso/hrsample/report/Company.jrxml

    and its resource bundle files :

    core/src/main/resources/org/jspresso/hrsample/i18n/Report_*.properties

 

Here we go :

  • The first step is, of course, to design your Jasper report (I used iReport 3.6.0).
    Jspresso will provide your report with the following inputs (so design it accordingly) :
    • The JDBC datasource of your application backend - in our case, the HSQL in-memory database.
    • An implicit set of built-in parameters, among which entity_id, that is the primary key of the contextual model entity - in our case, the displayed Company entity.
    • An arbitrary set of user-defined parameters that the user will be prompted to fill-in - in our case, the report title.
  • Save it  as JRXML under a sub-directory of core/src/main/jasperreports. This is where the maven build will pick it up to compile and package it into your application.
  • And finally, integrate it in your Spring conf file. In views.xml :
    • Describe your report :
      <bean id="company.report" parent="abstractReportDescriptor">
      <property name="reportDesignUrl" value="classpath:org/jspresso/hrsample/report/Company.jasper" />
      <property name="propertyDescriptors">
      <bean class="org.jspresso.framework.model.descriptor.basic.BasicStringPropertyDescriptor">
      <property name="name" value="title" />
      </bean>
      </property>
      </bean>
    • Install the Jspresso built-in action that will ask the user for user-defined parameters (title in the example), run the report, and display it (either in PDF for the Flex, Qooxdoo, Wings or ULC GUI or directly using the Jasper preview component for the Swing GUI). In this example, we declare it as an action in the company main view :
      <bean id="Company.module.view" parent="Company.organization.view">
      <property name="actionMap">
      <bean class="org.jspresso.framework.view.action.ActionMap">
      <property name="actionLists">
      <list>
      <bean class="org.jspresso.framework.view.action.ActionList">
      <property name="name" value="FILE" />
      <property name="actions">
      <list>
      <ref bean="saveModuleObjectFrontAction" />
      <ref bean="reloadModuleObjectFrontAction" />
      <bean parent="staticReportAction">
      <property name="reportDescriptor" ref="company.report"/>
      </bean>
      </list>
      </property>
      </bean>
      </list>
      </property>
      </bean>
      </property>
      </bean>

 

I hope this is clear enough. Don't hesitate to post back if you have any problem.

Keep me informed about your presentation !

 

Best,

Vincent

prakash
Offline
Joined: 10/07/2009
Thanks a Lot

Hi Vincent,

Thanks a lot for your help, I presented it to the team, They were impressed with the Flex stuff, they have also come up with many doubts, which i have to address,  Now i have to spend more time on the framework. I couldn't answer most of the questions posted, Some of them

  1. Developers want more details about the layout's in the view.

  2.They wanted hyperlink's to navigate to entities.

  3. unluckily wings was not working in ie when i showed the demo app.

  4. Multilingual support was well received.

  5. Some asked is there a way to create custom widgets.

  6.xml configuration for views and model got mixed response.( some said its exhaustive)

 & more....

 My plan is to create a small existing app in other framework with (10-12) screens and show them again and i have to increase the confidence level to get through this.

 Thanks for your help, I didn't try what you said , but i quoted that its possible.

Thanks Again.

 

-Regards

-Prakash

 

vvandens
Offline
Joined: 05/29/2008
Things are moving fast ;-)

Hi Prakash,

First of all, thanks for your feedback.

Following your idea of integrating charts in Jspresso, I've implemented fusioncharts-free integration. This library includes animated flash charts that look much better, to my opinion, than JFreeChart. I've made it available seemlessly to all Jspresso supported UI frontends (including swing with the help of a native library, DJ-NativeSwing). If you want to get an idea of how to include a chart in a Jspresso based application, read this post.

Thanks for the suggestion Wink

 

Regarding the comments of your audience :

 

Developers want more details about the layout's in the view.

Jspresso includes a lot more layouts than the ones used in HR sample. To get an idea of them, explore the class hierarchy of org.jspresso.framework.view.descriptor.basic.BasicCompositeViewDescriptor. Its subclasses allow for arranging sub-views in flexible ways, including a GridbagLayout like layout (org.jspresso.framework.view.descriptor.basic.BasicConstrainedGridViewDescriptor).

 

They wanted hyperlink's to navigate to entities.

Unfortunately, there's no such feature planned.

 

Unluckily wings was not working in ie when i showed the demo app

That's bad... Maybe do you have some more info (browser version, OS, public demo site or local build) ? By the way, the 3.0.1-SNAPSHOT includes a new AJAX frontend (Qooxdoo) that is a fantastic, pure javascript library. The implemented architecture in Jspresso is the same as the Flex one (a smart/rich client that drastically lowers the server-side memory consumption compared to Wings or ULC), with a very high rendering quality. Take a look at the screenshot attached to the post mentionned above.

 

Multilingual support was well received.

Thanks, I18N has been taken care from the ground up.

 

Some asked is there a way to create custom widgets.

There actually is, but it's a somehow advanced feature. All Jspresso UI screens are generated on the fly at runtime using view factories. These factories are open for extension.

 

XML configuration for views and model got mixed response.( some said its exhaustive).

There's an exciting contribution (Sugar For Jspresso) making its way to the Jspresso codebase : a groovy DSL. Instead of writing Spring XML, you write groovy code. It leads to clearer and more compact description (1/10th!). Again, refer to the post mentionned above to get an idea of the Jspresso near future regarding Domain Specific Language.

 

Don't hesitate to comment if you need further information.

 

Best regards,

Vincent

prakash
Offline
Joined: 10/07/2009
Thanks

Hi vincent,

 

Fusion charts is cool...Thanks for your help. I got pdf working too, Would you provide some reference to some projects that use Jspresso?

 

Thanks again.

-Prakash

vvandens
Offline
Joined: 05/29/2008
Project references

Hi Prakash,

Thanks very much for your feedback.

For the story, the Jspresso development has begun in 2005 and the framework has been open-sourced mid 2007. We have used it to build a CMS to generate J2ME mobile applications at BlueVox, a company targeted at bluetooth marketing. This CMS application is used by BlueVox customers directly over the internet to design their content and publish them on bluetooth devices for broadcasting.

I know of several companies that are currently evaluating it for inhouse developments. For instance, one of them is developing an application to manage its IT environment (machines, databases - tablespaces, parameters, ...- , installed software versions, ...). Unfortunately, I'm not allowed to disclose names.

Jspresso is free, opensource and business-friendly LGPL licensed. This allows for inclusion in closed-source projects without any need to publicize.

 

HTH,

Vincent

cvieira
Offline
Joined: 04/24/2009
Hi all, i'm trying to run

Hi all, i'm trying to run hrsample for the 1st time to evaluate jspresso 3.0.1-snapshot... although i'm having this problem with a report:

[INFO] [jasperreports:compile-reports {execution: compile-jasper-reports}]
[INFO] Compiling 1 report design files.
[INFO] Compiling report file: org/jspresso/hrsample/report/Company.jrxml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] : org.codehaus.mojo.jasperreports.JasperReportsMojo@faf015
Error compiling report design : /home/cvieira/WorkSpace/hrsample/core/src/main/jasperreports/org/jspresso/hrsample/report/Company.jrxml

Error compiling report design : /home/cvieira/WorkSpace/hrsample/core/src/main/jasperreports/org/jspresso/hrsample/report/Company.jrxml : Error compiling report java source files : /home/cvieira/WorkSpace/hrsample/core/target/jasperreports/java/Company_1261150999113_236899.java

 

Can anyone help, please! Thanks

Carlos

vvandens
Offline
Joined: 05/29/2008
jasper compilation problem.

Hi Carlos,

I don't have a clue. It must have something to do with your environement. I've just tried with a fresh checkout and everything builds fine. However :

  1. To track the problem, play in hrsample/core and do only "mvn clean compile". This will shorten the cycles compared to a full mvn package in the root directory.
  2. Try the above with debug enabled, i.e. "mvn --debug clean compile". This will produce verbose output for plugin executions. If there is more info regarding the error, post it back (don't copy/paste the entire log though...).
  3. If you still want to build without the Jasper report, just rename hrsample/core/src/main/jasperreports/org/jspresso/hrsample/report/Company.jrxml to Company.jrxml.bak.

BTW : OS, java version, maven version ?

 

HTH,

Vincent

jjjasont
Offline
Joined: 01/08/2010
I got the following

I got the following errors.

 

[INFO] Compiling report file: org\jspresso\hrsample\report\Company.jrxml

08/01/2010 4:59:27 PM org.apache.commons.digester.Digester error

SEVERE: Parse Error at line 2 column 441: Document root element "jasperReport",

must match DOCTYPE root "null".

org.xml.sax.SAXParseException: Document root element "jasperReport", must match

DOCTYPE root "null".

...

 

[INFO] ------------------------------------------------------------------------

[ERROR] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] : org.codehaus.mojo.jasperreports.JasperReportsMojo@cee41f

Error compiling report design : C:\Jason\workspace\hrsample\core\src\main\jasper

reports\org\jspresso\hrsample\report\Company.jrxml

 

Error compiling report design : C:\Jason\workspace\hrsample\core\src\main\jasper

reports\org\jspresso\hrsample\report\Company.jrxml : org.xml.sax.SAXParseExcepti

on: Document root element "jasperReport", must match DOCTYPE root "null".

[INFO] ------------------------------------------------------------------------

 

 

Any idea?

 

These are the steps that I've done

1. create project following steps in "10 minutes tutorial".

2. import hrsample to the project

3. hrsample runs properly in tomcat

4. checkout the following files from svn to the project

  - core\src\main\jasperreports\org\jspresso\hrsample\report\Company.jrxml

  - core\src\main\resources\org\jspresso\hrsample\i18n\Report.properties

  - core\src\main\resources\org\jspresso\hrsample\i18n\Report_en.properties

  - core\src\main\resources\org\jspresso\hrsample\i18n\Report_fr.properties

5. do mvn --debug clean compile, and got the above error


vvandens
Offline
Joined: 05/29/2008
Jasper version

Are you using 3.0.1-SNAPSHOT ? There might be a problem regarding the jasper reports version used to compile the report, i.e. 3.0.0 uses an older jasper version than the one required to compile the Company.jrxml report that was introduced recently in trunk (3.0.1-SNAPSHOT uses jasper 3.5.3 whereas 3.0.0 uses jasper 1.3.2).

The best you have to do is to play with the latest hrsample is to checkout the hrsample project from svn and build it as-is, i.e. :

svn co https://svn.jspresso.org/jspresso/app-hrsample/trunk/ hrsample
cd hrsample
mvn package

Beware that the latest hrsample sources got rid of Spring XML in favor of SJS groovy DSL, so you might be a bit lost...

Another option might be to upgrade your project to 3.0.1-SNAPSHOT, either manually (edit your [project root]/pom.xml and change the reference from 3.0.0 to 3.0.1-SNAPSHOT) or by generating a new one using the 3.0.1-SNAPSHOT archetype then re-importing your sources. For the latest, follow the steps indicated in this post.

 

HTH,

Vincent

CharlesMainegra
Offline
Joined: 02/04/2011
Thank you very much for

Thank you very much for posting this article. Its a very useful article. We will be acquire lot of things from this site.So i want some Business Logo Design information about this post.