Showing posts with label CAF. Show all posts
Showing posts with label CAF. Show all posts

Sunday, April 3, 2011

Select all table values using java script in CAF


CAF.Progress.overlay(document.blockEdgePanel4, "Please wait...");
if(this.checked)
{
  var checkedGroups = CAF.model('#{activePageBean.clientIds['hiddenCheckedGroups']}').getValue();
var Moduletable = CAF.model('#{activePageBean.clientIds['htmlForm:DataListTable']}');
var ModuleTemp = Moduletable.template();
for(i=0;i<Moduletable.getRowCount();i++)
{
var checkboxID = ModuleTemp.getControlId('htmlSelectBooleanCheckbox1');
var groupID = ModuleTemp.getControlId('htmlOutputLabel');
var replaceValue = Moduletable.get(i);
var newCheckboxID = checkboxID.replace('__template',replaceValue);
var newgroupID = groupID.replace('__template',replaceValue);
if(newCheckboxID != null)
{
  CAF.model(newCheckboxID).setValue(true);
  var groupValue =  CAF.model(newgroupID).getValue();      
  var Ltrim = '<SPAN class=caf-label-text>';
  var Rtrim = '</SPAN><SPAN class=caf-label-separator></SPAN>';
  groupValue = groupValue.replace(Ltrim,'');
  groupValue = groupValue.replace(Rtrim,'');
  if(checkedGroups.search(groupValue) == -1)
  {
  groupValue = groupValue+',';
      checkedGroups =checkedGroups+groupValue;
      }
}

}
 CAF.model('#{activePageBean.clientIds['hiddenCheckedGroups']}').setValue(checkedGroups);
 CAF.model('#{activePageBean.clientIds['htmlInputHidden1']}').setValue(true);
}

if(!this.checked)
{

var Moduletable = CAF.model('#{activePageBean.clientIds['htmlForm:DataListTable']}');
var ModuleTemp = Moduletable.template();
var checkedGroups = CAF.model('#{activePageBean.clientIds['hiddenCheckedGroups']}').getValue();
CAF.Progress.overlay(document.body, "Please wait...");
for(i=0;i< Moduletable.getRowCount();i++)
{

var checkboxID = ModuleTemp.getControlId('htmlSelectBooleanCheckbox1');
var replaceValue = Moduletable.get(i);
var  newCheckboxID = checkboxID.replace('__template',replaceValue);
if(newCheckboxID != null)
{
  CAF.model( newCheckboxID).setValue(false);
     }  
}
checkedGroups = '';
CAF.model('#{activePageBean.clientIds['hiddenCheckedGroups']}').setValue(checkedGroups);
CAF.model('#{activePageBean.clientIds['htmlInputHidden1']}').setValue(false);
}
CAF.Progress.hide(document.blockEdgePanel4);

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;

}

}

}