コード例 #1
0
  public String generateNewComponentId() {

    if (lastComponentId == 0) {

      Set<String> allIds = FormManagerUtil.getAllComponentsIds(getXformsDocument());

      for (String id : allIds) {
        int idNr = FormManagerUtil.parseIdNumber(id);

        if (idNr > lastComponentId) lastComponentId = idNr;
      }
    }

    return FormManagerUtil.CTID + (++lastComponentId);
  }
コード例 #2
0
  public Locale getDefaultLocale() {

    if (defaultLocale == null) {
      defaultLocale = FormManagerUtil.getDefaultFormLocale(getXformsDocument());
    }

    return defaultLocale;
  }
コード例 #3
0
  public void setFormErrorMsg(LocalizedStringBean formError) {

    if (formError != null) {

      FormManagerUtil.setFormErrorMsg(getXformsDocument(), formError);
      this.formErrorMsg = formError;
    } else {
      Logger.getLogger(getClass().getName())
          .log(Level.WARNING, "Tried to set form error message, but no formError provided");
    }
  }
コード例 #4
0
  public void setFormTitle(LocalizedStringBean formTitle) {

    if (formTitle != null) {

      FormManagerUtil.setFormTitle(getXformsDocument(), formTitle);
      this.formTitle = formTitle;
    } else {
      Logger.getLogger(getClass().getName())
          .log(Level.WARNING, "Tried to set form title, but no formTitle provided");
    }
  }
コード例 #5
0
  public void lazyLoadDocument(PersistedFormDocument persistedForm) {

    if (persistedForm != null) {
      setFormId(persistedForm.getFormId());
      setFormType(persistedForm.getFormType());
      setFormVersion(persistedForm.getVersion());
    }

    setContainerElement(FormManagerUtil.getComponentsContainerElement(getXformsDocument()));

    persistedFormForLazyLoading = persistedForm;
  }
コード例 #6
0
  public Document getComponentsXml(Locale locale) {

    Map<Locale, Document> localizedComponentsDocuments = getLocalizedComponentsDocuments();

    Document doc;

    if (!localizedComponentsDocuments.containsKey(locale)) {

      try {
        ComponentsGenerator componentsGenerator = getContext().getComponentsGenerator();
        Document xformClone = (Document) getXformsDocument().cloneNode(true);

        FormManagerUtil.modifyXFormsDocumentForViewing(xformClone);
        FormManagerUtil.setCurrentFormLocale(xformClone, locale);
        FormManagerUtil.modifyFormForLocalisationInFormbuilder(xformClone);

        doc = componentsGenerator.generateHtmlRepresentation(xformClone);

        localizedComponentsDocuments.put(locale, doc);
        setFormDocumentModified(false);

      } catch (Exception e) {

        Logger.getLogger(getClass().getName())
            .log(Level.SEVERE, "Exception while generating components html document", e);
        doc =
            localizedComponentsDocuments.isEmpty()
                ? null
                : localizedComponentsDocuments.values().iterator().next();
      }

    } else {
      doc = localizedComponentsDocuments.get(locale);
    }

    return doc;
  }
コード例 #7
0
  private void loadDocumentInternal(PersistedFormDocument persistedForm) {

    Document xformsXmlDoc = getXformsDocument();

    if (persistedForm != null) {
      setFormId(persistedForm.getFormId());
      setFormType(persistedForm.getFormType());
      setFormVersion(persistedForm.getVersion());
    }

    setContainerElement(FormManagerUtil.getComponentsContainerElement(xformsXmlDoc));
    loadContainerComponents();
    setProperties();

    loaded = true;
  }
コード例 #8
0
 public Element getSubmissionInstanceElement() {
   // TODO: this can be put to component data bean and lazy loaded there
   return FormManagerUtil.getFormSubmissionInstanceElement(getXformsDocument());
 }
コード例 #9
0
  public LocalizedStringBean getFormErrorMsg() {

    if (formErrorMsg == null) formErrorMsg = FormManagerUtil.getFormErrorMsg(getXformsDocument());

    return formErrorMsg;
  }
コード例 #10
0
  public LocalizedStringBean getFormTitle() {

    if (formTitle == null) formTitle = FormManagerUtil.getFormTitle(getXformsDocument());

    return formTitle;
  }
コード例 #11
0
  public String getFormSourceCode() throws Exception {

    return FormManagerUtil.serializeDocument(getXformsDocument());
  }
コード例 #12
0
  public void setDefaultLocale(Locale defaultLocale) {

    FormManagerUtil.setDefaultFormLocale(getXformsDocument(), defaultLocale);
    this.defaultLocale = defaultLocale;
  }
コード例 #13
0
  public void setFormId(Long formId) {

    FormManagerUtil.setFormId(getXformsDocument(), String.valueOf(formId));
    this.formId = formId;
  }