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" ;

Monday, 26 March 2012

Mootools and Jquery Conflict 

Mootools and Jquery works based on $ ...
 And actually mootools and Jquery have no any conflict.
 But u can not use Prototype and Mootools together .. 

Tuesday, 3 January 2012

Change value of Element in IFRAME using javascript....

  var IframeID=document.getElementById("myIFrame");
     var eyeframedoc;
           eyeframedoc = IframeID.contentWindow ? IframeID.contentWindow.document: IframeID.contentDocument;
     eyeframedoc.getElementById("elementInsideInIframe").value="any value";

Create print view using javascript to print perticular div

<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <script type="text/javascript">     
       function PrintDiv() {    

          var divToPrint = document.getElementById('divToPrint');
          var popupWin = window.open('', '_blank', 'width=300,height=300');
          popupWin.document.open();
          popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
           popupWin.document.close();
               }
    </script>
  </head>
       <body >
               other contents
           <div id="divToPrint" >
              <div style="width:200px;height:300px;background-color:teal;">
                 This is the div to print
               </div>
           </div>
           <div>
               <input type="button" value="print" onclick="PrintDiv();" />
           </div>
       </body>
</html>

Perm Gens space in IntelijIDEA

go to  > Edit Configuration >

put this line into a vm parameter

-XX:MaxPermSize=128m -XX:PermSize=128m -Xms1024m -Xmx1024m -XX:-UseGCOverheadLimit

Monday, 2 January 2012

Rendering Div Using Ajax

you have to use remoteFunction and call it on any event and call action on the controller and when at the end of the action you have to render one template .

In controller

def sendMail={
   //sending mail code
   render(template:'renderingDiv',model:[Name:"any Bean"])
}
In  _renderingDiv.gsp
<div>
 //use Bean for data (any GSP code)
</div>


This div automatically Rendered to The remoteFunction calling page and added to the id
specified By update attribute in remoteFunction