use of org.apache.ofbiz.widget.model.ModelFormField in project ofbiz-framework by apache.
the class MacroFormRenderer method renderFileField.
public void renderFileField(Appendable writer, Map<String, Object> context, FileField textField) throws IOException {
ModelFormField modelFormField = textField.getModelFormField();
String className = "";
String alert = "false";
String name = modelFormField.getParameterName(context);
String value = modelFormField.getEntry(context, textField.getDefaultValue(context));
String size = Integer.toString(textField.getSize());
String maxlength = "";
String autocomplete = "";
if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
className = modelFormField.getWidgetStyle();
if (modelFormField.shouldBeRed(context)) {
alert = "true";
}
}
if (UtilValidate.isEmpty(value)) {
value = "";
}
if (textField.getMaxlength() != null) {
maxlength = textField.getMaxlength().toString();
}
if (!textField.getClientAutocompleteField()) {
autocomplete = "off";
}
String tabindex = modelFormField.getTabindex();
StringWriter sr = new StringWriter();
sr.append("<@renderFileField ");
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=\"");
sr.append(maxlength);
sr.append("\" autocomplete=\"");
sr.append(autocomplete);
sr.append("\" tabindex=\"");
sr.append(tabindex);
sr.append("\" />");
executeMacro(writer, sr.toString());
this.makeHyperlinkString(writer, textField.getSubHyperlink(), context);
this.appendTooltip(writer, context, modelFormField);
}
use of org.apache.ofbiz.widget.model.ModelFormField in project ofbiz-framework by apache.
the class MacroFormRenderer method renderTextFindField.
public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField) throws IOException {
ModelFormField modelFormField = textFindField.getModelFormField();
String defaultOption = textFindField.getDefaultOption(context);
String conditionGroup = modelFormField.getConditionGroup();
String className = "";
String alert = "false";
String opEquals = "";
String opBeginsWith = "";
String opContains = "";
String opIsEmpty = "";
String opNotEqual = "";
String name = modelFormField.getParameterName(context);
String size = Integer.toString(textFindField.getSize());
String maxlength = "";
String autocomplete = "";
if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
className = modelFormField.getWidgetStyle();
if (modelFormField.shouldBeRed(context)) {
alert = "true";
}
}
Locale locale = (Locale) context.get("locale");
if (!textFindField.getHideOptions()) {
opEquals = UtilProperties.getMessage("conditionalUiLabels", "equals", locale);
opBeginsWith = UtilProperties.getMessage("conditionalUiLabels", "begins_with", locale);
opContains = UtilProperties.getMessage("conditionalUiLabels", "contains", locale);
opIsEmpty = UtilProperties.getMessage("conditionalUiLabels", "is_empty", locale);
opNotEqual = UtilProperties.getMessage("conditionalUiLabels", "not_equal", locale);
}
String value = modelFormField.getEntry(context, textFindField.getDefaultValue(context));
if (value == null) {
value = "";
}
if (textFindField.getMaxlength() != null) {
maxlength = textFindField.getMaxlength().toString();
}
if (!textFindField.getClientAutocompleteField()) {
autocomplete = "off";
}
String titleStyle = "";
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
titleStyle = modelFormField.getTitleStyle();
}
String ignoreCase = UtilProperties.getMessage("conditionalUiLabels", "ignore_case", locale);
boolean ignCase = textFindField.getIgnoreCase(context);
boolean hideIgnoreCase = textFindField.getHideIgnoreCase();
String tabindex = modelFormField.getTabindex();
StringWriter sr = new StringWriter();
sr.append("<@renderTextFindField ");
sr.append(" name=\"");
sr.append(name);
sr.append("\" value=\"");
sr.append(value);
sr.append("\" defaultOption=\"");
sr.append(defaultOption);
sr.append("\" opEquals=\"");
sr.append(opEquals);
sr.append("\" opBeginsWith=\"");
sr.append(opBeginsWith);
sr.append("\" opContains=\"");
sr.append(opContains);
sr.append("\" opIsEmpty=\"");
sr.append(opIsEmpty);
sr.append("\" opNotEqual=\"");
sr.append(opNotEqual);
sr.append("\" className=\"");
sr.append(className);
sr.append("\" alert=\"");
sr.append(alert);
sr.append("\" size=\"");
sr.append(size);
sr.append("\" maxlength=\"");
sr.append(maxlength);
sr.append("\" autocomplete=\"");
sr.append(autocomplete);
sr.append("\" titleStyle=\"");
sr.append(titleStyle);
sr.append("\" hideIgnoreCase=");
sr.append(Boolean.toString(hideIgnoreCase));
sr.append(" ignCase=");
sr.append(Boolean.toString(ignCase));
sr.append(" ignoreCase=\"");
sr.append(ignoreCase);
sr.append("\" tabindex=\"");
sr.append(tabindex);
sr.append("\" conditionGroup=\"");
sr.append(conditionGroup);
sr.append("\" />");
executeMacro(writer, sr.toString());
this.appendTooltip(writer, context, modelFormField);
}
use of org.apache.ofbiz.widget.model.ModelFormField in project ofbiz-framework by apache.
the class MacroFormRenderer method renderFormatListWrapperOpen.
public void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters"));
Map<String, Object> queryStringMap = UtilGenerics.toMap(context.get("queryStringMap"));
if (UtilValidate.isNotEmpty(queryStringMap)) {
inputFields.putAll(queryStringMap);
}
if ("multi".equals(modelForm.getType())) {
inputFields = UtilHttp.removeMultiFormParameters(inputFields);
}
String queryString = UtilHttp.urlEncodeArgs(inputFields);
context.put("_QBESTRING_", queryString);
if (modelForm instanceof ModelSingleForm) {
renderBeginningBoundaryComment(writer, "Form Widget - Form Element", modelForm);
} else {
renderBeginningBoundaryComment(writer, "Grid Widget - Grid Element", modelForm);
}
if (this.renderPagination) {
this.renderNextPrev(writer, context, modelForm);
}
List<ModelFormField> childFieldList = modelForm.getFieldList();
List<String> columnStyleList = new LinkedList<>();
List<String> fieldNameList = new LinkedList<>();
for (ModelFormField childField : childFieldList) {
int childFieldType = childField.getFieldInfo().getFieldType();
if (childFieldType == FieldInfo.HIDDEN || childFieldType == FieldInfo.IGNORED) {
continue;
}
String areaStyle = childField.getTitleAreaStyle();
if (UtilValidate.isEmpty(areaStyle)) {
areaStyle = "";
}
if (fieldNameList.contains(childField.getName())) {
if (UtilValidate.isNotEmpty(areaStyle)) {
columnStyleList.set(fieldNameList.indexOf(childField.getName()), areaStyle);
}
} else {
columnStyleList.add(areaStyle);
fieldNameList.add(childField.getName());
}
}
columnStyleList = StringUtil.quoteStrList(columnStyleList);
String columnStyleListString = StringUtil.join(columnStyleList, ", ");
StringWriter sr = new StringWriter();
sr.append("<@renderFormatListWrapperOpen ");
sr.append(" formName=\"");
sr.append(modelForm.getName());
sr.append("\" style=\"");
sr.append(FlexibleStringExpander.expandString(modelForm.getDefaultTableStyle(), context));
sr.append("\" columnStyles=[");
if (UtilValidate.isNotEmpty(columnStyleListString)) {
// this is a fix for forms with no fields
sr.append(columnStyleListString);
}
sr.append("] />");
executeMacro(writer, sr.toString());
}
use of org.apache.ofbiz.widget.model.ModelFormField in project ofbiz-framework by apache.
the class MacroFormRenderer method renderRadioField.
public void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField) throws IOException {
ModelFormField modelFormField = radioField.getModelFormField();
List<ModelFormField.OptionValue> allOptionValues = radioField.getAllOptionValues(context, WidgetWorker.getDelegator(context));
String currentValue = modelFormField.getEntry(context);
String conditionGroup = modelFormField.getConditionGroup();
String className = "";
String alert = "false";
String name = modelFormField.getParameterName(context);
String event = modelFormField.getEvent();
String action = modelFormField.getAction(context);
StringBuilder items = new StringBuilder();
if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
className = modelFormField.getWidgetStyle();
if (modelFormField.shouldBeRed(context)) {
alert = "true";
}
}
String noCurrentSelectedKey = radioField.getNoCurrentSelectedKey(context);
String tabindex = modelFormField.getTabindex();
items.append("[");
for (ModelFormField.OptionValue optionValue : allOptionValues) {
if (items.length() > 1) {
items.append(",");
}
items.append("{'key':'");
items.append(optionValue.getKey());
items.append("', 'description':'" + encode(optionValue.getDescription(), modelFormField, context));
items.append("'}");
}
items.append("]");
StringWriter sr = new StringWriter();
sr.append("<@renderRadioField ");
sr.append("items=");
sr.append(items.toString());
sr.append(" className=\"");
sr.append(className);
sr.append("\" alert=\"");
sr.append(alert);
sr.append("\" currentValue=\"");
sr.append(currentValue);
sr.append("\" noCurrentSelectedKey=\"");
sr.append(noCurrentSelectedKey);
sr.append("\" name=\"");
sr.append(name);
sr.append("\" event=\"");
if (event != null) {
sr.append(event);
}
sr.append("\" action=\"");
if (action != null) {
sr.append(action);
}
sr.append("\" conditionGroup=\"");
sr.append(conditionGroup);
sr.append("\" tabindex=\"");
sr.append(tabindex);
sr.append("\" />");
executeMacro(writer, sr.toString());
this.appendTooltip(writer, context, modelFormField);
}
use of org.apache.ofbiz.widget.model.ModelFormField in project ofbiz-framework by apache.
the class MacroFormRenderer method renderPasswordField.
public void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField) throws IOException {
ModelFormField modelFormField = passwordField.getModelFormField();
String className = "";
String alert = "false";
String name = modelFormField.getParameterName(context);
String size = Integer.toString(passwordField.getSize());
String maxlength = "";
String id = modelFormField.getCurrentContainerId(context);
String autocomplete = "";
if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
className = modelFormField.getWidgetStyle();
if (modelFormField.shouldBeRed(context)) {
alert = "true";
}
}
String value = modelFormField.getEntry(context, passwordField.getDefaultValue(context));
if (value == null) {
value = "";
}
if (passwordField.getMaxlength() != null) {
maxlength = passwordField.getMaxlength().toString();
}
if (id == null) {
id = "";
}
if (!passwordField.getClientAutocompleteField()) {
autocomplete = "off";
}
// check for required field style on single forms
if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
String requiredStyle = modelFormField.getRequiredFieldStyle();
if (UtilValidate.isEmpty(requiredStyle)) {
requiredStyle = "required";
}
if (UtilValidate.isEmpty(className)) {
className = requiredStyle;
} else {
className = requiredStyle + " " + className;
}
}
String tabindex = modelFormField.getTabindex();
StringWriter sr = new StringWriter();
sr.append("<@renderPasswordField ");
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=\"");
sr.append(maxlength);
sr.append("\" id=\"");
sr.append(id);
sr.append("\" autocomplete=\"");
sr.append(autocomplete);
sr.append("\" tabindex=\"");
sr.append(tabindex);
sr.append("\" />");
executeMacro(writer, sr.toString());
this.addAsterisks(writer, context, modelFormField);
this.makeHyperlinkString(writer, passwordField.getSubHyperlink(), context);
this.appendTooltip(writer, context, modelFormField);
}
Aggregations