public static void main(String[] args) { Student student = new Student(); student.firstName = "Mark"; student.middleName = "Elliot"; student.lastName = "Zuckerberg"; printFullName(student); }
/** Save changes to database */ public WOComponent saveChanges() { Session session = (Session) session(); EOEditingContext context = session.defaultEditingContext(); String msg = null; ErrorPage errorPage = (ErrorPage) pageWithName("ErrorPage"); // Verify student's first name msg = session.isValidName(student.firstName()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } // Verify student's last name msg = session.isValidName(student.lastName()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } // Verify student's date of birth if (student.dateOfBirth() != null || error != null) { error = null; msg = session.isValidDate(student.dateOfBirth()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } } // Verify student's street if (homeAddress.street() != null) { msg = session.isValidStreet(homeAddress.street()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } } // Verify student's city if (homeAddress.city() != null) { if (homeAddress.city() != null) { msg = session.isValidCity(homeAddress.city()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } } } // Verify student's state if (homeAddress.state() != null) { msg = session.isValidState(homeAddress.state()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } } // Verify student's ZIP code if (homeAddress.zip() != null) { msg = session.isValidZip(homeAddress.zip()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } } // Verify student's email address if (homeAddress.emailAddress() != null) { msg = session.isValidEmail(homeAddress.emailAddress()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } } // Verify student's login msg = session.isValidLogin(student.login()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } // Verify student's password msg = session.isValidPassword(student.password()); if (msg != null) { errorPage.setErrorMsg(msg); errorPage.setNextPage(this); return (errorPage); } // Save changes in database if (student.firstName() != null && student.lastName() != null) { // save changes permanently in database context.saveChanges(); } // Add new Student to editing context student = new Student(); homeAddress = new HomeAddress(); student.setAddress(homeAddress); session.defaultEditingContext().insertObject(student); session.defaultEditingContext().insertObject(homeAddress); return null; }