示例#1
0
文件: JsonForm.java 项目: vitlav/siu
  @Override
  public void attach() {
    hasAnyResult = false;
    VerticalLayout layout = (VerticalLayout) getLayout();
    try {
      integration = createIntegration();
      layout.addComponent(integration);
      layout.setExpandRatio(integration, 1f);
      integration.setErrorReceiver(new ErrorReceiver());
      integration.setValueReceiver(new ValueReceiver());
    } catch (RuntimeException e) {
      Logger.getLogger(getClass().getName()).log(Level.WARNING, "ошибка загрузки шаблона", e);
      layout.addComponent(
          new Label("Ошибка загрузки формы ввода данных " + e.getLocalizedMessage()));
    }

    super.attach();
  }
示例#2
0
文件: JsonForm.java 项目: vitlav/siu
 @Override
 public boolean isAsyncRequiredForComplete(AsyncCompleter asyncCompleter) {
   if (hasAnyResult) {
     return false;
   }
   if (asyncCompleter != null) {
     this.asyncCompleter = asyncCompleter;
   }
   if (integration != null) {
     integration.fireJson();
   }
   return true;
 }
示例#3
0
文件: JsonForm.java 项目: vitlav/siu
 public static JsonFormIntegration createIntegration(
     FormID formId, ActivitiApp app, String ref, String value, boolean archive) {
   String template = loadTemplate(app, ref);
   String template1 = template.replace("'#archiveMode#'", Boolean.toString(archive));
   boolean hasArchiveSupport = archive && !template1.equals(template);
   template = template1.replace("'#jsonField#'", value == null ? "{}" : value);
   StreamResource.StreamSource htmlStreamSource = new InMemoryResource(template);
   Resource resource =
       new StreamResource(
           htmlStreamSource, "jf-" + formId + "-" + System.currentTimeMillis() + ".html", app);
   JsonFormIntegration integration = new JsonFormIntegration();
   integration.setSource(resource);
   integration.setSizeFull();
   integration.setImmediate(true);
   if (archive) {
     integration.setReadOnly(true);
     if (!hasArchiveSupport) {
       integration.setFixArchiveSupport(true);
     }
   }
   return integration;
 }