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