为什么,当我为输入添加代码时,我的选择列表不起作用

如何解决为什么,当我为输入添加代码时,我的选择列表不起作用

我有自己的控制器和页面。共有三个对象:Doctor__c、Patient__c 和 Appointment__c。预约__c有医生和病人。

我的问题是:当我为 Appointment__c 的 VF 页面中的输入字段添加代码时,我以前的代码无法正常工作。 (我知道要删除部分代码。)

它应该是这样工作的:当我选择 Doctor - Work_Start_Hours 和 End hours 时,表格也应该显示该医生的行。但它不会随着输入字段刷新。

这是一个很大的代码,对不起,但这都是相关的。 这是一个控制器:

public class AppointmentTableController {

public List<Doctor__c> listofDoctors {get;set;}
public String doctorId {get;set;}
public List<Doctor__c> docHoursList {get;set;}

public List<Patient__c> patientList {get;set;}
public String patientId {get;set;}

public Apexpages.StandardSetController controller {get;set;}
public List<Appointment__c> appointmentList {get;set;}
public Appointment__c appointmentObject {get;set;}

public AppointmentTableController() {
    listofDoctors = [SELECT Id,Name From Doctor__c ORDER BY Name];
    doctorId = listofDoctors.isEmpty() == FALSE ? listofDoctors[0].Id : NULL;
    getDoctors();
    
    patientList = [SELECT Id,Name FROM Patient__c ];

    getAppointments();
    appointmentObject = new Appointment__c();
}

public List<SelectOption> getDoctoRSSelectOptionItems() {
    List<SelectOption> options = new List<SelectOption>();
     for(Doctor__c d: listofDoctors) {
        options.add(new SelectOption(d.Id,d.Name));
    }
    return options;
}


public void getDoctors() {
    docHoursList = [
        SELECT Id,Name,Working_Hours_Start__c,Working_Hours_End__c  From Doctor__c
        Where Id =: doctorId
    ];
}

public PageReference goToAddNewDoctor() {
    return new PageReference('https://vrpconsulting-1d5-dev-ed.lightning.force.com/lightning/o/Doctor__c' + 
                             '/new?count=1&nooverride=1&userecordtypeCheck=1&navigationLocation=LIST_VIEW&uid' + 
                             '=162489093371864736&backgroundContext=%2Flightning%2Fo%2FDoctor__c%2Flist%3FfilterName%3DRecent');
}

////////////////////////////////////////////////////////////////////////////////    Patient

public List<SelectOption> getPatientSelectOptionItems() {
    List<SelectOption> options = new List<SelectOption>();
     for(Patient__c p: patientList) {
        options.add(new SelectOption(p.Id,p.Name));
    }
    return options;
}

    public PageReference goToAddNewPatient() {
    return new PageReference('https://vrpconsulting-1d5-dev-ed.lightning.force.com/lightning/o/Patient__c' + 
                             '/new?count=1&nooverride=1&userecordtypeCheck=1&navigationLocation=LIST_VIEW&uid' + 
                             '=162490325260397268&backgroundContext=%2Flightning%2Fo%2FPatient__c%2Flist%3FfilterName%3DRecent');
}


////////////////////////////////////////////////////////////////////////////////        Appointment
    
        public void getAppointments() {
            List<Appointment__c> appList = [SELECT Id,Doctor__r.Name,Patient__r.Name,Appointment_Date__c,Duration_in_minutes__c
                                                    FROM Appointment__c
                                                    WHERE Doctor__r.Id =: doctorId];
            controller = new Apexpages.StandardSetController(appList);
            controller.setPageSize(20);
        appointmentList =  (List<Appointment__c>)controller.getRecords();
}

public void saveAppointment() {
    appointmentObject.Doctor__c = doctorId;
    appointmentObject.Patient__c = patientId;
    insert appointmentObject;
    appointmentObject = new Appointment__c();
}
 

}

这是一个页面

<apex:page controller="AppointmentTableController">
<apex:form >    
    <apex:pageBlock title="Appointments Table">
    
    <apex:pageBlock id="Doctor">
        <apex:actionFunction action="{!getDoctors}" name="selectDoctors" rerender="DoctorsWorkHours"/>
        <apex:actionFunction action="{!getAppointments}" name="selectDoctorAppointments" rerender="AppointmentTable"/>
        
        Select a doctor 
        <apex:selectList size="1" value="{!doctorId}" onclick="selectDoctors();" onchange="selectDoctorAppointments();">
            <apex:selectOptions value="{!doctoRSSelectOptionItems}"/>
        </apex:selectList>
        
       <apex:dataList value="{!docHoursList}" var="docHours" id="DoctorsWorkHours">
            Working Hours Start &nbsp;<apex:outputField value="{!docHours.Working_Hours_Start__c}"/><br/>
            Working Hours End &nbsp;<apex:outputField value="{!docHours.Working_Hours_End__c}"/>
        </apex:dataList>        
        
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{! goToAddNewDoctor }" value="Add New Doctor" />
        </apex:pageBlockButtons> 
        
    </apex:pageBlock>
    
    <apex:pageBlock id="Patient"> 
        Select a patient 
        <apex:selectList size="1" value="{!patientId}">
            <apex:selectOptions value="{!patientSelectOptionItems}"/>
        </apex:selectList>
        
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{! goToAddNewPatient }" value="Add New Patient" />
        </apex:pageBlockButtons> 
    </apex:pageBlock>   
    
    <apex:pageBlock id="Appointment"> 
        
HERE THIS CODE

   <!--         <apex:pageBlockSection columns="1">
                <apex:inputField value="{! appointmentObject.Appointment_Date__c }"/>
                <apex:inputField value="{! appointmentObject.Duration_in_minutes__c }"/>
                <apex:commandButton action="{!saveAppointment}" value="Add New Appointment"/>
            </apex:pageBlockSection>        -->
        
        <apex:pageBlockSection columns="1" id="AppointmentTable">
            <apex:pageBlockTable value="{!appointmentList}" var="app">
                <apex:column headerValue="Action">

                </apex:column>
                <apex:column value="{!app.Doctor__r.Name}"/>
                <apex:column value="{!app.Patient__r.Name}"/>
                <apex:column value="{!app.Appointment_Date__c}"/>
                <apex:column value="{!app.Duration_in_minutes__c}"/>
            </apex:pageBlockTable>
            {!Controller.pageNumber} of {! ROUND(controller.resultsize / 5,0)}
        </apex:pageBlockSection>
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton value="PrevIoUs" action="{!controller.prevIoUs}" rendered="{!controller.hasPrevIoUs}" />
            <apex:commandButton value="Next" action="{!controller.next}" rendered="{!controller.hasNext}" />
        </apex:pageBlockButtons>
    </apex:pageBlock>
    

 </apex:pageBlock>
  </apex:form>
    
</apex:page>

谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?