Skip to main content

Hi i want to call one apex method when an checkbox is clicked , 

My requirmnet is i have 2 vf pages and one controller.

in 1sr vf page when usere inserts 2 dates fileds and after that command button (submit) i am displaying custom report (data table).clicks exprot link i am passing the selected dates values to the same apex controller. to another vf page and i am getting correct result

now the requirmnet is after displaying the datatable there is one checkbox , when checkbox is checked in Vf page,i  want to make check in the Sobject record,(that i can do it), the main problem is i wnat to pass this check box also in the argument.

calling apex command button when checkbox is checked

My VF code:

 

<a href="/apex/SalesOrderSAPReportInExcel?fDate={!fDateStr}&tDate={!tDateStr}&chkbox={!StoreSelectCheckBox} " target="_blank" >

Export Here

</a>

Apex controller:in constructor

public SalesOrderReportGenerator(ApexPages.StandardController stdController) {

String Dtext = System.currentPageReference().getParameters().get('Dtext');

String fDate = System.currentPageReference().getParameters().get('fDate');

String tDate = System.currentPageReference().getParameters().get('tDate');

String chkbox=System.currentPageReference().getParameters().get('chkbox');

system.debug('*************:'+ chkboxs);

If(fDate != null && tDate != null){

fromDate = Date.valueOf(fDate);

toDate = Date.valueOf(tDate);

SelectCheckBox=Boolean.valueof(chkbox);

}

Submit function method:

public pageReference SalesOrderReportData() {

StoreSelectCheckBox=SelectCheckBox;

;

;

;

}

 

I can achive this only when checkbox checked and again subbmit commmad butoon called.

===

in simple words i want to call call apex command button when checkbox is check how to achive this pls tell me

2 answers
  1. Jan 6, 2015, 6:43 AM

    Hi padmini ss, 

    You can not directly pass argument in apex method  from VF page.

    Please try using <apex:actionfunction  tag. 

    when you click on checkbox, it will call a javascript method and your javascript method will call apex method through actionfunction.

    Let me know if it works for you.

    Sameer
0/9000