Package org.joget.apps.form.model

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


            }
        }
    }
   
    public static FormRowSet getAjaxOptionsBinderData(String dependencyValue, AppDefinition appDef, String nonce, String binderData) {
        FormRowSet rowSet = new FormRowSet();
       
        if (binderData != null && !binderData.isEmpty() && nonce != null && !nonce.isEmpty() && appDef != null) {
            try {
                binderData = URLDecoder.decode(binderData, "UTF-8");
                binderData = SecurityUtil.decrypt(binderData);
View Full Code Here


        String html = FormUtil.generateElementHtml(this, formData, template, dataModel);
        return html;
    }
   
    public FormRowSet formatData(FormData formData) {
        FormRowSet rowSet = null;

        // get value
        String id = getPropertyString(FormUtil.PROPERTY_ID);
        if (id != null) {
            String value = FormUtil.getElementPropertyValue(this, formData);
            if (getPropertyString("dataFormat") != null && !getPropertyString("dataFormat").isEmpty()) {
                try {
                    String displayFormat = getJavaDateFormat(getPropertyString("format"));
                    if (!displayFormat.equals(getPropertyString("dataFormat"))) {
                        SimpleDateFormat data = new SimpleDateFormat(getPropertyString("dataFormat"));
                        SimpleDateFormat display = new SimpleDateFormat(displayFormat);
                        Date date = display.parse(value);
                        value = data.format(date);
                    }
                } catch (Exception e) {}
            }
            if (value != null) {
                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
                result.setProperty(id, value);
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }

        return rowSet;
    }
View Full Code Here

        return formData;
    }
   
    @Override
    public FormRowSet formatData(FormData formData) {
        FormRowSet rowSet = null;

        // get value
        String id = getPropertyString(FormUtil.PROPERTY_ID);
        if (id != null) {
            String value = FormUtil.getElementPropertyValue(this, formData);
            if (value != null) {
                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
               
                // check if the file is in temp file
                File file = FileManager.getFileByPath(value);
                if (file != null) {
                    result.putTempFilePath(id, value);
                    result.setProperty(id, file.getName());
                   
                    String paramName = FormUtil.getElementParameterName(this);
                    formData.addRequestParameterValues(paramName, new String[]{file.getName()});
                } else {
                    result.setProperty(id, value);
                }
               
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }

        return rowSet;
    }
View Full Code Here

        return "Check Box Element";
    }

    @Override
    public FormRowSet formatData(FormData formData) {
        FormRowSet rowSet = null;

        // get value
        String id = getPropertyString(FormUtil.PROPERTY_ID);
        if (id != null) {
            String[] values = FormUtil.getElementPropertyValues(this, formData);
            if (values != null && values.length > 0) {
                // check for empty submission via parameter
                String[] paramValues = FormUtil.getRequestParameterValues(this, formData);
                if ((paramValues == null || paramValues.length == 0) && FormUtil.isFormSubmitted(this, formData)) {
                    values = new String[]{""};
                }

                // formulate values
                String delimitedValue = FormUtil.generateElementPropertyValues(values);

                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
                result.setProperty(id, delimitedValue);
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }

        return rowSet;
    }
View Full Code Here

        return formData;
    }
   
    @Override
    public FormRowSet formatData(FormData formData) {
        FormRowSet rowSet = null;

        // get value
        String id = getPropertyString(FormUtil.PROPERTY_ID);
        if (id != null) {
            String value = FormUtil.getElementPropertyValue(this, formData);
            if (value != null) {
                if (value.equals(SECURE_VALUE)) {
                    value = getPropertyString(FormUtil.PROPERTY_VALUE);
                    // load from binder if available
                    if (formData != null) {
                        String binderValue = formData.getLoadBinderDataProperty(this, id);
                        if (binderValue != null) {
                            value = binderValue;
                        }
                    } else {
                        value = SecurityUtil.encrypt(value);
                    }
                } else {
                    value = SecurityUtil.encrypt(value);
                }
               
                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
                result.setProperty(id, value);
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }

        return rowSet;
    }
View Full Code Here

        return html;
    }

    @Override
    public FormRowSet formatData(FormData formData) {
        FormRowSet rowSet = null;

        // get value
        String id = getPropertyString(FormUtil.PROPERTY_ID);
        if (id != null) {
            String value = FormUtil.getElementPropertyValue(this, formData);
            if (value == null || value.trim().isEmpty()) {
                // generate new value
                value = getGeneratedValue(formData);
                setProperty(FormUtil.PROPERTY_VALUE, value);
               
                String paramName = FormUtil.getElementParameterName(this);
                formData.addRequestParameterValues(paramName, new String[] {value});
            }
            if (value != null) {
                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
                result.setProperty(id, value);
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }

        return rowSet;
    }
View Full Code Here

        return formData;
    }

    @Override
    public FormRowSet formatData(FormData formData) {
        FormRowSet rowSet = null;

        // get value
        String id = getPropertyString(FormUtil.PROPERTY_ID);
        if (id != null) {
            String[] values = FormUtil.getElementPropertyValues(this, formData);
            if (values != null && values.length > 0) {
                // check for empty submission via parameter
                String[] paramValues = FormUtil.getRequestParameterValues(this, formData);
                if ((paramValues == null || paramValues.length == 0) && FormUtil.isFormSubmitted(this, formData)) {
                    values = new String[]{""};
                }

                // formulate values
                String delimitedValue = FormUtil.generateElementPropertyValues(values);

                // set value into Properties and FormRowSet object
                FormRow result = new FormRow();
                result.setProperty(id, delimitedValue);
                rowSet = new FormRowSet();
                rowSet.add(result);
            }
        }

        return rowSet;
    }
View Full Code Here

    public boolean useAjax() {
        return "true".equalsIgnoreCase(getPropertyString("useAjax"));
    }

    public FormRowSet loadAjaxOptions(String[] dependencyValues) {
        FormRowSet results = new FormRowSet();
        results.setMultiRow(true);
        //Using filtered formset to ensure the returned result is clean with no unnecessary nulls
        FormRowSet filtered = new FormRowSet();
        filtered.setMultiRow(true);
       
        try {
            // get form
            String formDefId = (String) getProperty("formDefId");
            String tableName = getTableName(formDefId);
            if (tableName != null) {

                String condition = null;
                Object[] conditionParams = null;
               
                String extraCondition = (String) getProperty("extraCondition");
                if (extraCondition != null && !extraCondition.trim().isEmpty()) {
                    condition = " WHERE " + extraCondition;
                }
               
                if (dependencyValues != null && getProperty("groupingColumn") != null) {
                    if (extraCondition == null || extraCondition.trim().isEmpty()) {
                        condition = " WHERE ";
                    } else {
                        condition += " AND ";
                    }
                   
                    if (dependencyValues.length > 0) {
                        condition += "e.customProperties." + getProperty("groupingColumn").toString() + " in (";
                        for (String s : dependencyValues) {
                            condition += "?,";
                        }
                        condition = condition.substring(0, condition.length()-1) + ")";
                       
                        conditionParams = dependencyValues;
                    } else {
                        condition += "e.customProperties." + getProperty("groupingColumn").toString() + " is empty";
                    }
                }

                String labelColumn = (String) getProperty("labelColumn");

                // get form data
                FormDataDao formDataDao = (FormDataDao) AppUtil.getApplicationContext().getBean("formDataDao");
                results = formDataDao.find(formDefId, tableName, condition, conditionParams, labelColumn, false, null, null);

                if (results != null) {
                    if ("true".equals(getPropertyString("addEmptyOption"))) {
                        FormRow emptyRow = new FormRow();
                        emptyRow.setProperty(FormUtil.PROPERTY_VALUE, "");
                        emptyRow.setProperty(FormUtil.PROPERTY_LABEL, getPropertyString("emptyLabel"));
                        filtered.add(emptyRow);
                    }

                    //Determine id column. Setting to default if not specified
                    String idColumn = (String) getProperty("idColumn");
                    idColumn = (idColumn == null || "".equals(idColumn)) ? FormUtil.PROPERTY_ID : idColumn;

                    String groupingColumn = (String) getProperty("groupingColumn");

                    // loop thru results to set value and label
                    for (FormRow row : results) {
                        String id = row.getProperty(idColumn);
                        String label = row.getProperty(labelColumn);
                        String grouping = "";
                        if (groupingColumn != null && !groupingColumn.isEmpty() && row.containsKey(groupingColumn)) {
                            grouping = row.getProperty(groupingColumn);
                        }

                        if (id != null && !id.isEmpty() && label != null && !label.isEmpty()) {
                            row.setProperty(FormUtil.PROPERTY_VALUE, id);
                            row.setProperty(FormUtil.PROPERTY_LABEL, label);
                            row.setProperty(FormUtil.PROPERTY_GROUPING, grouping);

                            filtered.add(row);
                        }
                    }
                }
            }
        } catch (Exception e) {
View Full Code Here

    }

    @Override
    public FormRowSet load(Element element, String primaryKey, FormData formData) {
       
        FormRowSet results = null;
        if (primaryKey != null && primaryKey.trim().length() > 0) {
            AppService appService = (AppService) FormUtil.getApplicationContext().getBean("appService");
            Form form = FormUtil.findRootForm(element);
            form = findFormForLoadBinder(form);
            if (form == null) {
View Full Code Here

                //convert submitted
                JSONObject jsonResult = new JSONObject();
               
                //get binder of main form
                FormStoreBinder mainBinder = form.getStoreBinder();
                FormRowSet rows = formData.getStoreBinderData(mainBinder);
               
                for (FormRow row : rows) {
                    for (Object o : row.keySet()) {
                        jsonResult.accumulate(o.toString(), row.get(o));
                    }
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.