Class FormTemplateHelper


  • public final class FormTemplateHelper
    extends Object
    Utilities for finding, adding and deleting form templates in the form designer, see FormDesignerTemplateBean.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    • Constructor Detail

      • FormTemplateHelper

        public FormTemplateHelper()
    • Method Detail

      • buildTagNames

        public static com.alibaba.fastjson.JSONArray buildTagNames​(List<FormTemplateTag> tags)
        Parameters:
        tags - A list of form template tag entities.
        Returns:
        A list of tag names.
      • buildTemplateJson

        public static com.alibaba.fastjson.JSONObject buildTemplateJson​(javax.faces.context.FacesContext context,
                                                                        FormTemplate template,
                                                                        boolean withData)
        Parameters:
        context - Currently active faces context.
        template - Template to convert to a JSON object.
        withData - Whether the data with the form elements of the template should be included.
        Returns:
        A JSON object representing the template.
      • buildTemplateJson

        public static com.alibaba.fastjson.JSONArray buildTemplateJson​(javax.faces.context.FacesContext context,
                                                                       List<FormTemplate> templates,
                                                                       boolean withData)
        Parameters:
        context - Currently active faces context.
        templates - Templates to convert to a JSON object.
        withData - Whether the data with the form elements of the template should be included.
        Returns:
        A JSON array representing the templates.
      • createPreviewStreamedContent

        public static org.primefaces.model.StreamedContent createPreviewStreamedContent​(long templateId,
                                                                                        boolean thumbnail)
        Parameters:
        templateId - ID of the template for which to fetch the image.
        thumbnail - Whether to return a thumbnail or the original size.
        Returns:
        Streamed content with the preview image of the template.
      • fetchTagsAndTemplates

        public static FetchTemplateResult fetchTagsAndTemplates​(Mandant client,
                                                                Benutzer user,
                                                                OptionalLong templateId)
        Parameters:
        client - Current client of the user who opened the form in the designer.
        user - User who initiated the action.
        templateId - ID of the template to retrieve. When not present, the tags of all templates are returned.
        Returns:
        All available tags of the given template.
      • insertNewTemplate

        public static FormTemplate insertNewTemplate​(Mandant client,
                                                     Benutzer user,
                                                     TemplateDataParams params)
                                              throws IOException
        Parameters:
        client - Current client who owns the project.
        user - User who initiated the action.
        params - Data of the template to create.
        Returns:
        The newly created template.
        Throws:
        IOException - When the thumbnail image could not be created.
      • removeFormTemplate

        public static void removeFormTemplate​(Benutzer user,
                                              long templateId)
        Parameters:
        user - User who initiated the action.
        templateId - ID of the template to delete.
      • updateExistingTemplate

        public static FormTemplate updateExistingTemplate​(Mandant client,
                                                          Benutzer user,
                                                          long templateId,
                                                          TemplateDataParams params)
                                                   throws IOException
        Parameters:
        client - Current client who owns the project.
        user - User who initiated the action.
        templateId - ID of the template to update.
        params - Data of the template to update.
        Returns:
        The updated template.
        Throws:
        IOException - When the thumbnail image could not be created.