Only Institute
to provide recording daily after class to students. you can practice whole day under faculty guidance. where test and mockup tests are taken regularly. provides all mobile nos of old students on website.

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) :

    jmesa-3

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



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


    Java By Kiran

    2.web.xml:
    
    < ? xml version="1.0" encoding="UTF-8"? >
    < web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    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

    Note:
  • 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