Async command button

Hi,

I’ve a async command button which is having some action defined. I’ve added some client side validation on this button in the click property. I want this button to invoke the action if client side validation is all good.

In the click property I am traversing through the table and checking if there are same entries in a single column, If there is then I am throwing CAF warning and if there is no warning the action should be executed but button is not invoking the action, please help.

Hi TeKnAs,

Have you tried with returning value as true/false from script block to invoke command button action.

If returning true/false from script block is not working,then you can add one hidden async command to call the action(that was being called from command button) and that hidden button can be invoked from script block.

Sample code for calling hidden async command block can be


var prevRowState=CAF.model('#{activePageBean.clientIds["htmlInputText"]}');
if(prevRowState=='1')
{
var cmdModel = CAF.model('#{activePageBean.clientIds["hidden12"]}');
cmdModel.raise();
}
else
{
alert("okk")
//Do nothing
}

Please let us know if you are facing any problem in implementing the same.

Thanks
Baharul Islam

Hi Baharul,

Thanks for the reply. However, when I am adding a for loop on the table [on Click property of save button] by getting the table row count. the control is not getting out of the for loop in case if there is no validation error, I’ve added an alert after the for loop. that alert never comes up.

Why is it so. any idea?

Thanks.

Hi TeKnAs,

For on click validation to loop over the table data can you try with code like

var tableModel=CAF.model('#{activePageBean.clientIds["asyncTable1"]}');

var rowModelList=tableModel.list();
//rowModelList will return table row IDS
alert(rowModelList.length);
for(var i=0;i<rowModelList.length;i++)
{
alert("row ID"+rowModelList[i])
//Validation part
}

Please let us know if you are facing any problem in implementing this.

Thanks
Baharul Islam