You need to sign in to do that
Don't have an account?

How I will call controller method from selectList ?
Hi All
<apex:selectList id="actionsList" multiselect="false" size="1">
<apex:selectOption itemValue="--None--" itemLabel="--None--" />
<apex:selectOption itemValue="Edit" itemLabel="Edit"/>
<apex:selectOption itemValue="Delete" itemLabel="Delete" />
<apex:selectOption itemValue="VAT+" itemLabel="VAT+" >
<apex:actionSupport event="onchange" action="{!applyVat}" reRender="masterPanel">
<apex:param value="{!er.entry.id}" assignTo="{!EntryToUpdate}"/>
</apex:actionSupport>
</apex:selectOption>
</apex:selectList>
public void applyVat(){
Id toUpdate = ApexPages.currentPage().getParameters().get('EntryToUpdate');
Ledger_Entry__c leEntry= [select Id,Apply_Vat__c,Type__c,Disbursement__c,DisbValAndVat__c from Ledger_Entry__c where id = :toUpdate];
if(leEntry.Apply_Vat__c==false && calculateVat=='VAT+'){
leEntry.Apply_Vat__c=true;
update leEntry;
}
}
Thanks in Advance,
Dileep Kumar
Try changing the return value of your method to PageReference and add a return null in the end.
public PageReference applyVat(){
Id toUpdate = ApexPages.currentPage().getParameters().get('EntryToUpdate');
Ledger_Entry__c leEntry= [select Id,Apply_Vat__c,Type__c,Disbursement__c,DisbValAndVat__c from Ledger_Entry__c where id = :toUpdate];
if(leEntry.Apply_Vat__c==false && calculateVat=='VAT+'){
leEntry.Apply_Vat__c=true;
update leEntry;
}
return null;
}
also, make sure you are rerendering the right pageblock or outputpanel in order to see any updates in the page. To troubleshoot that and make sure the error is not within your method, remove the rerender and see if it works (with the pagereference the entire page should reload.)
sometimes creating a public string, just for troubleshooting also helps, just to make sure the panels are being rerendered correctly and the method is also being called and the variables are being assigned the values you expect.
public String testString{get;set;}
public void applyVat(){
Id toUpdate = ApexPages.currentPage().getParameters().get('EntryToUpdate');
//assign values to your test string
testString = toUpdate;
Ledger_Entry__c leEntry= [select Id,Apply_Vat__c,Type__c,Disbursement__c,DisbValAndVat__c from Ledger_Entry__c where id = :toUpdate];
testString += ' apply_vat__c: '+leEntry.Apply_Vat__c+ ' calculateVat: '+calculateVat);
if(leEntry.Apply_Vat__c==false && calculateVat=='VAT+'){
leEntry.Apply_Vat__c=true;
update leEntry;
}
}
print the value of {!testString} in your visualforce and you will be able to troubleshoot.