Package org.joget.apps.form.model

Examples of org.joget.apps.form.model.Element


        if (form != null) {
            FormDataDao formDataDao = (FormDataDao) AppUtil.getApplicationContext().getBean("formDataDao");
            String tableName = formDataDao.getFormTableName(form);
            Collection<String> columnNames = formDataDao.getFormDefinitionColumnNames(tableName);
            for (String columnName : columnNames) {
                Element element = FormUtil.findElement(columnName, form, null, true);
                if (element != null && !(element instanceof FormContainer)) {
                    if (!(element instanceof PasswordField)) {
                        String id = element.getPropertyString(FormUtil.PROPERTY_ID);
                        String label = element.getPropertyString(FormUtil.PROPERTY_LABEL);
                        if (id != null && !id.isEmpty()) {
                            if (label == null || label.isEmpty()) {
                                label = id;
                            }
                            columns.add(new DataListColumn(id, label, true));
View Full Code Here


            while (matcher.find()) {
                String name = matcher.group(1);

                //create dummy element object
                Element element = new TextField();
                element.setProperty("id", name);

                //get value from the formData
                String[] values = FormUtil.getElementPropertyValues(element, formData);
                if (values != null && values.length > 0) {
                    // check for empty submission via parameter
View Full Code Here

                        String value = "";
                        if (matcherValue.find()) {
                            value = matcherValue.group(1);
                        }

                        Element element = new CheckBox();
                        element.setProperty("id", name);
                        element.setParent(this);
                        String[] values = FormUtil.getElementPropertyValues(element, formData);

                        Boolean checked = false;
                        if (values != null && values.length > 0) {
                            for (String v : values) {
                                if (value.equals(v)) {
                                    checked = true;
                                }
                            }
                        }

                        newInputString = newInputString.replaceFirst("checked", "");
                        newInputString = newInputString.replaceFirst("checked=\"true\"", "");
                        newInputString = newInputString.replaceFirst("checked=\"checked\"", "");

                        if (checked) {
                            newInputString = newInputString.replaceFirst("value=\"", "checked=\"checked\" value=\"");
                        }

                    } else if (type.equalsIgnoreCase("file") || type.equalsIgnoreCase("button") || type.equalsIgnoreCase("submit") || type.equalsIgnoreCase("reset") || type.equalsIgnoreCase("image")) {
                        //ignore
                    } else {
                        Element element = new TextField();
                        element.setProperty("id", name);
                        element.setParent(this);
                        String value = FormUtil.getElementPropertyValue(element, formData);
                        newInputString = newInputString.replaceFirst("value=\"[^\\\"]*\"", "value=\"" + StringUtil.escapeRegex(StringEscapeUtils.escapeHtml(value)) + "\"");
                    }

                    customHTML = customHTML.replaceFirst(StringUtil.escapeRegex(inputString), StringUtil.escapeRegex(newInputString));
                }

                //textarea
                Pattern patternTextarea = Pattern.compile("<textarea[^>]*>.*?</textarea>", Pattern.DOTALL);
                Matcher matcherTextarea = patternTextarea.matcher(customHTML);
                while (matcherTextarea.find()) {
                    String textareaString = matcherTextarea.group(0);
                    String newTextareaString = textareaString;

                    //get the name
                    Pattern patternName = Pattern.compile("name=\"([^\\\"]*)\"");
                    Matcher matcherName = patternName.matcher(textareaString);
                    String name = "";
                    if (matcherName.find()) {
                        name = matcherName.group(1);
                    }

                    Element element = new TextField();
                    element.setProperty("id", name);
                    element.setParent(this);
                    String value = FormUtil.getElementPropertyValue(element, formData);

                    newTextareaString = newTextareaString.replaceFirst(">.*?</", ">" + StringUtil.escapeRegex(StringEscapeUtils.escapeHtml(value)) + "</");

                    customHTML = customHTML.replaceFirst(StringUtil.escapeRegex(textareaString), StringUtil.escapeRegex(newTextareaString));
                }

                //Select Box
                Pattern patternSelect = Pattern.compile("<select[^>]*>.*?</select>", Pattern.DOTALL);
                Matcher matcherSelect = patternSelect.matcher(customHTML);
                while (matcherSelect.find()) {
                    String selectString = matcherSelect.group(0);
                    String newSelectString = selectString;

                    //get the name
                    Pattern patternName = Pattern.compile("name=\"([^\\\"]*)\"");
                    Matcher matcherName = patternName.matcher(selectString);
                    String name = "";
                    if (matcherName.find()) {
                        name = matcherName.group(1);
                    }

                    Element element = new SelectBox();
                    element.setProperty("id", name);
                    element.setParent(this);
                    String[] values = FormUtil.getElementPropertyValues(element, formData);

                    //get the option
                    Pattern patternOption = Pattern.compile("<option[^>]*>.*?</option>");
                    Matcher matcherOption = patternOption.matcher(selectString);
View Full Code Here

     * @param json
     * @param includeMetaData true to include metadata required for use in the form builder.
     * @return
     */
    public String previewElement(String json, boolean includeMetaData) {
        Element element = createElementFromJson(StringUtil.decryptContent(json), !includeMetaData);
        FormData formData = new FormData();
        formData.addFormResult(PREVIEW_MODE, "true");
        String html = "";
        try {
            formData = executeFormOptionsBinders(element, formData);
View Full Code Here

            }
           
            processedJson = processedJson.replaceAll("\\\"\\{\\}\\\"", "{}");

            // instantiate element
            Element element = FormUtil.parseElementFromJson(processedJson);
            return element;
        } catch (Exception ex) {
            LogUtil.error(FormService.class.getName(), ex, null);
            throw new RuntimeException(ex);
        }
View Full Code Here

        formData = executeFormOptionsBinders(form, formData);
        formData = executeFormLoadBinders(form, formData);

        // make foreign keys read-only
        for (String foreignKey : readOnlyForeignKeySet) {
            Element el = FormUtil.findElement(foreignKey, form, formData);
            if (el != null) {
                FormUtil.setReadOnlyProperty(el);
            }
        }
        return form;
View Full Code Here

            updatedFormData = validateFormData(form, formData);
        }
        Map<String, String> errors = updatedFormData.getFormErrors();
        if (!updatedFormData.getStay() && errors == null || errors.isEmpty()) {
            // generate primary key if necessary
            Element primaryElement = FormUtil.findElement(FormUtil.PROPERTY_ID, form, formData);
            if (primaryElement != null) {
                //format data to generate id
                FormUtil.executeElementFormatData(primaryElement, formData);
            }
           
View Full Code Here

            if (variableValue != null) {
                row.put(id, variableValue);
            }
        }
        for (Iterator<Element> i = element.getChildren().iterator(); i.hasNext();) {
            Element child = i.next();
            loadWorkflowVariables(child, row, variableMap);
        }
        return variableMap;
    }
View Full Code Here

            if (value != null) {
                variableMap.put(variableName, value);
            }
        }
        for (Iterator<Element> i = element.getChildren().iterator(); i.hasNext();) {
            Element child = i.next();
            storeWorkflowVariables(child, row, variableMap);
        }
        return variableMap;
    }
View Full Code Here

    public static Element parseElementFromJson(String json) throws Exception {
        // create json object
        JSONObject obj = new JSONObject(json);

        // parse json object
        Element element = FormUtil.parseElementFromJsonObject(obj);

        return element;
    }
View Full Code Here

TOP

Related Classes of org.joget.apps.form.model.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.