Jmesa Integration in Struts Hibernate

  • Jmesa is a dynamic HTML table that allows you to filter, sort, paginate, export and edit your data however you need to

  • Java By Kiran

  • Using Jmesa in Struts+hibernate Project:

  • we are using jmesa for showing table in jmesa format .
    Create Project in eclipse as describe below.
    we need jars for Struts2 + hibernate3 + jmesa which all given below: put all jars in lib folder exactly and add all to buil path.

    Java By Kiran

    Project Structure (Desgin in Eclipse) :


    Source Codes (sequentially):
    1. index.jsp:

    < h2 > < a href="showalladv.action" > Jmesa Advanced Report< / a > < / h2 >

    Java By Kiran

    < ? xml version="1.0" encoding="UTF-8"? >
    < web-app xmlns:xsi="" xmlns="" 
    id="WebApp_ID" version="3.0" >
      < display-name > Report < / display-name >
      < filter >
       < filter-name > f1 < / filter-name >
       < filter-class > org.apache.struts2.dispatcher.FilterDispatcher < / filter-class >
       < / filter >
       < filter-mapping >
         < filter-name > f1 < / filter-name >
         < url-pattern > /* < / url-pattern >
       < / filter-mapping >
    < / web-app >
    In given Program all the specified requirement for singleton pattern is satisfied i.e

    Step 2: Made default constructor private

    Step 3: Create a Method for getting the reference to the Singleton Object and make it as synchronised

  • We write a public static getter or access method to get the instance of the Singleton Object at runtime. First time the object is created inside this method as it is null. Subsequent calls to this method returns the same object created as the object is globally declared (private) and the hence the same referenced object is returned.
  • It could happen that the access method may be called twice from 2 different classes at the same time and hence more than one object being created. This could violate the design patter principle. In order to prevent the simultaneous invocation of the getter method by 2 threads or classes simultaneously we add the synchronized keyword to the method declaration.

  • Step 4: Override the Object clone method to prevent cloning.

    We can still be able to create a copy of the Object by cloning it using the Object’s clone method. This can be done as shown below

    SingletonObjectDemo clonedObject = (SingletonObjectDemo) obj.clone();

    This again violates the Singleton Design Pattern’s objective. So to deal with this we need to override the Object’s clone method which throws a CloneNotSupportedException exception.

    Step 5: Create class SingletonObjectDemo to test the Singleton pattern

    Java By Kiran

    Run the given class as java Application and we will get the output