Search in sources :

Example 6 with ModelSingleForm

use of org.apache.ofbiz.widget.model.ModelSingleForm in project ofbiz-framework by apache.

the class MacroFormRenderer method renderMultiFormClose.

public void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
    // FIXME copy from HtmlFormRenderer.java (except for the closing form tag itself, that is now converted)
    Iterator<ModelFormField> submitFields = modelForm.getMultiSubmitFields().iterator();
    while (submitFields.hasNext()) {
        ModelFormField submitField = submitFields.next();
        if (submitField != null && submitField.shouldUse(context)) {
            // Threw this in that as a hack to keep the submit button from expanding the first field
            // Needs a more rugged solution
            // WARNING: this method (renderMultiFormClose) must be called after the
            // table that contains the list has been closed (to avoid validation errors) so
            // we cannot call here the methods renderFormatItemRowCell*: for this reason
            // they are now commented.
            // this.renderFormatItemRowCellOpen(writer, context, modelForm, submitField);
            // this.renderFormatItemRowCellClose(writer, context, modelForm, submitField);
            // this.renderFormatItemRowCellOpen(writer, context, modelForm, submitField);
            submitField.renderFieldString(writer, context, this);
        // this.renderFormatItemRowCellClose(writer, context, modelForm, submitField);
        }
    }
    StringWriter sr = new StringWriter();
    sr.append("<@renderMultiFormClose />");
    executeMacro(writer, sr.toString());
    // see if there is anything that needs to be added outside of the multi-form
    Map<String, Object> wholeFormContext = UtilGenerics.checkMap(context.get("wholeFormContext"));
    Appendable postMultiFormWriter = wholeFormContext != null ? (Appendable) wholeFormContext.get("postMultiFormWriter") : null;
    if (postMultiFormWriter != null) {
        writer.append(postMultiFormWriter.toString());
    }
    if (modelForm instanceof ModelSingleForm) {
        renderEndingBoundaryComment(writer, "Form Widget - Form Element", modelForm);
    } else {
        renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm);
    }
}
Also used : StringWriter(java.io.StringWriter) ModelFormField(org.apache.ofbiz.widget.model.ModelFormField) ModelSingleForm(org.apache.ofbiz.widget.model.ModelSingleForm)

Aggregations

ModelSingleForm (org.apache.ofbiz.widget.model.ModelSingleForm)6 StringWriter (java.io.StringWriter)5 ModelFormField (org.apache.ofbiz.widget.model.ModelFormField)3 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 LinkedList (java.util.LinkedList)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 GeneralException (org.apache.ofbiz.base.util.GeneralException)1 ArtifactInfoContext (org.apache.ofbiz.widget.artifact.ArtifactInfoContext)1 ArtifactInfoGatherer (org.apache.ofbiz.widget.artifact.ArtifactInfoGatherer)1 SAXException (org.xml.sax.SAXException)1