use of org.apache.ofbiz.widget.model.ModelSingleForm 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.ModelSingleForm in project ofbiz-framework by apache.
the class MacroFormRenderer method renderFormClose.
public void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
String focusFieldName = modelForm.getFocusFieldName();
String formName = FormRenderer.getCurrentFormName(modelForm, context);
String containerId = FormRenderer.getCurrentContainerId(modelForm, context);
String hasRequiredField = "";
for (ModelFormField formField : modelForm.getFieldList()) {
if (formField.getRequiredField()) {
hasRequiredField = "Y";
break;
}
}
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());
if (modelForm instanceof ModelSingleForm) {
renderEndingBoundaryComment(writer, "Form Widget - Form Element", modelForm);
} else {
renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm);
}
}
use of org.apache.ofbiz.widget.model.ModelSingleForm in project ofbiz-framework by apache.
the class MacroFormRenderer method renderFormatListWrapperClose.
public void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
StringWriter sr = new StringWriter();
sr.append("<@renderFormatListWrapperClose");
sr.append(" formName=\"");
sr.append(modelForm.getName());
sr.append("\" />");
executeMacro(writer, sr.toString());
if (this.renderPagination) {
this.renderNextPrev(writer, context, modelForm);
}
if (modelForm instanceof ModelSingleForm) {
renderEndingBoundaryComment(writer, "Form Widget - Form Element", modelForm);
} else {
renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm);
}
}
use of org.apache.ofbiz.widget.model.ModelSingleForm in project ofbiz-framework by apache.
the class FormWidgetArtifactInfo method populateAll.
/**
* note this is mean to be called after the object is created and added to the ArtifactInfoFactory.allFormInfos in ArtifactInfoFactory.getFormWidgetArtifactInfo
*/
public void populateAll() throws GeneralException {
ArtifactInfoContext infoContext = new ArtifactInfoContext();
ArtifactInfoGatherer infoGatherer = new ArtifactInfoGatherer(infoContext);
try {
if (this.modelForm instanceof ModelSingleForm) {
infoGatherer.visit((ModelSingleForm) this.modelForm);
} else {
infoGatherer.visit((ModelGrid) this.modelForm);
}
} catch (Exception e) {
throw new GeneralException(e);
}
populateEntitiesFromNameSet(infoContext.getEntityNames());
populateServicesFromNameSet(infoContext.getServiceNames());
this.populateFormExtended();
this.populateLinkedRequests(infoContext.getRequestLocations());
this.populateTargetedRequests(infoContext.getTargetLocations());
}
use of org.apache.ofbiz.widget.model.ModelSingleForm in project ofbiz-framework by apache.
the class MacroFormRenderer method renderFormOpen.
public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context);
if (modelForm instanceof ModelSingleForm) {
renderBeginningBoundaryComment(writer, "Form Widget - Form Element", modelForm);
} else {
renderBeginningBoundaryComment(writer, "Grid Widget - Grid Element", modelForm);
}
String targetType = modelForm.getTargetType();
String targ = modelForm.getTarget(context, targetType);
StringBuilder linkUrl = new StringBuilder();
if (UtilValidate.isNotEmpty(targ)) {
WidgetWorker.buildHyperlinkUrl(linkUrl, targ, targetType, null, null, false, false, true, request, response, context);
}
String formType = modelForm.getType();
String targetWindow = modelForm.getTargetWindow(context);
String containerId = FormRenderer.getCurrentContainerId(modelForm, context);
String containerStyle = modelForm.getContainerStyle();
String autocomplete = "";
String name = FormRenderer.getCurrentFormName(modelForm, context);
String viewIndexField = modelForm.getMultiPaginateIndexField(context);
String viewSizeField = modelForm.getMultiPaginateSizeField(context);
int viewIndex = Paginator.getViewIndex(modelForm, context);
int viewSize = Paginator.getViewSize(modelForm, context);
boolean useRowSubmit = modelForm.getUseRowSubmit();
if (!modelForm.getClientAutocompleteFields()) {
autocomplete = "off";
}
StringWriter sr = new StringWriter();
sr.append("<@renderFormOpen ");
sr.append(" linkUrl=\"");
sr.append(linkUrl);
sr.append("\" formType=\"");
sr.append(formType);
sr.append("\" targetWindow=\"");
sr.append(targetWindow);
sr.append("\" containerId=\"");
sr.append(containerId);
sr.append("\" containerStyle=\"");
sr.append(containerStyle);
sr.append("\" autocomplete=\"");
sr.append(autocomplete);
sr.append("\" name=\"");
sr.append(name);
sr.append("\" viewIndexField=\"");
sr.append(viewIndexField);
sr.append("\" viewSizeField=\"");
sr.append(viewSizeField);
sr.append("\" viewIndex=\"");
sr.append(Integer.toString(viewIndex));
sr.append("\" viewSize=\"");
sr.append(Integer.toString(viewSize));
sr.append("\" useRowSubmit=");
sr.append(Boolean.toString(useRowSubmit));
sr.append(" />");
executeMacro(writer, sr.toString());
}
Aggregations