Exemplo n.º 1
0
 @Override
 protected void onBeforeRender() {
   super.onBeforeRender();
   IRequestTarget target = ((WebRequestCycle) RequestCycle.get()).getRequestTarget();
   if (target instanceof AjaxRequestTarget) {
     // if refreshed by ajax render it again
     ((AjaxRequestTarget) target).appendJavascript(getInitJs());
   }
 }
Exemplo n.º 2
0
  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;

    // 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();");
  }
Exemplo n.º 3
0
 /**
  * Maps a trimmed value entered by the user to a value stored in the value list. The value stored
  * in the value list may contain some trailing spaces, while the value entered by the user is
  * trimmed.
  *
  * @param value
  * @return
  */
 @SuppressWarnings("nls")
 public String mapTrimmedToNotTrimmed(String value) {
   // Although the value entered by the user should be trimmed, make sure it is so.
   String trimmed = value.trim();
   try {
     // this is the &nbsp character we set for empty value
     if ("\u00A0".equals(trimmed) || trimmed.length() == 0) return trimmed;
     // Grab all values that start with the value entered by the user.
     String result = matchValueListValue(trimmed, false);
     if (result == null) {
       if (changeListener != null) dlm.getValueList().removeListDataListener(changeListener);
       try {
         dlm.fill(parentState, getDataProviderID(), trimmed, false);
         result = matchValueListValue(trimmed, false);
         if (result == null && list.hasRealValues()) {
           dlm.fill(parentState, getDataProviderID(), null, false);
           // if it doesn't have real values, just keep what is typed
           // now just try to match it be start with matching instead of equals:
           result = matchValueListValue(trimmed, true);
           if (result == null && !getEventExecutor().getValidationEnabled()) {
             result = trimmed;
           } else {
             // if this is found then it is a commit of data of a partial string, make sure that
             // the field is updated with the complete value.
             String displayValue = result == null ? "" : result;
             if (displayValue != null
                 && !displayValue.equals(trimmed)
                 && RequestCycle.get() != null) {
               IRequestTarget requestTarget = RequestCycle.get().getRequestTarget();
               if (requestTarget instanceof AjaxRequestTarget) {
                 ((AjaxRequestTarget) requestTarget)
                     .appendJavascript(
                         "if (document.getElementById('"
                             + getMarkupId()
                             + "').value == '"
                             + value
                             + "') document.getElementById('"
                             + getMarkupId()
                             + "').value='"
                             + displayValue
                             + "'");
               }
             }
           }
         }
       } finally {
         if (changeListener != null) dlm.getValueList().addListDataListener(changeListener);
       }
     }
     // If no match was found then return back the value, otherwise return the found match.
     return result == null ? trimmed : result;
   } catch (Exception e) {
     Debug.error(e);
     return trimmed;
   }
 }
 /**
  * Refreshes the element
  *
  * @param ajaxRequestTarget
  */
 public void refresh(AjaxRequestTarget ajaxRequestTarget) {
   ajaxRequestTarget.appendJavascript(this.refresh().render().toString());
 }
Exemplo n.º 5
0
 /**
  * Method to returns the .ui-accordion element within the ajax request
  *
  * @param ajaxRequestTarget
  */
 public void widget(AjaxRequestTarget ajaxRequestTarget) {
   ajaxRequestTarget.appendJavascript(this.widget().render().toString());
 }
Exemplo n.º 6
0
 /**
  * Method to enable the accordion within the ajax request
  *
  * @param ajaxRequestTarget
  */
 public void enable(AjaxRequestTarget ajaxRequestTarget) {
   ajaxRequestTarget.appendJavascript(this.enable().render().toString());
 }
Exemplo n.º 7
0
 /**
  * Method to destroy the accordion within the ajax request
  *
  * @param ajaxRequestTarget
  */
 public void destroy(AjaxRequestTarget ajaxRequestTarget) {
   ajaxRequestTarget.appendJavascript(this.destroy().render().toString());
 }
Exemplo n.º 8
0
 /**
  * Method to destroy the accordion within the ajax request
  *
  * @param ajaxRequestTarget
  * @param index
  */
 public void activate(AjaxRequestTarget ajaxRequestTarget, int index) {
   ajaxRequestTarget.appendJavascript(this.activate(index).render().toString());
 }
Exemplo n.º 9
0
 public void enableName(AjaxRequestTarget target) {
   target.appendJavascript(
       "document.getElementById('" + name.getMarkupId() + "').disabled='false'");
 }