Search in sources :

Example 26 with ModelFormField

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

the class MacroFormRenderer method renderResetField.

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";
        }
    }
    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);
}
Also used : StringWriter(java.io.StringWriter) ModelFormField(org.apache.ofbiz.widget.model.ModelFormField)

Example 27 with ModelFormField

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

the class MacroFormRenderer method renderDateFindField.

public void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField) throws IOException {
    ModelFormField modelFormField = dateFindField.getModelFormField();
    Locale locale = (Locale) context.get("locale");
    String opEquals = UtilProperties.getMessage("conditionalUiLabels", "equals", locale);
    String opGreaterThan = UtilProperties.getMessage("conditionalUiLabels", "greater_than", locale);
    String opSameDay = UtilProperties.getMessage("conditionalUiLabels", "same_day", locale);
    String opGreaterThanFromDayStart = UtilProperties.getMessage("conditionalUiLabels", "greater_than_from_day_start", locale);
    String opLessThan = UtilProperties.getMessage("conditionalUiLabels", "less_than", locale);
    String opUpToDay = UtilProperties.getMessage("conditionalUiLabels", "up_to_day", locale);
    String opUpThruDay = UtilProperties.getMessage("conditionalUiLabels", "up_thru_day", locale);
    String opIsEmpty = UtilProperties.getMessage("conditionalUiLabels", "is_empty", locale);
    String conditionGroup = modelFormField.getConditionGroup();
    Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
    if (uiLabelMap == null) {
        Debug.logWarning("Could not find uiLabelMap in context", module);
    }
    String localizedInputTitle = "", localizedIconTitle = "";
    String className = "";
    String alert = "false";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }
    }
    String name = modelFormField.getParameterName(context);
    // the default values for a timestamp
    int size = 25;
    int maxlength = 30;
    String dateType = dateFindField.getType();
    if ("date".equals(dateType)) {
        size = maxlength = 10;
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatDate");
        }
    } else if ("time".equals(dateFindField.getType())) {
        size = maxlength = 8;
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatTime");
        }
    } else {
        if (uiLabelMap != null) {
            localizedInputTitle = uiLabelMap.get("CommonFormatDateTime");
        }
    }
    String value = modelFormField.getEntry(context, dateFindField.getDefaultValue(context));
    if (value == null) {
        value = "";
    }
    // search for a localized label for the icon
    if (uiLabelMap != null) {
        localizedIconTitle = uiLabelMap.get("CommonViewCalendar");
    }
    String formName = "";
    String defaultDateTimeString = "";
    StringBuilder imgSrc = new StringBuilder();
    // add calendar pop-up button and seed data IF this is not a "time" type date-find
    if (!"time".equals(dateFindField.getType())) {
        ModelForm modelForm = modelFormField.getModelForm();
        formName = FormRenderer.getCurrentFormName(modelForm, context);
        defaultDateTimeString = UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context)));
        this.appendContentUrl(imgSrc, "/images/cal.gif");
    }
    String defaultOptionFrom = dateFindField.getDefaultOptionFrom(context);
    String defaultOptionThru = dateFindField.getDefaultOptionThru(context);
    String value2 = modelFormField.getEntry(context);
    if (value2 == null) {
        value2 = "";
    }
    if (context.containsKey("parameters")) {
        Map<String, Object> parameters = UtilGenerics.checkMap(context.get("parameters"));
        if (parameters.containsKey(name + "_fld0_value")) {
            value = (String) parameters.get(name + "_fld0_value");
        }
        if (parameters.containsKey(name + "_fld1_value")) {
            value2 = (String) parameters.get(name + "_fld1_value");
        }
    }
    String titleStyle = "";
    if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
        titleStyle = modelFormField.getTitleStyle();
    }
    String tabindex = modelFormField.getTabindex();
    StringWriter sr = new StringWriter();
    sr.append("<@renderDateFindField ");
    sr.append(" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" name=\"");
    sr.append(name);
    sr.append("\" localizedInputTitle=\"");
    sr.append(localizedInputTitle);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" value2=\"");
    sr.append(value2);
    sr.append("\" size=\"");
    sr.append(Integer.toString(size));
    sr.append("\" maxlength=\"");
    sr.append(Integer.toString(maxlength));
    sr.append("\" dateType=\"");
    sr.append(dateType);
    sr.append("\" formName=\"");
    sr.append(formName);
    sr.append("\" defaultDateTimeString=\"");
    sr.append(defaultDateTimeString);
    sr.append("\" imgSrc=\"");
    sr.append(imgSrc.toString());
    sr.append("\" conditionGroup=\"");
    sr.append(conditionGroup);
    sr.append("\" localizedIconTitle=\"");
    sr.append(localizedIconTitle);
    sr.append("\" titleStyle=\"");
    sr.append(titleStyle);
    sr.append("\" defaultOptionFrom=\"");
    sr.append(defaultOptionFrom);
    sr.append("\" defaultOptionThru=\"");
    sr.append(defaultOptionThru);
    sr.append("\" opEquals=\"");
    sr.append(opEquals);
    sr.append("\" opSameDay=\"");
    sr.append(opSameDay);
    sr.append("\" opGreaterThanFromDayStart=\"");
    sr.append(opGreaterThanFromDayStart);
    sr.append("\" opGreaterThan=\"");
    sr.append(opGreaterThan);
    sr.append("\" opGreaterThan=\"");
    sr.append(opGreaterThan);
    sr.append("\" opLessThan=\"");
    sr.append(opLessThan);
    sr.append("\" opUpToDay=\"");
    sr.append(opUpToDay);
    sr.append("\" opUpThruDay=\"");
    sr.append(opUpThruDay);
    sr.append("\" opIsEmpty=\"");
    sr.append(opIsEmpty);
    sr.append("\" tabindex=\"");
    sr.append(tabindex);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
    this.appendTooltip(writer, context, modelFormField);
}
Also used : Locale(java.util.Locale) StringWriter(java.io.StringWriter) ModelFormField(org.apache.ofbiz.widget.model.ModelFormField) ModelForm(org.apache.ofbiz.widget.model.ModelForm)

Example 28 with ModelFormField

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

the class MacroFormRenderer method renderRangeFindField.

public void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField) throws IOException {
    ModelFormField modelFormField = rangeFindField.getModelFormField();
    Locale locale = (Locale) context.get("locale");
    String opEquals = UtilProperties.getMessage("conditionalUiLabels", "equals", locale);
    String opGreaterThan = UtilProperties.getMessage("conditionalUiLabels", "greater_than", locale);
    String opGreaterThanEquals = UtilProperties.getMessage("conditionalUiLabels", "greater_than_equals", locale);
    String opLessThan = UtilProperties.getMessage("conditionalUiLabels", "less_than", locale);
    String opLessThanEquals = UtilProperties.getMessage("conditionalUiLabels", "less_than_equals", locale);
    String conditionGroup = modelFormField.getConditionGroup();
    String className = "";
    String alert = "false";
    if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
        className = modelFormField.getWidgetStyle();
        if (modelFormField.shouldBeRed(context)) {
            alert = "true";
        }
    }
    String name = modelFormField.getParameterName(context);
    String size = Integer.toString(rangeFindField.getSize());
    String value = modelFormField.getEntry(context, rangeFindField.getDefaultValue(context));
    if (value == null) {
        value = "";
    }
    Integer maxlength = rangeFindField.getMaxlength();
    String autocomplete = "";
    if (!rangeFindField.getClientAutocompleteField()) {
        autocomplete = "off";
    }
    String titleStyle = modelFormField.getTitleStyle();
    if (titleStyle == null) {
        titleStyle = "";
    }
    String defaultOptionFrom = rangeFindField.getDefaultOptionFrom();
    String value2 = modelFormField.getEntry(context);
    if (value2 == null) {
        value2 = "";
    }
    String defaultOptionThru = rangeFindField.getDefaultOptionThru();
    String tabindex = modelFormField.getTabindex();
    StringWriter sr = new StringWriter();
    sr.append("<@renderRangeFindField ");
    sr.append(" className=\"");
    sr.append(className);
    sr.append("\" alert=\"");
    sr.append(alert);
    sr.append("\" name=\"");
    sr.append(name);
    sr.append("\" value=\"");
    sr.append(value);
    sr.append("\" size=\"");
    sr.append(size);
    sr.append("\" maxlength=\"");
    if (maxlength != null) {
        sr.append(Integer.toString(maxlength));
    }
    sr.append("\" autocomplete=\"");
    sr.append(autocomplete);
    sr.append("\" titleStyle=\"");
    sr.append(titleStyle);
    sr.append("\" defaultOptionFrom=\"");
    sr.append(defaultOptionFrom);
    sr.append("\" opEquals=\"");
    sr.append(opEquals);
    sr.append("\" opGreaterThan=\"");
    sr.append(opGreaterThan);
    sr.append("\" opGreaterThanEquals=\"");
    sr.append(opGreaterThanEquals);
    sr.append("\" opLessThan=\"");
    sr.append(opLessThan);
    sr.append("\" opLessThanEquals=\"");
    sr.append(opLessThanEquals);
    sr.append("\" value2=\"");
    sr.append(value2);
    sr.append("\" defaultOptionThru=\"");
    sr.append(defaultOptionThru);
    sr.append("\" conditionGroup=\"");
    sr.append(conditionGroup);
    sr.append("\" tabindex=\"");
    sr.append(tabindex);
    sr.append("\" />");
    executeMacro(writer, sr.toString());
    this.appendTooltip(writer, context, modelFormField);
}
Also used : Locale(java.util.Locale) StringWriter(java.io.StringWriter) ModelFormField(org.apache.ofbiz.widget.model.ModelFormField)

Example 29 with ModelFormField

use of org.apache.ofbiz.widget.model.ModelFormField 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)

Example 30 with ModelFormField

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

the class MacroFormRenderer method renderHyperlinkField.

public void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField) throws IOException {
    this.request.setAttribute("image", hyperlinkField.getImageLocation(context));
    ModelFormField modelFormField = hyperlinkField.getModelFormField();
    String encodedAlternate = encode(hyperlinkField.getAlternate(context), modelFormField, context);
    String encodedImageTitle = encode(hyperlinkField.getImageTitle(context), modelFormField, context);
    this.request.setAttribute("alternate", encodedAlternate);
    this.request.setAttribute("imageTitle", encodedImageTitle);
    this.request.setAttribute("descriptionSize", hyperlinkField.getSize());
    this.request.setAttribute("id", hyperlinkField.getId(context));
    this.request.setAttribute("width", hyperlinkField.getWidth());
    this.request.setAttribute("height", hyperlinkField.getHeight());
    makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getUrlMode(), hyperlinkField.getTarget(context), hyperlinkField.getParameterMap(context, modelFormField.getEntityName(), modelFormField.getServiceName()), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context), hyperlinkField.getConfirmation(context), modelFormField, this.request, this.response, context);
    this.appendTooltip(writer, context, modelFormField);
    this.request.removeAttribute("image");
    this.request.removeAttribute("descriptionSize");
}
Also used : ModelFormField(org.apache.ofbiz.widget.model.ModelFormField)

Aggregations

ModelFormField (org.apache.ofbiz.widget.model.ModelFormField)40 StringWriter (java.io.StringWriter)19 FieldInfo (org.apache.ofbiz.widget.model.FieldInfo)6 LinkedList (java.util.LinkedList)5 ModelForm (org.apache.ofbiz.widget.model.ModelForm)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Locale (java.util.Locale)3 ModelSingleForm (org.apache.ofbiz.widget.model.ModelSingleForm)3 TreeMap (java.util.TreeMap)2 HttpSession (javax.servlet.http.HttpSession)2 DisplayEntityField (org.apache.ofbiz.widget.model.ModelFormField.DisplayEntityField)2 Calendar (com.ibm.icu.util.Calendar)1 Timestamp (java.sql.Timestamp)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 TreeSet (java.util.TreeSet)1 GeneralException (org.apache.ofbiz.base.util.GeneralException)1