Package org.joget.apps.form.model

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


    public static String getElementProcessedJson(Element element) {
        String properties = "";
        try {
            // create json object
            JSONObject obj = new JSONObject(getProcessedFormJson());
            Element temp = element;
           
            // get the elements on the path to root element;
            Stack<Element> stack = new Stack<Element>();
            while (temp != null) {
                stack.push(temp);
                temp = temp.getParent();
            }
           
            // get the first element (Root element) in stack to match with root Json Object
            temp = stack.pop();
           
            //if statck is not empty, continue find the matching json object
            while (!stack.isEmpty()) {
                temp = stack.pop();
               
                //travel in json object's child to find matching json object
                if (!obj.isNull(FormUtil.PROPERTY_ELEMENTS)) {
                    int position = 0;
                   
                    //get position
                    Element parent = temp.getParent();
                    Collection<Element> children = parent.getChildren();
                    if (children != null) {
                        for (Element c : children) {
                            if (c.equals(temp)) {
                                break;
                            }
View Full Code Here


                for (Object o : fields) {
                    Map mapping = (HashMap) o;
                    String fieldId = mapping.get("field").toString();
                       
                    try {
                        Element el = FormUtil.findElement(fieldId, loadForm, formData);
                       
                        String value = FormUtil.getElementPropertyValue(el, formData);
                        if (value != null && !value.isEmpty()) {
                            File file = FileUtil.getFile(value, loadForm, primaryKey);
                            if (file != null) {
View Full Code Here

           
            String startDate = "";
            String endDate = "";
           
            if (!getPropertyString("startDateFieldId").isEmpty()) {
                Element e = FormUtil.findElement(getPropertyString("startDateFieldId"), form, formData);
                if (e != null) {
                    String compareValue = FormUtil.getElementPropertyValue(e, formData);
                    if (compareValue != null && !compareValue.isEmpty()) {
                        String formattedCompare = formatCompareValue(compareValue, displayFormat);
                        if (!DateUtil.compare(formattedCompare, value, displayFormat) && !formattedCompare.equals(value)) {
                            valid = false;
                            startDate = formattedCompare;
                        }
                    }
                }
            }
           
            if (!getPropertyString("endDateFieldId").isEmpty()) {
                Element e = FormUtil.findElement(getPropertyString("endDateFieldId"), form, formData);
                if (e != null) {
                    String compareValue = FormUtil.getElementPropertyValue(e, formData);
                    if (compareValue != null && !compareValue.isEmpty()) {
                        String formattedCompare = formatCompareValue(compareValue, displayFormat);
                        if (!DateUtil.compare(value, formattedCompare , displayFormat) && !formattedCompare.equals(value)) {
View Full Code Here

        form.setProperty("url", formUrl);

        // decorate form with actions
        Collection<FormAction> formActionList = new ArrayList<FormAction>();
        if (activityForm != null && activityForm.getFormId() != null && !activityForm.getFormId().isEmpty() && !activityForm.getDisableSaveAsDraft()) {
            Element saveButton = (Element) pluginManager.getPlugin(SaveAsDraftButton.class.getName());
            saveButton.setProperty(FormUtil.PROPERTY_ID, "saveAsDraft");
            saveButton.setProperty("label", ResourceBundleUtil.getMessage("form.button.saveAsDraft"));
            formActionList.add((FormAction) saveButton);
        }
        Element completeButton = (Element) pluginManager.getPlugin(AssignmentCompleteButton.class.getName());
        completeButton.setProperty(FormUtil.PROPERTY_ID, AssignmentCompleteButton.DEFAULT_ID);
        completeButton.setProperty("label", ResourceBundleUtil.getMessage("form.button.complete"));
        formActionList.add((FormAction) completeButton);
        FormAction[] formActions = formActionList.toArray(new FormAction[0]);
        form = decorateFormActions(form, formActions);

        // set to definition
View Full Code Here

                if (startForm != null) {
                    // set action URL
                    startForm.setProperty("url", formUrl);

                    // decorate form with actions
                    Element submitButton = (Element) pluginManager.getPlugin(AssignmentCompleteButton.class.getName());
                    submitButton.setProperty(FormUtil.PROPERTY_ID, AssignmentCompleteButton.DEFAULT_ID);
                    submitButton.setProperty("label",  ResourceBundleUtil.getMessage("form.button.submit"));
                    FormAction[] formActions = {(FormAction) submitButton};
                    startForm = decorateFormActions(startForm, formActions);

                    // set to definition
                    startFormDef.setForm(startForm);
View Full Code Here

        Collection<FormAction> formActionList = new ArrayList<FormAction>();
        if (saveButtonLabel != null) {
            if (saveButtonLabel.isEmpty()) {
                saveButtonLabel = "Save As Draft";
            }
            Element saveButton = (Element) pluginManager.getPlugin(SaveAsDraftButton.class.getName());
            saveButton.setProperty(FormUtil.PROPERTY_ID, "saveAsDraft");
            saveButton.setProperty("label", saveButtonLabel);
            formActionList.add((FormAction) saveButton);
        }
        if (submitButtonLabel != null) {
            if (submitButtonLabel.isEmpty()) {
                submitButtonLabel = "Submit";
            }
            Element submitButton = (Element) pluginManager.getPlugin(SubmitButton.class.getName());
            submitButton.setProperty(FormUtil.PROPERTY_ID, "submit");
            submitButton.setProperty("label", submitButtonLabel);
            formActionList.add((FormAction) submitButton);
        }
        if (cancelButtonLabel != null) {
            if (cancelButtonLabel.isEmpty()) {
                cancelButtonLabel = "Cancel";
            }
            Element cancelButton = (Element) pluginManager.getPlugin(LinkButton.class.getName());
            cancelButton.setProperty(FormUtil.PROPERTY_ID, "cancel");
            cancelButton.setProperty("label", cancelButtonLabel);
            cancelButton.setProperty("url", cancelUrl);
            if (cancelButtonTarget != null) {
                cancelButton.setProperty("target", cancelButtonTarget);
            }
            formActionList.add((FormAction) cancelButton);
        }
        FormAction[] formActions = formActionList.toArray(new FormAction[0]);
        form = decorateFormActions(form, formActions);
View Full Code Here

   
    public static Element  removeEmptyValueChild(Form form, Element element, FormData formData) {
        Collection<Element> childs = element.getChildren();
        if (childs != null && childs.size() > 0) {
            for (Iterator<Element> it = childs.iterator(); it.hasNext();) {
                Element c = it.next();
                if (removeEmptyValueChild(form, c, formData) == null) {
                    it.remove();
                }
            }
           
View Full Code Here

        form.setProperty("url", "?_a=submit&_callback="+callback+"&_setting="+StringEscapeUtils.escapeHtml(callbackSetting)+"&_submitButtonLabel="+StringEscapeUtils.escapeHtml(buttonLabel));

        if(form != null){
            //if id field not exist, automatically add an id hidden field
            Element idElement = FormUtil.findElement(FormUtil.PROPERTY_ID, form, formData);
            if (idElement == null) {
                Collection<Element> formElements = form.getChildren();
                idElement = new HiddenField();
                idElement.setProperty(FormUtil.PROPERTY_ID, FormUtil.PROPERTY_ID);
                idElement.setParent(form);
                formElements.add(idElement);
            }
           
            // create new section for buttons
            Section section = new Section();
            section.setProperty(FormUtil.PROPERTY_ID, "section-actions");
            Collection<Element> sectionChildren = new ArrayList<Element>();
            section.setChildren(sectionChildren);
            Collection<Element> formChildren = form.getChildren(formData);
            if (formChildren == null) {
                formChildren = new ArrayList<Element>();
            }
            formChildren.add(section);

            // add new horizontal column to section
            Column column = new Column();
            column.setProperty("horizontal", "true");
            Collection<Element> columnChildren = new ArrayList<Element>();
            column.setChildren(columnChildren);
            sectionChildren.add(column);

            Element hiddenField = (Element) pluginManager.getPlugin(HiddenField.class.getName());
            hiddenField.setProperty(FormUtil.PROPERTY_ID, "_json");
            hiddenField.setProperty(FormUtil.PROPERTY_VALUE, json);
            columnChildren.add((Element) hiddenField);

            Element submitButton = (Element) pluginManager.getPlugin(SubmitButton.class.getName());
            submitButton.setProperty(FormUtil.PROPERTY_ID, "submit");
            submitButton.setProperty("label", buttonLabel);
            columnChildren.add((Element) submitButton);
        }

        // generate form HTML
        String formHtml = null;
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.