}
@Override
protected void onBeforeSave(HibernateObjectModel<User> mUser) {
User user = mUser.getObject();
Role userRole = (Role) radioGroup.getDefaultModelObject();
user.setRole(userRole);
user.setCreateDate(new Date());
user.setValid(false);
user.generateSecurityToken();
user.setPassword(password.getConvertedInput());
String url = "/register?username=" + user.getUsername() + "&key=" + user.getSecurityToken();
if (userRole.equals(Role.STUDENT)) {
// add user to the default period
user.getPeriods().clear();
user.getPeriods().add(ISIApplication.get().getMDefaultPeriod().getObject());
ISIEmailService.get().sendXmlEmail(mUser, ISIEmailService.EMAIL_CONFIRM, url);
} else {