Package org.joget.apps.form.model

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


        // set headers
        Map<String, String> headers = getHeaderMap(formData);
        dataModel.put("headers", headers);

        // set rows
        FormRowSet rows = getRows(formData);
        dataModel.put("rows", rows);
       
        dataModel.put("customDecorator", getDecorator());

        String html = FormUtil.generateElementHtml(this, formData, template, dataModel);
View Full Code Here


    
    @Override
    public Boolean selfValidate(FormData formData) {
        Boolean valid = true;
       
        FormRowSet rowSet = getRows(formData);
        String id = FormUtil.getElementParameterName(this);
        String errorMsg = getPropertyString("errorMessage");
       
        String min = getPropertyString("validateMinRow");
        if (min != null && !min.isEmpty()) {
            try {
                int minNumber = Integer.parseInt(min);
                if (rowSet.size() < minNumber) {
                    valid = false;
                }
            } catch (Exception e) {}
        }
       
        String max = getPropertyString("validateMaxRow");
        if (max != null && !max.isEmpty()) {
            try {
                int maxNumber = Integer.parseInt(max);
                if (rowSet.size() > maxNumber) {
                    valid = false;
                }
            } catch (Exception e) {}
        }
       
View Full Code Here

        if (!obj.isNull(FormUtil.PROPERTY_PROPERTIES)) {
            JSONObject objProperty = obj.getJSONObject(FormUtil.PROPERTY_PROPERTIES);
            property = PropertyUtil.getPropertiesValueFromJson(objProperty.toString());

            if (property.containsKey(FormUtil.PROPERTY_OPTIONS)) {
                FormRowSet options = new FormRowSet();
                Object[] objs = (Object[]) property.get(FormUtil.PROPERTY_OPTIONS);

                for (Object o : objs) {
                    Map temp = (HashMap) o;
                    FormRow option = new FormRow();
                    for (String key : (Set<String>) temp.keySet()) {
                        option.setProperty(key, (String) temp.get(key));
                    }
                    options.add(option);
                }
                property.put(FormUtil.PROPERTY_OPTIONS, options);
            }
        }
View Full Code Here

            formData = new FormData();
        }
        FormLoadBinder binder = (FormLoadBinder) element.getOptionsBinder();
        String primaryKeyValue = (formData != null) ? element.getPrimaryKeyValue(formData) : null;
        if (binder != null && !isAjaxOptionsSupported(element, formData)) {
            FormRowSet data = binder.load(element, primaryKeyValue, formData);
            if (data != null) {
                formData.setOptionsBinderData(binder, data);
            }
        }
        Collection<Element> children = element.getChildren(formData);
View Full Code Here

            formData = new FormData();
        }
        FormLoadBinder binder = (FormLoadBinder) element.getLoadBinder();
        String primaryKeyValue = (formData != null) ? element.getPrimaryKeyValue(formData) : null;
        if (!(element instanceof AbstractSubForm) && binder != null) {
            FormRowSet data = binder.load(element, primaryKeyValue, formData);
            if (data != null) {
                formData.setLoadBinderData(binder, data);
            }
        }
        Collection<Element> children = element.getChildren(formData);
View Full Code Here

     */
    public static FormData executeElementFormatData(Element element, FormData formData) {
        // get store binder and rowset for element
        FormStoreBinder binder = FormUtil.findStoreBinder(element);
        if (binder != null) {
            FormRowSet rowSet = formData.getStoreBinderData(binder);
            if (rowSet == null) {
                rowSet = new FormRowSet();
                formData.setStoreBinderData(binder, rowSet);
            }

            // get element formatted data
            FormRowSet elementResult = element.formatData(formData);
            if (elementResult != null) {
                if (!elementResult.isMultiRow()) {
                    // get single row
                    FormRow elementRow = elementResult.get(0);

                    // append to consolidated row set
                    if (rowSet.isEmpty()) {
                        rowSet.add(elementRow);
                    } else {
View Full Code Here

        String id = element.getPropertyString(FormUtil.PROPERTY_ID);
        String value = element.getPropertyString(FormUtil.PROPERTY_VALUE);
        String paramName = FormUtil.getElementParameterName(element);
       
        if (formData != null) { // handle default value from options binder
            FormRowSet rowSet = formData.getOptionsBinderData(element, id);
            if (rowSet != null) {
               
                for (FormRow row : rowSet) {
                    Iterator<String> it = row.stringPropertyNames().iterator();
                    // get the key based on the "value" property
View Full Code Here

                values.add(val);
            }
        }
       
        if (formData != null) { // handle default value from options binder
            FormRowSet rowSet = formData.getOptionsBinderData(element, id);
            if (rowSet != null) {
               
                for (FormRow row : rowSet) {
                    Iterator<String> it = row.stringPropertyNames().iterator();
                    // get the key based on the "value" property
View Full Code Here

           
            Element controlElement = ajaxElement.getControlElement(formData);
            String[] controlValues = FormUtil.getElementPropertyValues(controlElement, formData);
           
            FormAjaxOptionsBinder binder = (FormAjaxOptionsBinder) element.getOptionsBinder();
            FormRowSet rowSet = binder.loadAjaxOptions(controlValues);
           
            if (rowSet != null) {
                optionsMap = new ArrayList<Map>();
                for (Map row : rowSet) {
                    optionsMap.add(row);
                }
            }
        } else {
            // load from "options" property
            Object optionProperty = element.getProperty(FormUtil.PROPERTY_OPTIONS);
            if (optionProperty != null && optionProperty instanceof Collection) {
                for (Map opt : (FormRowSet) optionProperty) {
                    optionsMap.add(opt);
                }
            }

            // load from binder if available
            if (formData != null) {
                String id = element.getPropertyString(FormUtil.PROPERTY_ID);
                FormRowSet rowSet = formData.getOptionsBinderData(element, id);
                if (rowSet != null) {
                    optionsMap = new ArrayList<Map>();
                    for (Map row : rowSet) {
                        optionsMap.add(row);
                    }
View Full Code Here

        FormLoadBinder loadBinder = e.getLoadBinder();
        FormLoadBinder optionsBinder = e.getOptionsBinder();
        if (loadBinder != null) {
            if (recursive) {
                // load form data
                FormRowSet rowSet = formData.getLoadBinderData(e);
                if (rowSet != null && !rowSet.isEmpty()) {
                    FormRow row = rowSet.get(0);
                    boolean useSubMap = !flatten && !(e instanceof Form);
                    if (useSubMap) {
                        // it's data from a different form, so put data into submap
                        Map<String, Object> subMap = new HashMap<String, Object>();
                        for (Iterator i=row.keySet().iterator(); i.hasNext();) {
                            String key = (String)i.next();
                            Object value = row.get(key);
                            subMap.put(key, value.toString());
                        }
                        String elementKey = e.getPropertyString(FormUtil.PROPERTY_ID);
                        data.put(elementKey, subMap);
                        result = subMap;
                    } else {
                        // it's the same as the original form, so put data into original map
                        for (Iterator i=row.keySet().iterator(); i.hasNext();) {
                            String key = (String)i.next();
                            Object value = row.get(key);
                            data.put(key, value.toString());
                        }
                    }
                }
            }
        } else if (includeReferenceElements && e instanceof FormReferenceDataRetriever) {
            // handle reference fields for elements implementing FormReferenceDataRetriever
            Collection<Map<String, Object>> subResults = new ArrayList<Map<String, Object>>();

            // get values
            String[] valueArray = FormUtil.getElementPropertyValues(e, formData);
            FormRowSet options = ((FormReferenceDataRetriever)e).loadFormRows(valueArray);
            for (Map opt: options) {
                Map optionRow = new HashMap(opt);
                subResults.add(optionRow);
            }
            if (!subResults.isEmpty()) {
View Full Code Here

TOP

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

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.