Package org.joget.apps.form.model

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


    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) {
                form = FormUtil.findRootForm(element);
            }
            if (form != null) {
View Full Code Here


    @Override
    public FormRowSet store(Element element, FormRowSet rows, FormData formData) {
        if (rows != null && !rows.isEmpty()) {
            // find root form
            Form form = FormUtil.findRootForm(element);
            form = findFormForStoreBinder(form);
            if (form == null) {
                form = FormUtil.findRootForm(element);
            }
            if (form == null) {
                return rows;
            }

            // store form data
            AppService appService = (AppService) FormUtil.getApplicationContext().getBean("appService");
            String primaryKeyValue = form.getPrimaryKeyValue(formData);
            rows = appService.storeFormData(form, rows, primaryKeyValue);
        }
        return rows;
    }
View Full Code Here

     * Returns the Form that is tied to this binder.
     * @param element
     * @return
     */
    protected Form findFormForLoadBinder(Element element) {
        Form form = null;
        if (element != null) {
            if (element.getLoadBinder() == this) {
                if (element instanceof AbstractSubForm) {
                    Collection<Element> children = element.getChildren();
                    if (!children.isEmpty()) {
View Full Code Here

    /**
     * Returns the Form that is tied to this binder.
     */
    protected Form findFormForStoreBinder(Element element) {
        Form form = null;
        if (element != null) {
            if (element.getStoreBinder() == this) {
                if (element instanceof AbstractSubForm) {
                    Collection<Element> children = element.getChildren();
                    if (!children.isEmpty()) {
View Full Code Here

        }
        if (assignment != null) {
            formData.setProcessId(assignment.getProcessId());
        }
       
        Form form = null;
        FormDefinitionDao formDefinitionDao = (FormDefinitionDao) AppUtil.getApplicationContext().getBean("formDefinitionDao");
        FormService formService = (FormService) AppUtil.getApplicationContext().getBean("formService");
        FormDefinition formDef = formDefinitionDao.loadById(formId, appDef);
        String formJson = formDef.getJson();
View Full Code Here

    public String renderTemplate(FormData formData, Map dataModel) {
       
        // set subform html
        String elementMetaData = ((Boolean) dataModel.get("includeMetaData")) ? FormUtil.generateElementMetaData(this) : "";
        Collection<Element> childElements = getChildren();
        Form subForm = (childElements.size() > 0) ? (Form) getChildren().iterator().next() : null;
        String label = getPropertyString("label");
        String cellClass = ((Boolean) dataModel.get("includeMetaData")) ? "form-cell" : "subform-cell";
        String noFrame = ("true".equalsIgnoreCase(getPropertyString("noframe"))) ? " no-frame" : "";
        String readonly = ("true".equalsIgnoreCase(getPropertyString(FormUtil.PROPERTY_READONLY))) ? " readonly" : "";
        String html = "<div class='" + cellClass + "' " + elementMetaData + "><div class='subform-container"+noFrame+readonly+"'>";
        html += "<span class='subform-title'>" + label + "</span>";
        if (subForm != null) {
            String subFormHtml = subForm.render(formData, false);
            subFormHtml = subFormHtml.replaceAll("\"form-section", "\"subform-section");
            subFormHtml = subFormHtml.replaceAll("\"form-column", "\"subform-column");
            subFormHtml = subFormHtml.replaceAll("\"form-cell", "\"subform-cell");
            html += subFormHtml;
        } else {
View Full Code Here

        }

        // determine table name
        String tableName = "";
        if (element != null) {
            Form form = FormUtil.findRootForm(element);
            tableName = form.getPropertyString(FormUtil.PROPERTY_TABLE_NAME);
            if (tableName == null) {
                tableName = "";
            }
        }
View Full Code Here

    public String embedForm(ModelMap model, HttpServletRequest request, HttpServletResponse response, @RequestParam("_submitButtonLabel") String buttonLabel, @RequestParam("_json") String json, @RequestParam("_callback") String callback, @RequestParam("_setting") String callbackSetting, @RequestParam(required = false) String id, @RequestParam(value = "_a", required = false) String action) throws JSONException {
        FormData formData = new FormData();
        if(id != null && !id.isEmpty()){
            formData.setPrimaryKeyValue(id);
        }
        Form form = formService.loadFormFromJson(json, formData);

        if(callbackSetting == null || (callbackSetting != null && callbackSetting.isEmpty())){
            callbackSetting = "{}";
        }

        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;

        if("submit".equals(action)){
            formData = formService.retrieveFormDataFromRequest(formData, request);
            formData = formService.executeFormActions(form, formData);

            // check for validation errors
            Map<String, String> errors = formData.getFormErrors();
            int errorCount = 0;
            if (!formData.getStay() && errors == null || errors.isEmpty()) {
                // render normal template
                formHtml = formService.generateElementHtml(form, formData);
               
                //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

        }
        String formUrlWithContextPath = AppUtil.getRequestContextPath() + formUrl;
       
        PackageActivityForm startFormDef = appService.viewStartProcessForm(appId, appDef.getVersion().toString(), processDefId, formData, formUrlWithContextPath);
        if (startFormDef != null && startFormDef.getForm() != null) {
            Form startForm = startFormDef.getForm();

            // generate form HTML
            String formHtml = formService.retrieveFormHtml(startForm, formData);
            String formJson = formService.generateElementJson(startForm);
View Full Code Here

        PackageActivityForm startFormDef = appService.viewStartProcessForm(appId, appDef.getVersion().toString(), processDefId, formData, formUrl);
        WorkflowProcessResult result = appService.submitFormToStartProcess(appId, version, processDefId, formData, variableMap, recordId, formUrl);
        if (startFormDef != null && (startFormDef.getForm() != null || PackageActivityForm.ACTIVITY_FORM_TYPE_EXTERNAL.equals(startFormDef.getType()))) {
            if (result == null) {
                // validation error, get form
                Form startForm = startFormDef.getForm();

                // generate form HTML
                String formHtml = formService.retrieveFormErrorHtml(startForm, formData);
                String formJson = formService.generateElementJson(startForm);
View Full Code Here

TOP

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

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.