/* (non-Javadoc)
* @see org.ofbiz.widget.form.FormStringRenderer#renderDateFindField(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DateFindField)
*/
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("conditional", "equals", locale);
String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
String opSameDay = UtilProperties.getMessage("conditional", "same_day", locale);
String opGreaterThanFromDayStart = UtilProperties.getMessage("conditional",
"greater_than_from_day_start", locale);
String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale);
String opUpToDay = UtilProperties.getMessage("conditional", "up_to_day", locale);
String opUpThruDay = UtilProperties.getMessage("conditional", "up_thru_day", locale);
String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
if (uiLabelMap == null) {
Debug.logWarning("Could not find uiLabelMap in context", module);
}
String localizedInputTitle = "", localizedIconTitle = "";
writer.append("<input type=\"text\"");
appendClassNames(writer, context, modelFormField);
writer.append(" name=\"");
writer.append(modelFormField.getParameterName(context));
writer.append("_fld0_value\"");
// the default values for a timestamp
int size = 25;
int maxlength = 30;
if ("date".equals(dateFindField.getType())) {
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");
}
}
writer.append(" title=\"");
writer.append(localizedInputTitle);
writer.append('"');
String value = modelFormField.getEntry(context, dateFindField.getDefaultValue(context));
if (UtilValidate.isNotEmpty(value)) {
if (value.length() > maxlength) {
value = value.substring(0, maxlength);
}
writer.append(" value=\"");
writer.append(value);
writer.append('"');
}
writer.append(" size=\"");
writer.append(Integer.toString(size));
writer.append('"');
writer.append(" maxlength=\"");
writer.append(Integer.toString(maxlength));
writer.append('"');
writer.append("/>");
// search for a localized label for the icon
if (uiLabelMap != null) {
localizedIconTitle = uiLabelMap.get("CommonViewCalendar");
}
// add calendar pop-up button and seed data IF this is not a "time" type date-find
if (!"time".equals(dateFindField.getType())) {
if ("date".equals(dateFindField.getType())) {
writer.append("<a href=\"javascript:call_cal_notime(document.");
} else {
writer.append("<a href=\"javascript:call_cal(document.");
}
writer.append(modelFormField.getModelForm().getCurrentFormName(context));
writer.append('.');
writer.append(modelFormField.getParameterName(context));
writer.append("_fld0_value,'");
writer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
writer.append("');\">");
writer.append("<img src=\"");
this.appendContentUrl(writer, "/images/cal.gif");
writer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"");
writer.append(localizedIconTitle);
writer.append("\" title=\"");
writer.append(localizedIconTitle);
writer.append("\"/></a>");
}
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
writer.append(" <span class=\"");
writer.append(modelFormField.getTitleStyle());
writer.append("\">");
}
String defaultOptionFrom = dateFindField.getDefaultOptionFrom();
writer.append(" <select name=\"");
writer.append(modelFormField.getParameterName(context));
writer.append("_fld0_op\" class=\"selectBox\">");
writer.append("<option value=\"equals\"").append(("equals".equals(defaultOptionFrom)? " selected": "")).append(">").append(opEquals).append("</option>");
writer.append("<option value=\"sameDay\"").append(("sameDay".equals(defaultOptionFrom)? " selected": "")).append(">").append(opSameDay).append("</option>");
writer.append("<option value=\"greaterThanFromDayStart\"").append(("greaterThanFromDayStart".equals(defaultOptionFrom)? " selected": "")).append(">").append(opGreaterThanFromDayStart).append("</option>");
writer.append("<option value=\"greaterThan\"").append(("greaterThan".equals(defaultOptionFrom)? " selected": "")).append(">").append(opGreaterThan).append("</option>");
writer.append("</select>");
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
writer.append(" </span>");
}
writer.append(" <br/> ");
writer.append("<input type=\"text\"");
appendClassNames(writer, context, modelFormField);
writer.append(" name=\"");
writer.append(modelFormField.getParameterName(context));
writer.append("_fld1_value\"");
writer.append(" title=\"");
writer.append(localizedInputTitle);
writer.append('"');
value = modelFormField.getEntry(context);
if (UtilValidate.isNotEmpty(value)) {
if (value.length() > maxlength) {
value = value.substring(0, maxlength);
}
writer.append(" value=\"");
writer.append(value);
writer.append('"');
}
writer.append(" size=\"");
writer.append(Integer.toString(size));
writer.append('"');
writer.append(" maxlength=\"");
writer.append(Integer.toString(maxlength));
writer.append('"');
writer.append("/>");
// add calendar pop-up button and seed data IF this is not a "time" type date-find
if (!"time".equals(dateFindField.getType())) {
if ("date".equals(dateFindField.getType())) {
writer.append("<a href=\"javascript:call_cal_notime(document.");
} else {
writer.append("<a href=\"javascript:call_cal(document.");
}
writer.append(modelFormField.getModelForm().getCurrentFormName(context));
writer.append('.');
writer.append(modelFormField.getParameterName(context));
writer.append("_fld1_value,'");
writer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
writer.append("');\">");
writer.append("<img src=\"");
this.appendContentUrl(writer, "/images/cal.gif");
writer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"");
writer.append(localizedIconTitle);
writer.append("\" title=\"");
writer.append(localizedIconTitle);
writer.append("\"/></a>");
}
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
writer.append(" <span class=\"");
writer.append(modelFormField.getTitleStyle());
writer.append("\">");
}
String defaultOptionThru = dateFindField.getDefaultOptionThru();
writer.append(" <select name=\"");
writer.append(modelFormField.getParameterName(context));
writer.append("_fld1_op\" class=\"selectBox\">");
writer.append("<option value=\"lessThan\"").append(("lessThan".equals(defaultOptionThru)? " selected": "")).append(">").append(opLessThan).append("</option>");
writer.append("<option value=\"upToDay\"").append(("upToDay".equals(defaultOptionThru)? " selected": "")).append(">").append(opUpToDay).append("</option>");
writer.append("<option value=\"upThruDay\"").append(("upThruDay".equals(defaultOptionThru)? " selected": "")).append(">").append(opUpThruDay).append("</option>");
writer.append("<option value=\"empty\"").append(("empty".equals(defaultOptionThru)? " selected": "")).append(">").append(opIsEmpty).append("</option>");
writer.append("</select>");
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
writer.append("</span>");
}
this.appendTooltip(writer, context, modelFormField);