/** Transforms the login screen into a dialog for inputing security questions. */ protected void changeModeNewQuestions() { // components that are worked with Object questionScreen = ui.loadComponentFromFile(XML_QUESTIONS, this); Object questionPanel = ui.find(questionScreen, "questionCreationPanel"); Object multiLabel = ui.find(questionPanel, MULTI_LABEL); // set the text describing how many questions are needed String text; int num = numberOfSecurityQuestions(user); if (num == 1) { text = getI18NString(QUESTION_ON_FILE); } else { text = getI18NString(QUESTIONS_ON_FILE); text = text.replaceFirst("<X>", "" + num); } int required = settings.getRequiredQuestionsRange().value() - num; text = text.replaceFirst("<Y>", "" + required); ui.setText(multiLabel, text); // create the panel ui.removeAll(questionPanel); ui.add(questionPanel, multiLabel); questions = new Object[required]; answers = new Object[required]; for (int i = 0; i < required; i++) { questions[i] = createQuestionComboBox(); ui.add(questionPanel, questions[i]); answers[i] = ui.createTextfield("", ""); ui.setColspan(answers[i], 2); ui.add(questionPanel, answers[i]); } ui.removeAll(mainPanel); ui.add(mainPanel, questionScreen); ui.setFocus(questions[0]); }
/** The mode that lets a user answer their security questions to generate a new password. */ protected void changeModeRecoverPassword() { List<SecurityQuestion> userQuestions = questionDao.getSecurityQuestionsForUser(user); if (userQuestions.size() < settings.getRequiredAnswersRange().value()) { displayWarningMessage("password.new.no.questions"); return; } Object recoverPanel = ui.loadComponentFromFile(XML_RECOVER_PASSWORD, this); Object questionsPanel = ui.find(recoverPanel, "questionsPanel"); Object multiLabel = ui.find(questionsPanel, MULTI_LABEL); ui.removeAll(questionsPanel); ui.add(questionsPanel, multiLabel); questions = new Object[settings.getRequiredQuestionsRange().value()]; answers = new Object[settings.getRequiredQuestionsRange().value()]; for (int i = 0; i < questions.length; i++) { SecurityQuestion sq = userQuestions.get(i); questions[i] = ui.createLabel(sq.getQuestion()); ui.setAttachedObject(questions[i], sq); ui.add(questionsPanel, questions[i]); answers[i] = ui.createTextfield("", ""); ui.add(questionsPanel, answers[i]); } ui.removeAll(mainPanel); ui.add(mainPanel, recoverPanel); ui.setFocus(answers[0]); }
protected void setResults(List<MedicForm> results) { this.results = results; uiController.removeAll(resultsList); for (MedicForm mf : results) { uiController.add(resultsList, uiController.createListItem(mf.getName(), mf)); } uiController.setSelectedIndex(resultsList, 0); selectionChanged(); }
/** Resets the login screen back to its initial state. */ public void reset() { UserSessionManager.getUserSessionManager().logout(); user = null; Object landingScreen = ui.loadComponentFromFile(XML_LOGIN, this); Object usernameField = ui.find(landingScreen, "usernameField"); ui.removeAll(mainPanel); ui.add(mainPanel, landingScreen); ui.setFocus(usernameField); }
/** Transforms the login screen into a dialog for inputting a new password. */ protected void changeModeNewPassword() { Object passwordScreen = ui.loadComponentFromFile(XML_NEW_PASSWORD, this); Object notice = ui.find(passwordScreen, "noticeTextArea"); String text = getI18NString("password.new.notice"); text += "\n -" + settings.getPasswordLength() + " " + getI18NString("admin.security.pass.length"); if (settings.isCaseRequired()) { text += "\n -" + getI18NString("admin.security.pass.letters"); } if (settings.isNumberRequired()) { text += "\n -" + getI18NString("admin.security.pass.numbers"); } if (settings.isSymbolRequired()) { text += "\n -" + getI18NString("admin.security.pass.symbols"); } ui.setText(notice, text); Object passwordBox = ui.find(passwordScreen, "passwordBox1"); ui.removeAll(mainPanel); ui.add(mainPanel, passwordScreen); ui.setFocus(passwordBox); }