Подскажите пожалуйста как заставить работать кнопку Add New Appointment она просто перезагружает страницу
<apex:page controller=“AppointmentTableController” showHeader=“false” sidebar=“false”>
<apex:form >
<apex:pageBlock title=“Appointmets Table”>
<apex:pageBlockSection >
<apex:selectList size="1" value="{!selectedDoctor}">
Select a doctor:
<apex:selectOptions value="{!doctorSelectOptionList}"/>
</apex:selectList>
<apex:commandButton value="Add New Doctor" />
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:outputText value="Work Hours Start {}">
<!--<apex:param value="{!appt?????.Doctor__c.Working_Hours_End__c }"/> -->
</apex:outputText>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:outputText value="Work Hours End {}">
<!--<apex:param value="{!appt?????.Doctor__c.Working_Hours_End__c }"/> -->
</apex:outputText>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:selectList size="1">
<apex:selectOptions value="{!patientSelectOptionList}"/>
<apex:outputText value="Select a patient ">
</apex:outputText>
</apex:selectList>
<apex:commandButton immediate="false" value="Add New Patient" />
</apex:pageBlockSection>
<!-- Appointment date -->
<apex:pageBlockSection >
<apex:inputField label="Appointment date"
value="{!appt.Appointment_Data__c}"
required="false"/>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:inputField label="Duration in minutes"
value="{!appt.Duration_in_minutes__c}"
required="false"/>
</apex:pageBlockSection>
<!-- new appointment button(button not work) -->
<apex:pageBlockSection >
<apex:commandButton action="{!addNewAppt}" value="Add New Appointment" />
</apex:pageBlockSection>
<apex:pageBlockTable value="{!tableAppointments}" var="apt">
<apex:column headerValue="Action">
<apex:outputLink value="{!URLFOR('/' + apt.Id)}">
View
</apex:outputLink>
</apex:column>
<apex:column headerValue="Doctor's Name" value="{!apt.Doctor__c}"/>
<apex:column headerValue="Patient's Name" value="{!apt.Patient__c}"/>
<apex:column headerValue="Appointment Date" value="{!apt.Appointment_Data__c}"/>
<apex:column headerValue="Duration in minutes" value="{!apt.Duration_in_minutes__c}"/>
</apex:pageBlockTable>
<table style="width: 100%"><tr>
<td>
Page: <apex:outputText
value="{!PageNumber} of {!CEILING(ResultSize / PageSize)}"/>
</td>
<td align="center">
</td>
<td align="right">
Records per page:
<apex:selectList value="{!PageSize}" size="1">
<apex:selectOption itemValue="5" itemLabel="5"/>
<apex:selectOption itemValue="20" itemLabel="20"/>
<apex:actionSupport event="onchange" reRender=""/>
</apex:selectList>
</td>
</tr></table>
</apex:pageBlock>
</apex:form>
</apex:page>
public class AppointmentTableController {
public Appointment__c appt {get; set;}
public String selectedDoctor {get; set;}
public String selectedPatient {get; set;}
public Datetime appDate {get; set;}
public List<Doctor__c> DoctorList {get;set;}
public List doctorSelectOptionList {get;set;}
public List<Patient__c> PatientList {get;set;}
public List patientSelectOptionList {get;set;}
public Integer duration {get; set;}
public List<Appointment__c> tableAppointments{get; set;}
public AppointmentTableController() {
doctorSelectOptionList = new List<SelectOption>();
patientSelectOptionList = new List<SelectOption>();
DoctorList = [SELECT iD, Name FROM Doctor__c];
for (Doctor__c doc : DoctorList){
doctorSelectOptionList.add(new SelectOption(doc.Id, doc.Name));
}
PatientList = [SELECT Id, Name FROM Patient__c];
for (Patient__c patient : PatientList){
patientSelectOptionList.add(new SelectOption(patient.Id, patient.Name));
}
getTable();
}
public void getTable () {
tableAppointments = [SELECT id, Name, Doctor__c, Patient__c, Appointment_Data__c, Duration_in_minutes__c
FROM Appointment__c ORDER BY Appointment_Data__c ASC
];
}
public PageReference addNewAppt() {
try {
this.appt.Doctor__c = selectedDoctor;
this.appt.Patient__c = selectedPatient;
insert this.appt;
}
catch (Exception ex) {
ApexPages.addMessages(ex);
}
return NULL;
}
}