亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這是否會使 MVC 設計模式失效?

這是否會使 MVC 設計模式失效?

萬千封印 2023-12-13 15:10:20
我想知道使用控制器將本地學生(模型)拉到我的視圖類中是否會使 MVC 設計模式無效。供參考我從來沒有將我的學生模型導入到視圖類中??刂破鱬ublic void saveStudent(int selectedRow, Student studentChanged){    studentList.getStudentList().set(selectedRow, studentChanged);}看法Student currentStudent;. . . .public StudentDetailedUI(StudentCntrl studentCntrIn, int selectedRowIn) {    studentCntrl = studentCntrIn;    selectedRow = selectedRowIn;    if (selectedRow >= 0) {        currentStudent = studentCntrl.getStudent(selectedRow);        initComponents();        parseCurrentStudent();    } else {        initComponents();        parseNewStudent();    }}. . . .JButton saveButton = new JButton("Save");    saveButton.addActionListener((ActionEvent e) -> {        if (selectedRow != -1){            currentStudent.setFirstName(firstNameDisplayValue.getText());            currentStudent.setLastName(lastNameDisplayValue.getText());            currentStudent.setUniversity(universityDisplayValue.getText());            currentStudent.setGpa(Double.parseDouble(gpaDisplayValue.getText()));            StudentDetailedUI.this.studentCntrl.saveStudent(selectedRow, currentStudent);            StudentDetailedUI.this.studentCntrl.getStudentListUI();        }        else {            StudentDetailedUI.this.studentCntrl.addStudent(firstNameDisplayValue.getText() +", " +lastNameDisplayValue.getText() +", " +universityDisplayValue.getText() +", " +gpaDisplayValue.getText());            StudentDetailedUI.this.studentCntrl.getStudentListUI();        }    });我的預期功能是使用列表詳細信息 GUI 更新列表中的現有學生。
查看完整描述

1 回答

?
青春有我

TA貢獻1784條經驗 獲得超8個贊

只要有關更新的所有邏輯都保留在控制器中就可以了,最終您可以在視圖中添加一些驗證,但控制器仍然應該對聯系持久層擁有最終決定權。



查看完整回答
反對 回復 2023-12-13
  • 1 回答
  • 0 關注
  • 151 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號