Sunday, April 3, 2011

Select table values using java script in CAF


var Moduletable = CAF.model('#{activePageBean.clientIds['defaultForm:asyncTable1']}');


var ModuleTemp = Moduletable.template();




for(i=0;i< Moduletable.getRowCount();i++)

{




var id1 = ModuleTemp.getControlId('htmlOutputText7');


var id2 = ModuleTemp.getControlId('htmlOutputText4');


var id3 = ModuleTemp.getControlId('htmlOutputText6');


var id4 = ModuleTemp.getControlId('htmlSelectOneMenu1');


var id5 = ModuleTemp.getControlId('htmlSelectOneMenu');


var sysID = Moduletable.get(i);


var idm1 = id1.replace('__template',sysID);

var idm2 = id2.replace('__template',sysID);

var idm3 = id3.replace('__template',sysID);

var idm4 = id4.replace('__template',sysID);

var idm5 = id5.replace('__template',sysID);

var modulename = CAF.model(idm1).getValue();

var date3 = CAF.model(idm2).getValue();

var date7 = CAF.model(idm3).getValue();

var exammonth= CAF.model(idm4).getValue();

var examyear = CAF.model(idm5).getValue();


var startmonth =date3.getMonth();

var startyear = date3.getYear();


startmonth =startmonth+ 1;


var endmonth =date7.getMonth();

var endyear = date7.getYear();


endmonth = endmonth + 1;

if(startyear > examyear)

{

alert('Enter valid Exam month and Year for'+ modulename);

return false;

}


if(endyear <examyear )

{

alert('Enter valid Exam month and Year for '+ modulename);

return false;

}


if(startyear == examyear)

{

if(startmonth >exammonth )

{

alert('Enter valid Exam month and Year for '+modulename);

return false;

}

}


if(endyear == examyear)

{

if(endmonth < exammonth )

{

alert('Enter valid Exam month and Year for '+ modulename);


return false;

}

}

}