Wednesday, 25 July 2012

Filling Html Data From Sever Into Html Element Using Ajax And Spring MVC 3.0


//placed this code in controller in controller
@RequestMapping(value = "/show.htm")
protected ModelAndView showStudent(@RequestParam("id") Long studentId,HttpServletRequest request,HttpServletResponse response) throws Exception {
         System.out.println("inside ajax");
       //getting Student Object From Database using StudentDao
        Student student = studentDao.getStudent(studentId);
     
      //createing ModelAndView Object
      ModelAndView modelAndView = new ModelAndView("show");
 
// putting student Into the model for used into the show page
      modelAndView.addObject(student);
return modelAndView;
   }


//put this code in jsp within script tag
function viewStudent(studentId)
    {
            //create ajax object using jquery or prototype or mootools or javascript
        //here we use jquery
    $.ajax({
         url:'show.htm',
         data:({id : studentId}),     //parameter passed ti the controller
        success:function(data){   // callback function after the request is completed
 $("#studentViewDiv").html(data);

            // 'studentViewDiv' is the target div
            // where we want to display our response
}
   });
 }
You can buy Xiomi Note from Flipkart ::: Click Here

Friday, 20 July 2012

Disabling AutoSaving Of Object Into Database In Grails.

----------------------------------------------------------------

In Grails if we get object from database and change it's properties then the persistence context save that object to database.

This Condition would not applied for newly created object.

........................Solution.....................

discard

Purpose :- it discards changes that are made persistence.

def student =Student.get(1)student .name = "Ankit"
student.discard() // changes won't be applied now

Description

Discard is same as Hibernate's evict method .
Discard inform persistence that changes are not saved into the database.

  



Tuesday, 10 July 2012

Applying Float Left Or Float Right Style Using Javascript



For Float Left
var element = document.getElementById('Element Id');
element.style.cssFloat= "left" ;
element.style.styleFloat= "left" ;