You need to sign in to do that
Don't have an account?
Vijosh
Unable to call a method associated to a button when a SelectOption is included.
Hi,
I am new to apex and visualforce.I have written a simple code and in this code the when i click on the button the associated method is not called.
The code below is just a sample code with static assigments, the main problem is whenever I add a selectoption in my code the methods in the controllers do not work and I am unable to submit/commit the record.
Any suggestions would be helpful.
Regards,
Vijosh
I am new to apex and visualforce.I have written a simple code and in this code the when i click on the button the associated method is not called.
The code below is just a sample code with static assigments, the main problem is whenever I add a selectoption in my code the methods in the controllers do not work and I am unable to submit/commit the record.
<apex:page controller="test_controller"> <apex:form > <apex:selectList value="{!countries}" multiselect="false" size="1"> <apex:selectOptions value="{!Items}"></apex:selectOptions> </apex:selectList><p/> <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/> </apex:form> </apex:page>
public class test_controller { public String[] countries = new String[]{}; public PageReference test() { test__c t=new test__c(); t.textfield__c='string'; insert t; } public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; } public String[] getCountries() { return countries; } }
Any suggestions would be helpful.
Regards,
Vijosh
Can you use the below code,
All Answers
<apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
to
<apex:commandButton value="Test" action="{!test}" />
I mean remove the reRender attribute from CommandButton.
If this helps,please mark it as best answer to help others :)
Can you use the below code,