Wednesday, July 22, 2009

Different ways to call controller class form Jsp and JavaScript

1. ${project.categoryCount}

" alt="Edit" width="11" height="11">

2. :it calls '/shareImagesPage' controller
3. onclick="javascript:handleUpdate(this.form, 'findProject', 'Project')">
the above code calls the java script handleUpdate() function and
the function invoke the 'findProject' controller

function handleUpdate(f, deleteaction, entity)
{
var group = f.elements["delete"];
f.action = deleteaction+'?projectID='+group[0].value;
f.submit();

}

4. Rredirecting request the to another controller
@RequestMapping("/loadCategories")
String loadCategories(@ModelAttribute
Project project, HttpServletRequest request) {
return "redirect:loadCategories";
}

5. Rredirecting request the to Jsp page
@RequestMapping("/loadCategories")
String loadCategories(@ModelAttribute
Project project, HttpServletRequest request) {
return "loadCategories";
}
this is used to redirect the request to loadCategories.jsp

6.

7.

delete: this is related to the name of the all check box.

function checkAll(f)
{

var field = f.elements["delete"];
var len = field.length;
if(len >0 ){
if(f.selectall.checked){
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}else{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
}else{

var element = document.getElementById('delete');
if(f.selectall.checked){

element.checked = true ;

}else{

element.checked = false ;

}


}
}

No comments: