Saturday, 10 October 2015

Javascript Check if form is Dirty.


Checking if the form is dirty or not is an important scenario that comes in most web applications. Typically this implies to the fact that there is always some form in the application that will be containing atleast 20-30 fields. Here it becomes tedious to keep a track of all the values for all fields .

There are some ways to check if the form is dirty.

Approach #1

1. Serialize the form (and all its values) before showing it .
e.g
  $(document).ready(function(){   
    form_before_change = $("form").serialize();    
  });   

  
2. Serialize it again in a "onbeforeunload" event handler



 window.onbeforeunload = function (e) {   
   var form_changed = $("form").serialize();   
   if(form_before_change != form_changed) {   
    return 'There is unsaved data. on the form';   
   }   
  };   


Friday, 13 February 2015

Difference between JSP include directive and JSP include action

@include 
<%@ include file=”filename” %> is the JSP include directive. At JSP page translation time, the content of the file given in the include directive is ‘pasted’ as it is, in the place where the JSP include directive is used. Then the source JSP page is converted into a java servlet class. The included file can be a static resource or a JSP page. Generally JSP include directive is used to include header banners and footers.


The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output. is the JSP include action element. 


<jsp:include>
The jsp:include action element is like a function call. At runtime, the included file will be ‘executed’ and the result content will be included with the soure JSP page.
 When the included JSP page is called, both the request and response objects are passed as parameters. If there is a need to pass additional parameters, then jsp:param element can be used. If the resource is static, its content is inserted into the calling JSP file, since there is no processing needed.

Wednesday, 11 February 2015

Sorted collection vs Ordered collection in hibernate -

Sorted collection vs Ordered collection in hibernate  - 

Sorted Collection - 


  • A sorted collection is sorting a collection by utilizing the sorting features provided by the Java collections framework.
  •  The sorting occurs in the memory of JVM which running Hibernate, after the data being read from database using java comparator.
  • If your collection is not large, it will be more efficient way to sort it. 


Order Collection - 

  • Order collection is sorting a collection by specifying the order-by clause for sorting this collection when retrieval. 
  • If your collection is very large, it will be more efficient way to sort it