Example usage for java.io StringWriter append

List of usage examples for java.io StringWriter append

Introduction

In this page you can find the example usage for java.io StringWriter append.

Prototype

public StringWriter append(char c) 

Source Link

Document

Appends the specified character to this writer.

Usage

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderFieldGroupClose(Appendable writer, Map<String, Object> context,
        ModelForm.FieldGroup fieldGroup) throws IOException {
    String style = fieldGroup.getStyle();
    String id = fieldGroup.getId();
    FlexibleStringExpander titleNotExpanded = FlexibleStringExpander.getInstance(fieldGroup.getTitle());
    String title = titleNotExpanded.expandString(context);
    StringWriter sr = new StringWriter();
    sr.append("<@renderFieldGroupClose ");
    sr.append(" style=\"");
    if (style != null) {
        sr.append(style);/*from   w w  w . j a  v  a  2  s.  c  om*/
    }
    sr.append("\" id=\"");
    if (id != null) {
        sr.append(id);
    }
    sr.append("\" title=\"");
    if (title != null) {
        sr.append(title);
    }
    sr.append("\" />");
    executeMacro(writer, sr.toString());
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField,
        String value) throws IOException {
    String name = modelFormField.getParameterName(context);
    String action = modelFormField.getAction(context);
    String event = modelFormField.getEvent();
    String id = modelFormField.getCurrentContainerId(context);

    StringWriter sr = new StringWriter();
    sr.append("<@renderHiddenField ");
    sr.append(" name=\"");
    sr.append(name);/*from   w w w .j a  va2  s . c  om*/
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" id=\"");
    sr.append(id);
    sr.append("\" event=\"");
    if (event != null) {
        sr.append(event);
    }
    sr.append("\" action=\"");
    if (action != null) {
        sr.append(action);
    }
    sr.append("\" />");
    executeMacro(writer, sr.toString());
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm)
        throws IOException {
    String focusFieldName = modelForm.getfocusFieldName();
    String formName = modelForm.getCurrentFormName(context);
    String containerId = modelForm.getCurrentContainerId(context);
    String hasRequiredField = "";
    for (ModelFormField formField : modelForm.getFieldList()) {
        if (formField.getRequiredField()) {
            hasRequiredField = "Y";
            break;
        }/*w  w  w .ja  v a2s  .c  om*/
    }
    StringWriter sr = new StringWriter();
    sr.append("<@renderFormClose ");
    sr.append(" focusFieldName=\"");
    sr.append(focusFieldName);
    sr.append("\" formName=\"");
    sr.append(formName);
    sr.append("\" containerId=\"");
    sr.append(containerId);
    sr.append("\" hasRequiredField=\"");
    sr.append(hasRequiredField);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
    renderEndingBoundaryComment(writer, "Form Widget - Form Element", modelForm);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderResetField(Appendable writer, Map<String, Object> context, ResetField resetField)
        throws IOException {
    ModelFormField modelFormField = resetField.getModelFormField();
    String name = modelFormField.getParameterName(context);
    String className = "";
    String alert = "false";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }/*from w  w  w  . j a v a  2s  . c o m*/
    }
    String title = modelFormField.getTitle(context);

    StringWriter sr = new StringWriter();
    sr.append("<@renderResetField ");
    sr.append(" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" name=\"");
    sr.append(name);
    sr.append("\" title=\"");
    sr.append(title);
    sr.append("\" />");
    executeMacro(writer, sr.toString());

    this.appendTooltip(writer, context, modelFormField);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm)
        throws IOException {
    Integer itemIndex = (Integer) context.get("itemIndex");
    String altRowStyles = "";
    String evenRowStyle = "";
    String oddRowStyle = "";
    if (itemIndex != null) {
        altRowStyles = modelForm.getStyleAltRowStyle(context);
        if (itemIndex.intValue() % 2 == 0) {
            evenRowStyle = modelForm.getEvenRowStyle();
        } else {/*  w w  w  .  ja  v  a  2  s . co  m*/
            oddRowStyle = FlexibleStringExpander.expandString(modelForm.getOddRowStyle(), context);
        }
    }
    StringWriter sr = new StringWriter();
    sr.append("<@renderFormatItemRowOpen ");
    sr.append(" formName=\"");
    sr.append(modelForm.getName());
    sr.append("\" itemIndex=");
    sr.append(Integer.toString(itemIndex));
    sr.append(" altRowStyles=\"");
    sr.append(altRowStyles);
    sr.append("\" evenRowStyle=\"");
    sr.append(evenRowStyle);
    sr.append("\" oddRowStyle=\"");
    sr.append(oddRowStyle);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void makeHiddenFormLinkForm(Appendable writer, String target, String targetType, String targetWindow,
        List<WidgetWorker.Parameter> parameterList, ModelFormField modelFormField, HttpServletRequest request,
        HttpServletResponse response, Map<String, Object> context) throws IOException {
    StringBuilder actionUrl = new StringBuilder();
    WidgetWorker.buildHyperlinkUrl(actionUrl, target, targetType, null, null, false, false, true, request,
            response, context);//from  w w w.  j  a  va2s . c om
    String name = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
    StringBuilder parameters = new StringBuilder();
    parameters.append("[");
    for (WidgetWorker.Parameter parameter : parameterList) {
        if (parameters.length() > 1) {
            parameters.append(",");
        }
        parameters.append("{'name':'");
        parameters.append(parameter.getName());
        parameters.append("'");
        parameters.append(",'value':'");
        parameters.append(StringUtil.htmlEncoder.encode(parameter.getValue(context)));
        parameters.append("'}");
    }
    parameters.append("]");

    StringWriter sr = new StringWriter();
    sr.append("<@makeHiddenFormLinkForm ");
    sr.append("actionUrl=\"");
    sr.append(actionUrl.toString());
    sr.append("\" name=\"");
    sr.append(name);
    sr.append("\" parameters=");
    sr.append(parameters.toString());
    sr.append(" targetWindow=\"");
    sr.append(targetWindow);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

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);

        }/*from ww w.  java2s  .  c  om*/
    }
    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());
        appendWhitespace(writer);
    }

    renderEndingBoundaryComment(writer, "Form Widget - Form Element (Multi)", modelForm);
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner)
        throws IOException {
    String style = banner.getStyle(context);
    String leftStyle = banner.getLeftTextStyle(context);
    if (UtilValidate.isEmpty(leftStyle))
        leftStyle = style;//from w w  w  .j a v a2 s .  c o  m
    String rightStyle = banner.getRightTextStyle(context);
    if (UtilValidate.isEmpty(rightStyle))
        rightStyle = style;

    String leftText = banner.getLeftText(context);
    if (leftText == null) {
        leftText = "";
    }

    String text = banner.getText(context);
    if (text == null) {
        text = "";
    }

    String rightText = banner.getRightText(context);
    if (rightText == null) {
        rightText = "";
    }

    StringWriter sr = new StringWriter();
    sr.append("<@renderBanner ");
    sr.append(" style=\"");
    sr.append(style);
    sr.append("\" leftStyle=\"");
    sr.append(leftStyle);
    sr.append("\" rightStyle=\"");
    sr.append(rightStyle);
    sr.append("\" leftText=\"");
    sr.append(leftText);
    sr.append("\" text=\"");
    sr.append(text);
    sr.append("\" rightText=\"");
    sr.append(rightText);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description,
        String confirmation, ModelFormField modelFormField, HttpServletRequest request,
        HttpServletResponse response, Map<String, Object> context) throws IOException {
    if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
        String hiddenFormName = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
        String event = "";
        String action = "";
        String imgSrc = "";

        if (UtilValidate.isNotEmpty(modelFormField.getEvent())
                && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
            event = modelFormField.getEvent();
            action = modelFormField.getAction(context);
        }//  w  w w  . ja v  a 2 s. co  m

        if (UtilValidate.isNotEmpty(request.getAttribute("image"))) {
            imgSrc = request.getAttribute("image").toString();
        }

        StringWriter sr = new StringWriter();
        sr.append("<@makeHiddenFormLinkAnchor ");
        sr.append("linkStyle=\"");
        sr.append(linkStyle == null ? "" : linkStyle);
        sr.append("\" hiddenFormName=\"");
        sr.append(hiddenFormName == null ? "" : hiddenFormName);
        sr.append("\" event=\"");
        sr.append(event);
        sr.append("\" action=\"");
        sr.append(action);
        sr.append("\" imgSrc=\"");
        sr.append(imgSrc);
        sr.append("\" description=\"");
        sr.append(description);
        sr.append("\" confirmation =\"");
        sr.append(confirmation);
        sr.append("\" />");
        executeMacro(writer, sr.toString());
    }
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context,
        ModelForm.FieldGroup fieldGroup) throws IOException {
    String style = fieldGroup.getStyle();
    String id = fieldGroup.getId();
    FlexibleStringExpander titleNotExpanded = FlexibleStringExpander.getInstance(fieldGroup.getTitle());
    String title = titleNotExpanded.expandString(context);
    Boolean collapsed = fieldGroup.initiallyCollapsed();
    String collapsibleAreaId = fieldGroup.getId() + "_body";
    Boolean collapsible = fieldGroup.collapsible();
    String expandToolTip = "";
    String collapseToolTip = "";

    if (UtilValidate.isNotEmpty(style) || UtilValidate.isNotEmpty(id) || UtilValidate.isNotEmpty(title)) {
        if (fieldGroup.collapsible()) {
            Map<String, Object> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
            //Map<String, Object> paramMap = UtilGenerics.checkMap(context.get("requestParameters"));
            if (uiLabelMap != null) {
                expandToolTip = (String) uiLabelMap.get("CommonExpand");
                collapseToolTip = (String) uiLabelMap.get("CommonCollapse");
            }//from  w  w w. j  a v a  2  s.c om
        }
    }
    StringWriter sr = new StringWriter();
    sr.append("<@renderFieldGroupOpen ");
    sr.append(" style=\"");
    if (style != null) {
        sr.append(style);
    }
    sr.append("\" id=\"");
    sr.append(id);
    sr.append("\" title=\"");
    sr.append(title);
    sr.append("\" collapsed=");
    sr.append(Boolean.toString(collapsed));
    sr.append(" collapsibleAreaId=\"");
    sr.append(collapsibleAreaId);
    sr.append("\" collapsible=");
    sr.append(Boolean.toString(collapsible));
    sr.append(" expandToolTip=\"");
    sr.append(expandToolTip);
    sr.append("\" collapseToolTip=\"");
    sr.append(collapseToolTip);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
}