Textfield listener saves updates to person model

I have a program that saves person details. Examples – first name, last name, MRN, dob, address, and preferred name. Each of these are textfields that a user can update. I’m trying to figure out how to have these save on the fly. As in once a user types in this fields, its being saved up to the database and can be seen in the program right away.

I have tried to accomplish this task in multiple different ways. I have several println statements within each function to try and capture and ensure information is being seen and saved. Also the MRN field is essentially another unique ID field.

I have first tried to use the setOnAction function tied to the textfield.

  preferredNameTextField.setOnAction(e -> {
            IPatientModel person= personService.findByMrn(mrnTextfield.getText());
            System.out.println(personService.findByMrn(mrnTextfield.getText()));
            person.setPreferredFirstName(preferredNameTextField.getText());
            personService.save(person);
            System.out.println(personService.save(patient));
        });

This honestly didn’t do anything. Didn’t result in an error but also didn’t save the update. The println statement also didn’t capture any data.

I then used thought about using a listener and would see if a change was made to the field it would then update the person information.

        preferredNameTextField.focusedProperty().addListener(new ChangeListener<Boolean>() {
            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                if(newValue){
                    IPersonModel person = personService.findByMrn(mrnTextfield.getText());
                    System.out.println(personService.findByMrn(mrnTextfield.getText()));
                    person.setPreferredFirstName(preferredNameTextField.getText());
                    personService.save(patient);
                    System.out.println(personService.save(patient));

                }else {
                    
                }
            }
        });

So the println did show that the Person table and that specific person update go through but it wasn’t saving. which i dont quite understand how thats possible. I would relaunch the program, go to that person and the perrferedNameTextfield would be blank.

       preferredNameTextField.textProperty().addListener((obs, oldText, newText) -> {
            if(newText != null || newText == null){
                  IPersonModel person = personService.findByMrn(mrnTextfield.getText());
                    System.out.println(personService.findByMrn(mrnTextfield.getText()));
                    person.setPreferredFirstName(preferredNameTextField.getText());
                    personService.save(person);
                    System.out.println(personService.save(patient));
            }
        });

So this resulted in the same as the previous. The data was opening in the println but when the program was relaunched it didn’t save, also querying the Person table showed it didn’t update successfully.

Is there a better way to be handling

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật