List of usage examples for org.apache.wicket.ajax AjaxRequestTarget appendJavaScript
void appendJavaScript(CharSequence javascript);
If the javascript needs to do something asynchronously (i.e.
From source file:org.obiba.onyx.marble.core.wicket.wizard.ConsentWizardForm.java
License:Open Source License
public void onFinish(AjaxRequestTarget target, Form form) { Boolean consentIsSubmitted = activeConsentService.isConsentFormSubmitted(); Boolean consentIsAccepted = activeConsentService.getConsent().isAccepted(); Boolean consentIsElectronic = activeConsentService.getConsent().getMode() == ConsentMode.ELECTRONIC ? true : false;/* ww w.ja v a 2 s . c o m*/ // Consent not submitted, inform the user that the submit button (PDF form) has to be clicked. if (!consentIsSubmitted) { error(getString("MissingConsentForm")); onError(target, form); // Invalid electronic consent. } else if (consentIsAccepted && consentIsElectronic && !activeConsentService.validateElectronicConsent()) { error(getString("InvalidConsentForm")); getElectronicConsentStep().setNextStep(null); gotoNext(target); this.changeWizardFormStyle("wizard-consent"); onError(target, form); // Valid electronic consent, refused electronic consent, or manual consent. } else { IStageExecution exec = activeInterviewService.getStageExecution((Stage) stageModel.getObject()); ActionDefinition actionDef = exec.getSystemActionDefinition(ActionType.COMPLETE); // Delete previous consent (if exist) for that interview Consent existingConsent = consentService.getConsent(activeInterviewService.getInterview()); if (existingConsent != null) { consentService.deletePreviousConsent(activeInterviewService.getInterview()); } // Save the consent consentService.saveConsent(activeConsentService.getConsent()); if (actionDef != null) { getActionWindow().show(target, stageModel, actionDef); } } target.appendJavascript("Resizer.resizeWizard();"); target.appendJavascript("Resizer.resizeConsentFrame();"); }
From source file:org.obiba.onyx.marble.core.wicket.wizard.ElectronicConsentStep.java
License:Open Source License
@Override public void onStepInNext(WizardForm form, AjaxRequestTarget target) { super.onStepInNext(form, target); setContent(target, new ElectronicConsentPanel(getContentId(), form)); // Replace the WizardForm css to get rid of the blue border that surrounds the form. // This border is taking too much space when the electronic consent form is displayed. form.changeWizardFormStyle("wizard-consent"); target.appendJavascript("Resizer.resizeConsentFrame();"); }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.BaseQuestionCategorySelectionPanel.java
License:Open Source License
/** * Find the feedback panel associated to the wizard form and update it regarding the ajax target. * @param target// w w w .ja v a 2s .c o m */ protected void updateFeedbackPanel(AjaxRequestTarget target) { WizardForm wizard = findParent(WizardForm.class); if (wizard != null && wizard.getFeedbackWindow() != null) { if (wizard.getFeedbackMessage() != null) wizard.getFeedbackWindow().show(target); } target.appendJavascript("Resizer.resizeWizard();"); }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.simplified.pad.NumericPad.java
License:Open Source License
private AjaxImageSubmitLink createSubmitButton(final DataType type, final FeedbackPanel padFeedbackPanel) { AjaxImageSubmitLink link = new AjaxImageSubmitLink("ok", new QuestionnaireStringResourceModel(activeQuestionnaireAdministrationService.getQuestionnaire(), "ok"), null, new Model("icons/check_ok.png")) { private static final long serialVersionUID = 1L; @Override// w w w . j a va 2 s . co m public void onError(AjaxRequestTarget target, Form form) { log.debug("Error submitting numeric pad data, data is not valid."); valuePressed.getField().clearInput(); resetField(); target.addComponent(valuePressed); target.addComponent(padFeedbackPanel); target.appendJavascript("resizeNumericPad();"); } @Override public void onSubmit(AjaxRequestTarget target, Form form) { log.debug("Submitting numeric pad data..."); // build final data Data data = getData(); if (data != null && data.getValue() != null && data.getValueAsString().length() > 0) { try { setData(DataBuilder.build(type, data.getValueAsString())); } catch (Exception e) { log.warn("Failed parsing as a " + type + ":" + data.getValueAsString(), e); setData(null); } } else { setData(null); } Question question = getQuestion(); QuestionCategory questionCategory = getQuestionCategory(); if (!question.isMultiple() || questionCategory.isEscape()) { // exclusive choice: delete other category answers for (CategoryAnswer categoryAnswer : activeQuestionnaireAdministrationService .findAnswers(question)) { if (!categoryAnswer.getCategoryName().equals(questionCategory.getCategory().getName())) { QuestionCategory qCategory = question .findQuestionCategory(categoryAnswer.getCategoryName()); if (qCategory == null && question.getParentQuestion() != null) { // case of shared category qCategory = question.getParentQuestion() .findQuestionCategory(categoryAnswer.getCategoryName()); } activeQuestionnaireAdministrationService.deleteAnswer(question, qCategory); } } } else if (!questionCategory.isEscape()) { // in case of multiple answer, make sure when selecting a regular category that a previously selected one is // deselected for (CategoryAnswer categoryAnswer : activeQuestionnaireAdministrationService .findAnswers(question)) { QuestionCategory qCategory = question .findQuestionCategory(categoryAnswer.getCategoryName()); if (qCategory == null && question.getParentQuestion() != null) { // case of shared category qCategory = question.getParentQuestion() .findQuestionCategory(categoryAnswer.getCategoryName()); } if (qCategory != null && qCategory.isEscape()) { activeQuestionnaireAdministrationService.deleteAnswer(question, qCategory); } } } if (getData() != null) { activeQuestionnaireAdministrationService.answer(question, questionCategory, getOpenAnswerDefinition(), getData()); } else { activeQuestionnaireAdministrationService.deleteAnswer(question, questionCategory, getOpenAnswerDefinition()); } valuePressed.getField().clearInput(); resetField(); target.addComponent(valuePressed); // close pad modal window ModalWindow.closeCurrent(target); } @Override public void onClick(AjaxRequestTarget target) { // TODO Auto-generated method stub } }; link.setOutputMarkupId(true); link.getLink().setOutputMarkupId(true); valuePressed.add(new OnKeyPressBehaviour(link.getLink(), KeyPressed.Enter)); link.getLink().add(new NoDragBehavior()); return link; }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.standard.DefaultOpenAnswerDefinitionPanel.java
License:Open Source License
/** * Refresh wizard feedback panel and input field. * //from w w w .j av a2 s .co m * @param target */ private void updateFeedback(final AjaxRequestTarget target) { WizardForm wizard = findParent(WizardForm.class); if (wizard != null && wizard.getFeedbackWindow() != null) { if (wizard.getFeedbackMessage() != null) wizard.getFeedbackWindow().show(target); } target.appendJavascript("Resizer.resizeWizard();"); target.addComponent(openField.getField()); }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.standard.DefaultPageLayout.java
License:Open Source License
/** * Called when an answer is given to a question and then requires to update the resolution of in-page conditions. * In-page conditions on sub-questions is not supported yet. *//* w w w.j ava2 s .c o m*/ @Override public void onQuestionCategorySelection(AjaxRequestTarget target, IModel<Question> questionModel, IModel<QuestionCategory> questionCategoryModel, boolean isSelected) { int tests = 0; boolean questionListChanged = false; List<QuestionPanel> questionPanels = getQuestionPanels(); for (QuestionPanel panel : questionPanels) { Question question = (Question) panel.getDefaultModelObject(); tests++; if (!question.isToBeAnswered(activeQuestionnaireAdministrationService)) { // a question is not to be answered any more due to in-page conditions, make sure subsequent conditions will be // correctly resolved. panel.setActiveAnswers(false); questionListChanged = true; } } log.debug("tests {}", tests); log.debug("questionListChanged={}", questionListChanged); if (!questionListChanged) { if (getQuestionToBeAnsweredCount() > questionPanels.size()) { questionListChanged = true; } } log.debug("questionListChanged={}", questionListChanged); // update the whole layout because some questions can (dis)appear. if (questionListChanged) { log.debug("Page update"); target.addComponent(this); target.appendJavascript("Resizer.resizeWizard();"); } }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.standard.DropDownQuestionCategoriesPanel.java
License:Open Source License
@Override public void onQuestionCategorySelection(AjaxRequestTarget target, IModel<Question> questionModel, IModel<QuestionCategory> questionCategoryModel, boolean isSelected) { log.debug("onQuestionCategorySelection()={}", selectedQuestionCategoryModel != null ? selectedQuestionCategoryModel.getObject() : null); if (((QuestionCategory) questionCategoryModel.getObject()).isEscape()) { // called from escape category if (selectedQuestionCategoryModel != null) { target.appendJavascript("document.getElementById('" + questionCategoriesDropDownChoice.getMarkupId() + "').selectedIndex = 0;"); }//from w ww. j a v a 2 s .c om setSelectedQuestionCategory(null); questionCategoriesDropDownChoice.setRequired(false); updateOpenAnswerDefinitionPanel(target, null); } updateFeedbackPanel(target); // forward event to parent fireQuestionCategorySelected(target, questionModel, questionCategoryModel); }
From source file:org.obiba.onyx.quartz.core.wicket.wizard.QuestionnaireWizardForm.java
License:Open Source License
public void onBegin(AjaxRequestTarget target) { gotoBegin(target);/* w w w . j a v a2 s . c o m*/ target.appendJavascript("Resizer.resizeWizard();"); updateProgressBar(this); }
From source file:org.obiba.onyx.quartz.core.wicket.wizard.QuestionnaireWizardForm.java
License:Open Source License
public void onEnd(AjaxRequestTarget target) { gotoEnd(target);//w w w.jav a 2s. co m target.appendJavascript("Resizer.resizeWizard();"); updateProgressBar(this); }