You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2015/01/25 19:36:26 UTC
svn commit: r1654683 - in /ofbiz/trunk/framework:
webtools/src/org/ofbiz/webtools/artifactinfo/
widget/src/org/ofbiz/widget/artifact/ widget/src/org/ofbiz/widget/model/
Author: adrianc
Date: Sun Jan 25 18:36:26 2015
New Revision: 1654683
URL: http://svn.apache.org/r1654683
Log:
Eliminated redundant code in the new widget classes. ModelSingleForm and ModelGrid are effectively light-weight "decorators" for the ModelForm abstract class. ModelForm still retains code for all form types (single and list) - because any attempt to separate the functionality will result in an avalanche of code modifications.
Modified:
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelForm.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelGrid.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelSingleForm.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/XmlWidgetVisitor.java
Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java?rev=1654683&r1=1654682&r2=1654683&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java Sun Jan 25 18:36:26 2015
@@ -33,7 +33,9 @@ import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilURL;
import org.ofbiz.widget.artifact.ArtifactInfoContext;
import org.ofbiz.widget.artifact.ArtifactInfoGatherer;
-import org.ofbiz.widget.model.*;
+import org.ofbiz.widget.model.ModelForm;
+import org.ofbiz.widget.model.ModelGrid;
+import org.ofbiz.widget.model.ModelSingleForm;
import org.xml.sax.SAXException;
/**
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java?rev=1654683&r1=1654682&r2=1654683&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java Sun Jan 25 18:36:26 2015
@@ -33,14 +33,22 @@ import org.ofbiz.widget.model.AbstractMo
import org.ofbiz.widget.model.AbstractModelAction.Script;
import org.ofbiz.widget.model.AbstractModelAction.Service;
import org.ofbiz.widget.model.AbstractModelAction.SetField;
-import org.ofbiz.widget.model.*;
+import org.ofbiz.widget.model.FieldInfo;
+import org.ofbiz.widget.model.HtmlWidget;
import org.ofbiz.widget.model.HtmlWidget.HtmlTemplate;
import org.ofbiz.widget.model.HtmlWidget.HtmlTemplateDecorator;
import org.ofbiz.widget.model.HtmlWidget.HtmlTemplateDecoratorSection;
+import org.ofbiz.widget.model.IterateSectionWidget;
+import org.ofbiz.widget.model.ModelAction;
+import org.ofbiz.widget.model.ModelActionVisitor;
+import org.ofbiz.widget.model.ModelFieldVisitor;
+import org.ofbiz.widget.model.ModelForm;
import org.ofbiz.widget.model.ModelForm.AltTarget;
import org.ofbiz.widget.model.ModelForm.AutoFieldsEntity;
import org.ofbiz.widget.model.ModelForm.AutoFieldsService;
+import org.ofbiz.widget.model.ModelFormAction;
import org.ofbiz.widget.model.ModelFormAction.CallParentActions;
+import org.ofbiz.widget.model.ModelFormField;
import org.ofbiz.widget.model.ModelFormField.CheckField;
import org.ofbiz.widget.model.ModelFormField.ContainerField;
import org.ofbiz.widget.model.ModelFormField.DateFindField;
@@ -63,6 +71,12 @@ import org.ofbiz.widget.model.ModelFormF
import org.ofbiz.widget.model.ModelFormField.TextField;
import org.ofbiz.widget.model.ModelFormField.TextFindField;
import org.ofbiz.widget.model.ModelFormField.TextareaField;
+import org.ofbiz.widget.model.ModelGrid;
+import org.ofbiz.widget.model.ModelMenu;
+import org.ofbiz.widget.model.ModelMenuAction;
+import org.ofbiz.widget.model.ModelMenuItem;
+import org.ofbiz.widget.model.ModelScreen;
+import org.ofbiz.widget.model.ModelScreenWidget;
import org.ofbiz.widget.model.ModelScreenWidget.Column;
import org.ofbiz.widget.model.ModelScreenWidget.ColumnContainer;
import org.ofbiz.widget.model.ModelScreenWidget.Container;
@@ -83,8 +97,12 @@ import org.ofbiz.widget.model.ModelScree
import org.ofbiz.widget.model.ModelScreenWidget.Screenlet;
import org.ofbiz.widget.model.ModelScreenWidget.Section;
import org.ofbiz.widget.model.ModelScreenWidget.Tree;
+import org.ofbiz.widget.model.ModelSingleForm;
+import org.ofbiz.widget.model.ModelTree;
import org.ofbiz.widget.model.ModelTree.ModelNode;
import org.ofbiz.widget.model.ModelTree.ModelNode.ModelSubNode;
+import org.ofbiz.widget.model.ModelTreeAction;
+import org.ofbiz.widget.model.ModelWidgetVisitor;
/**
* An object that gathers artifact information from screen widgets.
@@ -225,86 +243,12 @@ public final class ArtifactInfoGatherer
@Override
public void visit(ModelSingleForm modelForm) throws Exception {
- if (modelForm.getActions() != null) {
- for (ModelAction action : modelForm.getActions()) {
- action.accept(this);
- }
- }
- if (modelForm.getRowActions() != null) {
- for (ModelAction action : modelForm.getRowActions()) {
- action.accept(this);
- }
- }
- for (AutoFieldsEntity autoFieldsEntity : modelForm.getAutoFieldsEntities()) {
- infoContext.addEntityName(autoFieldsEntity.entityName);
- }
- for (AutoFieldsService autoFieldsService : modelForm.getAutoFieldsServices()) {
- infoContext.addServiceName(autoFieldsService.serviceName);
- }
- if (modelForm.getAltTargets() != null) {
- for (AltTarget altTarget : modelForm.getAltTargets()) {
- String target = altTarget.targetExdr.getOriginal();
- String urlMode = "intra-app";
- try {
- Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target,
- urlMode);
- if (controllerLocAndRequestSet != null) {
- for (String requestLocation : controllerLocAndRequestSet) {
- infoContext.addTargetLocation(requestLocation);
- }
- }
- } catch (GeneralException e) {
- throw new RuntimeException(e);
- }
- }
- }
- if (!modelForm.getTarget().isEmpty()) {
- String target = modelForm.getTarget();
- String urlMode = UtilValidate.isNotEmpty(modelForm.getTargetType()) ? modelForm.getTargetType() : "intra-app";
- if (target.indexOf("${") < 0) {
- try {
- Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target,
- urlMode);
- if (controllerLocAndRequestSet != null) {
- for (String requestLocation : controllerLocAndRequestSet) {
- infoContext.addTargetLocation(requestLocation);
- }
- }
- } catch (GeneralException e) {
- throw new RuntimeException(e);
- }
- }
- }
- FieldInfoGatherer fieldInfoGatherer = new FieldInfoGatherer();
- for (ModelFormField modelFormField : modelForm.getFieldList()) {
- if (UtilValidate.isNotEmpty(modelFormField.getEntityName())) {
- infoContext.addEntityName(modelFormField.getEntityName());
- }
- if (modelFormField.getFieldInfo() instanceof ModelFormField.DisplayEntityField) {
- infoContext.addEntityName(((ModelFormField.DisplayEntityField) modelFormField.getFieldInfo()).getEntityName());
- }
- if (modelFormField.getFieldInfo() instanceof FieldInfoWithOptions) {
- for (ModelFormField.OptionSource optionSource : ((FieldInfoWithOptions) modelFormField
- .getFieldInfo()).getOptionSources()) {
- if (optionSource instanceof ModelFormField.EntityOptions) {
- infoContext.addEntityName(((ModelFormField.EntityOptions) optionSource).getEntityName());
- }
- }
- }
- if (UtilValidate.isNotEmpty(modelFormField.getServiceName())) {
- infoContext.addServiceName(modelFormField.getServiceName());
- }
- FieldInfo fieldInfo = modelFormField.getFieldInfo();
- if (fieldInfo != null) {
- fieldInfo.accept(fieldInfoGatherer);
- }
- }
+ visitModelForm(modelForm);
}
@Override
public void visit(ModelGrid modelGrid) throws Exception {
- // TODO: Finish implementation
-
+ visitModelForm(modelGrid);
}
@Override
@@ -557,4 +501,81 @@ public final class ArtifactInfoGatherer
public void visit(TextFindField textField) {
}
}
+
+ public void visitModelForm(ModelForm modelForm) throws Exception {
+ if (modelForm.getActions() != null) {
+ for (ModelAction action : modelForm.getActions()) {
+ action.accept(this);
+ }
+ }
+ if (modelForm.getRowActions() != null) {
+ for (ModelAction action : modelForm.getRowActions()) {
+ action.accept(this);
+ }
+ }
+ for (AutoFieldsEntity autoFieldsEntity : modelForm.getAutoFieldsEntities()) {
+ infoContext.addEntityName(autoFieldsEntity.entityName);
+ }
+ for (AutoFieldsService autoFieldsService : modelForm.getAutoFieldsServices()) {
+ infoContext.addServiceName(autoFieldsService.serviceName);
+ }
+ if (modelForm.getAltTargets() != null) {
+ for (AltTarget altTarget : modelForm.getAltTargets()) {
+ String target = altTarget.targetExdr.getOriginal();
+ String urlMode = "intra-app";
+ try {
+ Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target,
+ urlMode);
+ if (controllerLocAndRequestSet != null) {
+ for (String requestLocation : controllerLocAndRequestSet) {
+ infoContext.addTargetLocation(requestLocation);
+ }
+ }
+ } catch (GeneralException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ if (!modelForm.getTarget().isEmpty()) {
+ String target = modelForm.getTarget();
+ String urlMode = UtilValidate.isNotEmpty(modelForm.getTargetType()) ? modelForm.getTargetType() : "intra-app";
+ if (target.indexOf("${") < 0) {
+ try {
+ Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target,
+ urlMode);
+ if (controllerLocAndRequestSet != null) {
+ for (String requestLocation : controllerLocAndRequestSet) {
+ infoContext.addTargetLocation(requestLocation);
+ }
+ }
+ } catch (GeneralException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ FieldInfoGatherer fieldInfoGatherer = new FieldInfoGatherer();
+ for (ModelFormField modelFormField : modelForm.getFieldList()) {
+ if (UtilValidate.isNotEmpty(modelFormField.getEntityName())) {
+ infoContext.addEntityName(modelFormField.getEntityName());
+ }
+ if (modelFormField.getFieldInfo() instanceof ModelFormField.DisplayEntityField) {
+ infoContext.addEntityName(((ModelFormField.DisplayEntityField) modelFormField.getFieldInfo()).getEntityName());
+ }
+ if (modelFormField.getFieldInfo() instanceof FieldInfoWithOptions) {
+ for (ModelFormField.OptionSource optionSource : ((FieldInfoWithOptions) modelFormField
+ .getFieldInfo()).getOptionSources()) {
+ if (optionSource instanceof ModelFormField.EntityOptions) {
+ infoContext.addEntityName(((ModelFormField.EntityOptions) optionSource).getEntityName());
+ }
+ }
+ }
+ if (UtilValidate.isNotEmpty(modelFormField.getServiceName())) {
+ infoContext.addServiceName(modelFormField.getServiceName());
+ }
+ FieldInfo fieldInfo = modelFormField.getFieldInfo();
+ if (fieldInfo != null) {
+ fieldInfo.accept(fieldInfoGatherer);
+ }
+ }
+ }
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelForm.java?rev=1654683&r1=1654682&r2=1654683&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelForm.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelForm.java Sun Jan 25 18:36:26 2015
@@ -57,7 +57,7 @@ import bsh.EvalError;
import bsh.Interpreter;
/**
- * Models the <form> element.
+ * Abstract base class for the <form> and <grid> elements.
*
* @see <code>widget-form.xsd</code>
*/
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelGrid.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelGrid.java?rev=1654683&r1=1654682&r2=1654683&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelGrid.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelGrid.java Sun Jan 25 18:36:26 2015
@@ -19,27 +19,13 @@
package org.ofbiz.widget.model;
import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import org.ofbiz.base.util.BshUtil;
import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.StringUtil;
-import org.ofbiz.base.util.UtilCodec;
-import org.ofbiz.base.util.UtilGenerics;
-import org.ofbiz.base.util.UtilProperties;
-import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
-import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.model.ModelReader;
import org.ofbiz.service.DispatchContext;
-import org.ofbiz.widget.WidgetWorker;
import org.w3c.dom.Element;
-import bsh.EvalError;
-import bsh.Interpreter;
-
/**
* Models the <grid> element.
*
@@ -60,10 +46,6 @@ public class ModelGrid extends ModelForm
* Instances of this class will be shared by multiple threads - therefore
* it is immutable. DO NOT CHANGE THE OBJECT'S STATE AT RUN TIME!
*
- * BE VERY CAREFUL when implementing "extends" - parent form collections
- * must be added to child collections, not replace them. In other words,
- * do not assign parent collection fields to child collection fields.
- *
*/
public static final String module = ModelGrid.class.getName();
@@ -78,382 +60,6 @@ public class ModelGrid extends ModelForm
visitor.visit(this);
}
- public List<ModelAction> getActions() {
- return actions;
- }
-
- public List<AltRowStyle> getAltRowStyles() {
- return altRowStyles;
- }
-
- public List<AltTarget> getAltTargets() {
- return altTargets;
- }
-
- public List<AutoFieldsEntity> getAutoFieldsEntities() {
- return autoFieldsEntities;
- }
-
- public List<AutoFieldsService> getAutoFieldsServices() {
- return autoFieldsServices;
- }
-
- public Interpreter getBshInterpreter(Map<String, Object> context) throws EvalError {
- Interpreter bsh = (Interpreter) context.get("bshInterpreter");
- if (bsh == null) {
- bsh = BshUtil.makeInterpreter(context);
- context.put("bshInterpreter", bsh);
- }
- return bsh;
- }
-
- @Override
- public String getBoundaryCommentName() {
- return formLocation + "#" + getName();
- }
-
- public boolean getClientAutocompleteFields() {
- return this.clientAutocompleteFields;
- }
-
- public String getContainerId() {
- // use the name if there is no id
- if (UtilValidate.isNotEmpty(this.containerId)) {
- return this.containerId;
- } else {
- return this.getName();
- }
- }
-
- public String getContainerStyle() {
- return this.containerStyle;
- }
-
- public String getDefaultEntityName() {
- return this.defaultEntityName;
- }
-
- public FieldGroup getDefaultFieldGroup() {
- return defaultFieldGroup;
- }
-
- public Map<String, ? extends Object> getDefaultMap(Map<String, ? extends Object> context) {
- return this.defaultMapName.get(context);
- }
-
- public String getDefaultMapName() {
- return this.defaultMapName.getOriginalName();
- }
-
- public String getDefaultRequiredFieldStyle() {
- return this.defaultRequiredFieldStyle;
- }
-
- public String getDefaultServiceName() {
- return this.defaultServiceName;
- }
-
- public String getDefaultSortFieldAscStyle() {
- return this.defaultSortFieldAscStyle;
- }
-
- public String getDefaultSortFieldDescStyle() {
- return this.defaultSortFieldDescStyle;
- }
-
- public String getDefaultSortFieldStyle() {
- return this.defaultSortFieldStyle;
- }
-
- public String getDefaultTableStyle() {
- return this.defaultTableStyle;
- }
-
- public String getDefaultTitleAreaStyle() {
- return this.defaultTitleAreaStyle;
- }
-
- public String getDefaultTitleStyle() {
- return this.defaultTitleStyle;
- }
-
- public String getDefaultTooltipStyle() {
- return this.defaultTooltipStyle;
- }
-
- public int getDefaultViewSize() {
- return defaultViewSize;
- }
-
- public String getDefaultWidgetAreaStyle() {
- return this.defaultWidgetAreaStyle;
- }
-
- public String getDefaultWidgetStyle() {
- return this.defaultWidgetStyle;
- }
-
- public String getEvenRowStyle() {
- return this.evenRowStyle;
- }
-
- public List<FieldGroupBase> getFieldGroupList() {
- return fieldGroupList;
- }
-
- public Map<String, FieldGroupBase> getFieldGroupMap() {
- return fieldGroupMap;
- }
-
- public List<ModelFormField> getFieldList() {
- return fieldList;
- }
-
- public String getFocusFieldName() {
- return focusFieldName;
- }
-
- public String getFormLocation() {
- return this.formLocation;
- }
-
- public String getFormTitleAreaStyle() {
- return this.formTitleAreaStyle;
- }
-
- public String getFormWidgetAreaStyle() {
- return this.formWidgetAreaStyle;
- }
-
- public String getHeaderRowStyle() {
- return this.headerRowStyle;
- }
-
- public boolean getHideHeader() {
- return this.hideHeader;
- }
-
- public String getItemIndexSeparator() {
- if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) {
- return this.itemIndexSeparator;
- } else {
- return "_o_";
- }
- }
-
- public List<String> getLastOrderFields() {
- return lastOrderFields;
- }
-
- public String getListEntryName() {
- return this.listEntryName;
- }
-
- public String getListName() {
- return this.listName;
- }
-
- public String getMultiPaginateIndexField(Map<String, Object> context) {
- String field = this.paginateIndexField.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = DEFAULT_PAG_INDEX_FIELD;
- }
- // append the paginator number
- field = field + "_" + WidgetWorker.getPaginatorNumber(context);
- return field;
- }
-
- public String getMultiPaginateSizeField(Map<String, Object> context) {
- String field = this.paginateSizeField.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = DEFAULT_PAG_SIZE_FIELD;
- }
- // append the paginator number
- field = field + "_" + WidgetWorker.getPaginatorNumber(context);
- return field;
- }
-
- public List<ModelFormField> getMultiSubmitFields() {
- return this.multiSubmitFields;
- }
-
- public String getOddRowStyle() {
- return this.oddRowStyle;
- }
-
- public List<UpdateArea> getOnPaginateUpdateAreas() {
- return this.onPaginateUpdateAreas;
- }
-
- public List<UpdateArea> getOnSortColumnUpdateAreas() {
- return this.onSortColumnUpdateAreas;
- }
-
- /* Returns the list of ModelForm.UpdateArea objects.
- */
- public List<UpdateArea> getOnSubmitUpdateAreas() {
- return this.onSubmitUpdateAreas;
- }
-
- public String getOverrideListSize() {
- return overrideListSize.getOriginal();
- }
-
- public int getOverrideListSize(Map<String, Object> context) {
- int listSize = 0;
- if (!this.overrideListSize.isEmpty()) {
- String size = this.overrideListSize.expandString(context);
- try {
- size = size.replaceAll("[^0-9.]", "");
- listSize = Integer.parseInt(size);
- } catch (NumberFormatException e) {
- Debug.logError(e, "Error getting override list size from value " + size, module);
- }
- }
- return listSize;
- }
-
- public String getPaginate() {
- return paginate.getOriginal();
- }
-
- public boolean getPaginate(Map<String, Object> context) {
- String paginate = this.paginate.expandString(context);
- if (!paginate.isEmpty()) {
- return Boolean.valueOf(paginate).booleanValue();
- } else {
- return true;
- }
- }
-
- public String getPaginateFirstLabel() {
- return paginateFirstLabel.getOriginal();
- }
-
- public String getPaginateFirstLabel(Map<String, Object> context) {
- Locale locale = (Locale) context.get("locale");
- String field = this.paginateFirstLabel.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = UtilProperties.getMessage("CommonUiLabels", "CommonFirst", locale);
- }
- return field;
- }
-
- public String getPaginateFirstStyle() {
- return DEFAULT_PAG_FIRST_STYLE;
- }
-
- public String getPaginateIndexField() {
- return paginateIndexField.getOriginal();
- }
-
- public String getPaginateIndexField(Map<String, Object> context) {
- String field = this.paginateIndexField.expandString(context);
- if (field.isEmpty()) {
- return DEFAULT_PAG_INDEX_FIELD;
- }
- return field;
- }
-
- public String getPaginateLastLabel() {
- return paginateLastLabel.getOriginal();
- }
-
- public String getPaginateLastLabel(Map<String, Object> context) {
- Locale locale = (Locale) context.get("locale");
- String field = this.paginateLastLabel.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = UtilProperties.getMessage("CommonUiLabels", "CommonLast", locale);
- }
- return field;
- }
-
- public String getPaginateLastStyle() {
- return DEFAULT_PAG_LAST_STYLE;
- }
-
- public String getPaginateNextLabel() {
- return paginateNextLabel.getOriginal();
- }
-
- public String getPaginateNextLabel(Map<String, Object> context) {
- String field = this.paginateNextLabel.expandString(context);
- if (field.isEmpty()) {
- Locale locale = (Locale) context.get("locale");
- return UtilProperties.getMessage("CommonUiLabels", "CommonNext", locale);
- }
- return field;
- }
-
- public String getPaginateNextStyle() {
- return DEFAULT_PAG_NEXT_STYLE;
- }
-
- public String getPaginatePreviousLabel() {
- return paginatePreviousLabel.getOriginal();
- }
-
- public String getPaginatePreviousLabel(Map<String, Object> context) {
- String field = this.paginatePreviousLabel.expandString(context);
- if (field.isEmpty()) {
- Locale locale = (Locale) context.get("locale");
- field = UtilProperties.getMessage("CommonUiLabels", "CommonPrevious", locale);
- }
- return field;
- }
-
- public String getPaginatePreviousStyle() {
- return DEFAULT_PAG_PREV_STYLE;
- }
-
- public String getPaginateSizeField() {
- return paginateSizeField.getOriginal();
- }
-
- public String getPaginateSizeField(Map<String, Object> context) {
- String field = this.paginateSizeField.expandString(context);
- if (field.isEmpty()) {
- return DEFAULT_PAG_SIZE_FIELD;
- }
- return field;
- }
-
- public String getPaginateStyle() {
- return this.paginateStyle;
- }
-
- public String getPaginateTarget() {
- return paginateTarget.getOriginal();
- }
-
- public String getPaginateTarget(Map<String, Object> context) {
- String targ = this.paginateTarget.expandString(context);
- if (targ.isEmpty()) {
- Map<String, ?> parameters = UtilGenerics.cast(context.get("parameters"));
- if (parameters != null && parameters.containsKey("targetRequestUri")) {
- targ = (String) parameters.get("targetRequestUri");
- }
- }
- return targ;
- }
-
- public String getPaginateTargetAnchor() {
- return this.paginateTargetAnchor;
- }
-
- public String getPaginateViewSizeLabel() {
- return paginateViewSizeLabel.getOriginal();
- }
-
- public String getPaginateViewSizeLabel(Map<String, Object> context) {
- String field = this.paginateViewSizeLabel.expandString(context);
- if (field.isEmpty()) {
- Locale locale = (Locale) context.get("locale");
- return UtilProperties.getMessage("CommonUiLabels", "CommonItemsPerPage", locale);
- }
- return field;
- }
-
protected ModelForm getParentModel(Element gridElement, ModelReader entityModelReader, DispatchContext dispatchContext) {
ModelForm parentModel = null;
String parentResource = gridElement.getAttribute("extends-resource");
@@ -477,8 +83,10 @@ public class ModelGrid extends ModelForm
gridElements = UtilXml.childElementList(rootElement, "form");
}
for (Element parentElement : gridElements) {
- if (parentElement.getAttribute("name").equals(parentGrid) && gridType.equals(parentElement.getAttribute("type"))) {
- parentModel = GridFactory.createModelGrid(parentElement, entityModelReader, dispatchContext, parentResource, parentGrid);
+ if (parentElement.getAttribute("name").equals(parentGrid)
+ && gridType.equals(parentElement.getAttribute("type"))) {
+ parentModel = GridFactory.createModelGrid(parentElement, entityModelReader, dispatchContext,
+ parentResource, parentGrid);
break;
}
}
@@ -491,166 +99,4 @@ public class ModelGrid extends ModelForm
}
return parentModel;
}
-
- public String getPassedRowCount(Map<String, Object> context) {
- return rowCountExdr.expandString(context);
- }
-
- public List<ModelAction> getRowActions() {
- return rowActions;
- }
-
- public String getRowCount() {
- return rowCountExdr.getOriginal();
- }
-
- public boolean getSeparateColumns() {
- return this.separateColumns;
- }
-
- public boolean getSkipEnd() {
- return this.skipEnd;
- }
-
- public boolean getSkipStart() {
- return this.skipStart;
- }
-
- public String getSortField(Map<String, Object> context) {
- String value = null;
- try {
- value = (String) context.get(this.sortFieldParameterName);
- if (value == null) {
- Map<String, String> parameters = UtilGenerics.cast(context.get("parameters"));
- if (parameters != null) {
- value = parameters.get(this.sortFieldParameterName);
- }
- }
- } catch (Exception e) {
- Debug.logWarning(e, "Error getting sortField: " + e.toString(), module);
- }
- return value;
- }
-
- public String getSortFieldParameterName() {
- return this.sortFieldParameterName;
- }
-
- public List<SortField> getSortOrderFields() {
- return sortOrderFields;
- }
-
- /**
- * iterate through alt-row-styles list to see if should be used, then add style
- * @return The style for item row
- */
- public String getStyleAltRowStyle(Map<String, Object> context) {
- String styles = "";
- try {
- // use the same Interpreter (ie with the same context setup) for all evals
- Interpreter bsh = this.getBshInterpreter(context);
- for (AltRowStyle altRowStyle : this.altRowStyles) {
- Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(altRowStyle.useWhen));
- // retVal should be a Boolean, if not something weird is up...
- if (retVal instanceof Boolean) {
- Boolean boolVal = (Boolean) retVal;
- if (boolVal.booleanValue()) {
- styles += altRowStyle.style;
- }
- } else {
- throw new IllegalArgumentException("Return value from style condition eval was not a Boolean: "
- + retVal.getClass().getName() + " [" + retVal + "] of form " + getName());
- }
- }
- } catch (EvalError e) {
- String errmsg = "Error evaluating BeanShell style conditions on form " + getName();
- Debug.logError(e, errmsg, module);
- throw new IllegalArgumentException(errmsg);
- }
- return styles;
- }
-
- public String getTarget() {
- return target.getOriginal();
- }
-
- /** iterate through altTargets list to see if any should be used, if not return original target
- * @return The target for this Form
- */
- public String getTarget(Map<String, Object> context, String targetType) {
- Map<String, Object> expanderContext = context;
- UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
- if (simpleEncoder != null) {
- expanderContext = UtilCodec.HtmlEncodingMapWrapper.getHtmlEncodingMapWrapper(context, simpleEncoder);
- }
- try {
- // use the same Interpreter (ie with the same context setup) for all evals
- Interpreter bsh = this.getBshInterpreter(context);
- for (AltTarget altTarget : this.altTargets) {
- String useWhen = FlexibleStringExpander.expandString(altTarget.useWhen, context);
- Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(useWhen));
- boolean condTrue = false;
- // retVal should be a Boolean, if not something weird is up...
- if (retVal instanceof Boolean) {
- Boolean boolVal = (Boolean) retVal;
- condTrue = boolVal.booleanValue();
- } else {
- throw new IllegalArgumentException("Return value from target condition eval was not a Boolean: "
- + retVal.getClass().getName() + " [" + retVal + "] of form " + getName());
- }
-
- if (condTrue && !targetType.equals("inter-app")) {
- return altTarget.targetExdr.expandString(expanderContext);
- }
- }
- } catch (EvalError e) {
- String errmsg = "Error evaluating BeanShell target conditions on form " + getName();
- Debug.logError(e, errmsg, module);
- throw new IllegalArgumentException(errmsg);
- }
- return target.expandString(expanderContext);
- }
-
- public String getTargetType() {
- return this.targetType;
- }
-
- public String getTargetWindow() {
- return targetWindowExdr.getOriginal();
- }
-
- public String getTargetWindow(Map<String, Object> context) {
- return this.targetWindowExdr.expandString(context);
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public String getTooltip() {
- return this.tooltip;
- }
-
- public String getType() {
- return this.type;
- }
-
- public boolean getUseRowSubmit() {
- return this.useRowSubmit;
- }
-
- public Set<String> getUseWhenFields() {
- return useWhenFields;
- }
- public boolean getGroupColumns() {
- return groupColumns;
- }
-
- public boolean isOverridenListSize() {
- return !this.overrideListSize.isEmpty();
- }
-
- public void runFormActions(Map<String, Object> context) {
- AbstractModelAction.runSubActions(this.actions, context);
- }
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelSingleForm.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelSingleForm.java?rev=1654683&r1=1654682&r2=1654683&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelSingleForm.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelSingleForm.java Sun Jan 25 18:36:26 2015
@@ -19,27 +19,13 @@
package org.ofbiz.widget.model;
import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import org.ofbiz.base.util.BshUtil;
import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.StringUtil;
-import org.ofbiz.base.util.UtilCodec;
-import org.ofbiz.base.util.UtilGenerics;
-import org.ofbiz.base.util.UtilProperties;
-import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
-import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.model.ModelReader;
import org.ofbiz.service.DispatchContext;
-import org.ofbiz.widget.WidgetWorker;
import org.w3c.dom.Element;
-import bsh.EvalError;
-import bsh.Interpreter;
-
/**
* Models the <form> element.
*
@@ -60,16 +46,13 @@ public class ModelSingleForm extends Mod
* Instances of this class will be shared by multiple threads - therefore
* it is immutable. DO NOT CHANGE THE OBJECT'S STATE AT RUN TIME!
*
- * BE VERY CAREFUL when implementing "extends" - parent form collections
- * must be added to child collections, not replace them. In other words,
- * do not assign parent collection fields to child collection fields.
- *
*/
public static final String module = ModelSingleForm.class.getName();
/** XML Constructor */
- public ModelSingleForm(Element formElement, String formLocation, ModelReader entityModelReader, DispatchContext dispatchContext) {
+ public ModelSingleForm(Element formElement, String formLocation, ModelReader entityModelReader,
+ DispatchContext dispatchContext) {
super(formElement, formLocation, entityModelReader, dispatchContext);
}
@@ -77,381 +60,6 @@ public class ModelSingleForm extends Mod
public void accept(ModelWidgetVisitor visitor) throws Exception {
visitor.visit(this);
}
- public List<ModelAction> getActions() {
- return actions;
- }
-
- public List<AltRowStyle> getAltRowStyles() {
- return altRowStyles;
- }
-
- public List<AltTarget> getAltTargets() {
- return altTargets;
- }
-
- public List<AutoFieldsEntity> getAutoFieldsEntities() {
- return autoFieldsEntities;
- }
-
- public List<AutoFieldsService> getAutoFieldsServices() {
- return autoFieldsServices;
- }
-
- public Interpreter getBshInterpreter(Map<String, Object> context) throws EvalError {
- Interpreter bsh = (Interpreter) context.get("bshInterpreter");
- if (bsh == null) {
- bsh = BshUtil.makeInterpreter(context);
- context.put("bshInterpreter", bsh);
- }
- return bsh;
- }
-
- @Override
- public String getBoundaryCommentName() {
- return formLocation + "#" + getName();
- }
-
- public boolean getClientAutocompleteFields() {
- return this.clientAutocompleteFields;
- }
-
- public String getContainerId() {
- // use the name if there is no id
- if (UtilValidate.isNotEmpty(this.containerId)) {
- return this.containerId;
- } else {
- return this.getName();
- }
- }
-
- public String getContainerStyle() {
- return this.containerStyle;
- }
-
- public String getDefaultEntityName() {
- return this.defaultEntityName;
- }
-
- public FieldGroup getDefaultFieldGroup() {
- return defaultFieldGroup;
- }
-
- public Map<String, ? extends Object> getDefaultMap(Map<String, ? extends Object> context) {
- return this.defaultMapName.get(context);
- }
-
- public String getDefaultMapName() {
- return this.defaultMapName.getOriginalName();
- }
-
- public String getDefaultRequiredFieldStyle() {
- return this.defaultRequiredFieldStyle;
- }
-
- public String getDefaultServiceName() {
- return this.defaultServiceName;
- }
-
- public String getDefaultSortFieldAscStyle() {
- return this.defaultSortFieldAscStyle;
- }
-
- public String getDefaultSortFieldDescStyle() {
- return this.defaultSortFieldDescStyle;
- }
-
- public String getDefaultSortFieldStyle() {
- return this.defaultSortFieldStyle;
- }
-
- public String getDefaultTableStyle() {
- return this.defaultTableStyle;
- }
-
- public String getDefaultTitleAreaStyle() {
- return this.defaultTitleAreaStyle;
- }
-
- public String getDefaultTitleStyle() {
- return this.defaultTitleStyle;
- }
-
- public String getDefaultTooltipStyle() {
- return this.defaultTooltipStyle;
- }
-
- public int getDefaultViewSize() {
- return defaultViewSize;
- }
-
- public String getDefaultWidgetAreaStyle() {
- return this.defaultWidgetAreaStyle;
- }
-
- public String getDefaultWidgetStyle() {
- return this.defaultWidgetStyle;
- }
-
- public String getEvenRowStyle() {
- return this.evenRowStyle;
- }
-
- public List<FieldGroupBase> getFieldGroupList() {
- return fieldGroupList;
- }
-
- public Map<String, FieldGroupBase> getFieldGroupMap() {
- return fieldGroupMap;
- }
-
- public List<ModelFormField> getFieldList() {
- return fieldList;
- }
-
- public String getFocusFieldName() {
- return focusFieldName;
- }
-
- public String getFormLocation() {
- return this.formLocation;
- }
-
- public String getFormTitleAreaStyle() {
- return this.formTitleAreaStyle;
- }
-
- public String getFormWidgetAreaStyle() {
- return this.formWidgetAreaStyle;
- }
-
- public String getHeaderRowStyle() {
- return this.headerRowStyle;
- }
-
- public boolean getHideHeader() {
- return this.hideHeader;
- }
-
- public String getItemIndexSeparator() {
- if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) {
- return this.itemIndexSeparator;
- } else {
- return "_o_";
- }
- }
-
- public List<String> getLastOrderFields() {
- return lastOrderFields;
- }
-
- public String getListEntryName() {
- return this.listEntryName;
- }
-
- public String getListName() {
- return this.listName;
- }
-
- public String getMultiPaginateIndexField(Map<String, Object> context) {
- String field = this.paginateIndexField.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = DEFAULT_PAG_INDEX_FIELD;
- }
- // append the paginator number
- field = field + "_" + WidgetWorker.getPaginatorNumber(context);
- return field;
- }
-
- public String getMultiPaginateSizeField(Map<String, Object> context) {
- String field = this.paginateSizeField.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = DEFAULT_PAG_SIZE_FIELD;
- }
- // append the paginator number
- field = field + "_" + WidgetWorker.getPaginatorNumber(context);
- return field;
- }
-
- public List<ModelFormField> getMultiSubmitFields() {
- return this.multiSubmitFields;
- }
-
- public String getOddRowStyle() {
- return this.oddRowStyle;
- }
-
- public List<UpdateArea> getOnPaginateUpdateAreas() {
- return this.onPaginateUpdateAreas;
- }
-
- public List<UpdateArea> getOnSortColumnUpdateAreas() {
- return this.onSortColumnUpdateAreas;
- }
-
- /* Returns the list of ModelForm.UpdateArea objects.
- */
- public List<UpdateArea> getOnSubmitUpdateAreas() {
- return this.onSubmitUpdateAreas;
- }
-
- public String getOverrideListSize() {
- return overrideListSize.getOriginal();
- }
-
- public int getOverrideListSize(Map<String, Object> context) {
- int listSize = 0;
- if (!this.overrideListSize.isEmpty()) {
- String size = this.overrideListSize.expandString(context);
- try {
- size = size.replaceAll("[^0-9.]", "");
- listSize = Integer.parseInt(size);
- } catch (NumberFormatException e) {
- Debug.logError(e, "Error getting override list size from value " + size, module);
- }
- }
- return listSize;
- }
-
- public String getPaginate() {
- return paginate.getOriginal();
- }
-
- public boolean getPaginate(Map<String, Object> context) {
- String paginate = this.paginate.expandString(context);
- if (!paginate.isEmpty()) {
- return Boolean.valueOf(paginate).booleanValue();
- } else {
- return true;
- }
- }
-
- public String getPaginateFirstLabel() {
- return paginateFirstLabel.getOriginal();
- }
-
- public String getPaginateFirstLabel(Map<String, Object> context) {
- Locale locale = (Locale) context.get("locale");
- String field = this.paginateFirstLabel.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = UtilProperties.getMessage("CommonUiLabels", "CommonFirst", locale);
- }
- return field;
- }
-
- public String getPaginateFirstStyle() {
- return DEFAULT_PAG_FIRST_STYLE;
- }
-
- public String getPaginateIndexField() {
- return paginateIndexField.getOriginal();
- }
-
- public String getPaginateIndexField(Map<String, Object> context) {
- String field = this.paginateIndexField.expandString(context);
- if (field.isEmpty()) {
- return DEFAULT_PAG_INDEX_FIELD;
- }
- return field;
- }
-
- public String getPaginateLastLabel() {
- return paginateLastLabel.getOriginal();
- }
-
- public String getPaginateLastLabel(Map<String, Object> context) {
- Locale locale = (Locale) context.get("locale");
- String field = this.paginateLastLabel.expandString(context);
- if (UtilValidate.isEmpty(field)) {
- field = UtilProperties.getMessage("CommonUiLabels", "CommonLast", locale);
- }
- return field;
- }
-
- public String getPaginateLastStyle() {
- return DEFAULT_PAG_LAST_STYLE;
- }
-
- public String getPaginateNextLabel() {
- return paginateNextLabel.getOriginal();
- }
-
- public String getPaginateNextLabel(Map<String, Object> context) {
- String field = this.paginateNextLabel.expandString(context);
- if (field.isEmpty()) {
- Locale locale = (Locale) context.get("locale");
- return UtilProperties.getMessage("CommonUiLabels", "CommonNext", locale);
- }
- return field;
- }
-
- public String getPaginateNextStyle() {
- return DEFAULT_PAG_NEXT_STYLE;
- }
-
- public String getPaginatePreviousLabel() {
- return paginatePreviousLabel.getOriginal();
- }
-
- public String getPaginatePreviousLabel(Map<String, Object> context) {
- String field = this.paginatePreviousLabel.expandString(context);
- if (field.isEmpty()) {
- Locale locale = (Locale) context.get("locale");
- field = UtilProperties.getMessage("CommonUiLabels", "CommonPrevious", locale);
- }
- return field;
- }
-
- public String getPaginatePreviousStyle() {
- return DEFAULT_PAG_PREV_STYLE;
- }
-
- public String getPaginateSizeField() {
- return paginateSizeField.getOriginal();
- }
-
- public String getPaginateSizeField(Map<String, Object> context) {
- String field = this.paginateSizeField.expandString(context);
- if (field.isEmpty()) {
- return DEFAULT_PAG_SIZE_FIELD;
- }
- return field;
- }
-
- public String getPaginateStyle() {
- return this.paginateStyle;
- }
-
- public String getPaginateTarget() {
- return paginateTarget.getOriginal();
- }
-
- public String getPaginateTarget(Map<String, Object> context) {
- String targ = this.paginateTarget.expandString(context);
- if (targ.isEmpty()) {
- Map<String, ?> parameters = UtilGenerics.cast(context.get("parameters"));
- if (parameters != null && parameters.containsKey("targetRequestUri")) {
- targ = (String) parameters.get("targetRequestUri");
- }
- }
- return targ;
- }
-
- public String getPaginateTargetAnchor() {
- return this.paginateTargetAnchor;
- }
-
- public String getPaginateViewSizeLabel() {
- return paginateViewSizeLabel.getOriginal();
- }
-
- public String getPaginateViewSizeLabel(Map<String, Object> context) {
- String field = this.paginateViewSizeLabel.expandString(context);
- if (field.isEmpty()) {
- Locale locale = (Locale) context.get("locale");
- return UtilProperties.getMessage("CommonUiLabels", "CommonItemsPerPage", locale);
- }
- return field;
- }
protected ModelForm getParentModel(Element formElement, ModelReader entityModelReader, DispatchContext dispatchContext) {
ModelForm parent = null;
@@ -474,7 +82,8 @@ public class ModelSingleForm extends Mod
//Uncomment below to add support for abstract forms
//formElements.addAll(UtilXml.childElementList(rootElement, "abstract-form"));
for (Element parentElement : formElements) {
- if (parentElement.getAttribute("name").equals(parentForm) && formType.equals(parentElement.getAttribute("type"))) {
+ if (parentElement.getAttribute("name").equals(parentForm)
+ && formType.equals(parentElement.getAttribute("type"))) {
parent = FormFactory.createModelForm(parentElement, entityModelReader, dispatchContext, parentResource,
parentForm);
break;
@@ -489,166 +98,4 @@ public class ModelSingleForm extends Mod
}
return parent;
}
-
- public String getPassedRowCount(Map<String, Object> context) {
- return rowCountExdr.expandString(context);
- }
-
- public List<ModelAction> getRowActions() {
- return rowActions;
- }
-
- public String getRowCount() {
- return rowCountExdr.getOriginal();
- }
-
- public boolean getSeparateColumns() {
- return this.separateColumns;
- }
-
- public boolean getSkipEnd() {
- return this.skipEnd;
- }
-
- public boolean getSkipStart() {
- return this.skipStart;
- }
-
- public String getSortField(Map<String, Object> context) {
- String value = null;
- try {
- value = (String) context.get(this.sortFieldParameterName);
- if (value == null) {
- Map<String, String> parameters = UtilGenerics.cast(context.get("parameters"));
- if (parameters != null) {
- value = parameters.get(this.sortFieldParameterName);
- }
- }
- } catch (Exception e) {
- Debug.logWarning(e, "Error getting sortField: " + e.toString(), module);
- }
- return value;
- }
-
- public String getSortFieldParameterName() {
- return this.sortFieldParameterName;
- }
-
- public List<SortField> getSortOrderFields() {
- return sortOrderFields;
- }
-
- /**
- * iterate through alt-row-styles list to see if should be used, then add style
- * @return The style for item row
- */
- public String getStyleAltRowStyle(Map<String, Object> context) {
- String styles = "";
- try {
- // use the same Interpreter (ie with the same context setup) for all evals
- Interpreter bsh = this.getBshInterpreter(context);
- for (AltRowStyle altRowStyle : this.altRowStyles) {
- Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(altRowStyle.useWhen));
- // retVal should be a Boolean, if not something weird is up...
- if (retVal instanceof Boolean) {
- Boolean boolVal = (Boolean) retVal;
- if (boolVal.booleanValue()) {
- styles += altRowStyle.style;
- }
- } else {
- throw new IllegalArgumentException("Return value from style condition eval was not a Boolean: "
- + retVal.getClass().getName() + " [" + retVal + "] of form " + getName());
- }
- }
- } catch (EvalError e) {
- String errmsg = "Error evaluating BeanShell style conditions on form " + getName();
- Debug.logError(e, errmsg, module);
- throw new IllegalArgumentException(errmsg);
- }
- return styles;
- }
-
- public String getTarget() {
- return target.getOriginal();
- }
-
- /** iterate through altTargets list to see if any should be used, if not return original target
- * @return The target for this Form
- */
- public String getTarget(Map<String, Object> context, String targetType) {
- Map<String, Object> expanderContext = context;
- UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
- if (simpleEncoder != null) {
- expanderContext = UtilCodec.HtmlEncodingMapWrapper.getHtmlEncodingMapWrapper(context, simpleEncoder);
- }
- try {
- // use the same Interpreter (ie with the same context setup) for all evals
- Interpreter bsh = this.getBshInterpreter(context);
- for (AltTarget altTarget : this.altTargets) {
- String useWhen = FlexibleStringExpander.expandString(altTarget.useWhen, context);
- Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(useWhen));
- boolean condTrue = false;
- // retVal should be a Boolean, if not something weird is up...
- if (retVal instanceof Boolean) {
- Boolean boolVal = (Boolean) retVal;
- condTrue = boolVal.booleanValue();
- } else {
- throw new IllegalArgumentException("Return value from target condition eval was not a Boolean: "
- + retVal.getClass().getName() + " [" + retVal + "] of form " + getName());
- }
-
- if (condTrue && !targetType.equals("inter-app")) {
- return altTarget.targetExdr.expandString(expanderContext);
- }
- }
- } catch (EvalError e) {
- String errmsg = "Error evaluating BeanShell target conditions on form " + getName();
- Debug.logError(e, errmsg, module);
- throw new IllegalArgumentException(errmsg);
- }
- return target.expandString(expanderContext);
- }
-
- public String getTargetType() {
- return this.targetType;
- }
-
- public String getTargetWindow() {
- return targetWindowExdr.getOriginal();
- }
-
- public String getTargetWindow(Map<String, Object> context) {
- return this.targetWindowExdr.expandString(context);
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public String getTooltip() {
- return this.tooltip;
- }
-
- public String getType() {
- return this.type;
- }
-
- public boolean getUseRowSubmit() {
- return this.useRowSubmit;
- }
-
- public Set<String> getUseWhenFields() {
- return useWhenFields;
- }
- public boolean getGroupColumns() {
- return groupColumns;
- }
-
- public boolean isOverridenListSize() {
- return !this.overrideListSize.isEmpty();
- }
-
- public void runFormActions(Map<String, Object> context) {
- AbstractModelAction.runSubActions(this.actions, context);
- }
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/XmlWidgetVisitor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/XmlWidgetVisitor.java?rev=1654683&r1=1654682&r2=1654683&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/XmlWidgetVisitor.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/XmlWidgetVisitor.java Sun Jan 25 18:36:26 2015
@@ -239,115 +239,15 @@ public class XmlWidgetVisitor extends Xm
@Override
public void visit(ModelSingleForm modelForm) throws Exception {
writer.append("<form");
- visitModelWidget(modelForm);
- if (modelForm.getParentModelForm() != null) {
- visitAttribute("extends", modelForm.getParentModelForm().getName());
- visitAttribute("extends-resource", modelForm.getParentModelForm().getFormLocation());
- }
- visitAttribute("view-size", modelForm.getDefaultViewSize());
- visitAttribute("type", modelForm.getType());
- visitAttribute("target", modelForm.getTarget());
- visitAttribute("id", modelForm.getContainerId());
- visitAttribute("style", modelForm.getContainerStyle());
- visitAttribute("title", modelForm.getTitle());
- visitAttribute("tooltip", modelForm.getTooltip());
- visitAttribute("list-name", modelForm.getListName());
- visitAttribute("list-entry-name", modelForm.getListEntryName());
- visitAttribute("default-entity-name", modelForm.getDefaultEntityName());
- visitAttribute("default-service-name", modelForm.getDefaultServiceName());
- visitAttribute("form-title-area-style", modelForm.getFormTitleAreaStyle());
- visitAttribute("form-widget-area-style", modelForm.getFormWidgetAreaStyle());
- visitAttribute("default-title-area-style", modelForm.getDefaultTitleAreaStyle());
- visitAttribute("default-widget-area-style", modelForm.getDefaultWidgetAreaStyle());
- visitAttribute("odd-row-style", modelForm.getOddRowStyle());
- visitAttribute("even-row-style", modelForm.getEvenRowStyle());
- visitAttribute("default-table-style", modelForm.getDefaultTableStyle());
- visitAttribute("header-row-style", modelForm.getHeaderRowStyle());
- visitAttribute("default-title-style", modelForm.getDefaultTitleStyle());
- visitAttribute("default-widget-style", modelForm.getDefaultWidgetStyle());
- visitAttribute("default-tooltip-style", modelForm.getDefaultTooltipStyle());
- visitAttribute("item-index-separator", modelForm.getItemIndexSeparator());
- visitAttribute("separate-columns", modelForm.getSeparateColumns());
- visitAttribute("group-columns", modelForm.getGroupColumns());
- visitAttribute("target-type", modelForm.getTargetType());
- visitAttribute("default-map-name", modelForm.getDefaultMapName());
- visitAttribute("target-window", modelForm.getTargetWindow());
- visitAttribute("hide-header", modelForm.getHideHeader());
- visitAttribute("client-autocomplete-fields", modelForm.getClientAutocompleteFields());
- visitAttribute("paginate-target", modelForm.getPaginateTarget());
- visitAttribute("sort-field-parameter-name", modelForm.getSortFieldParameterName());
- visitAttribute("default-required-field-style", modelForm.getDefaultRequiredFieldStyle());
- visitAttribute("default-sort-field-style", modelForm.getDefaultSortFieldStyle());
- visitAttribute("default-sort-field-asc-style", modelForm.getDefaultSortFieldAscStyle());
- visitAttribute("default-sort-field-desc-style", modelForm.getDefaultSortFieldDescStyle());
- visitAttribute("paginate-target-anchor", modelForm.getPaginateTargetAnchor());
- visitAttribute("paginate-index-field", modelForm.getPaginateIndexField());
- visitAttribute("paginate-size-field", modelForm.getPaginateSizeField());
- visitAttribute("override-list-size", modelForm.getOverrideListSize());
- visitAttribute("paginate-first-label", modelForm.getPaginateFirstLabel());
- visitAttribute("paginate-previous-label", modelForm.getPaginatePreviousLabel());
- visitAttribute("paginate-next-label", modelForm.getPaginateNextLabel());
- visitAttribute("paginate-last-label", modelForm.getPaginateLastLabel());
- visitAttribute("paginate-viewsize-label", modelForm.getPaginateViewSizeLabel());
- visitAttribute("paginate-style", modelForm.getPaginateStyle());
- visitAttribute("paginate", modelForm.getPaginate());
- visitAttribute("skip-start", modelForm.getSkipStart());
- visitAttribute("skip-end", modelForm.getSkipEnd());
- visitAttribute("use-row-submit", modelForm.getUseRowSubmit());
- visitAttribute("row-count", modelForm.getRowCount());
- visitAttribute("focus-field-name", modelForm.getFocusFieldName());
- writer.append(">");
- if (!modelForm.getActions().isEmpty()) {
- writer.append("<actions>");
- visitActions(modelForm.getActions());
- writer.append("</actions>");
- }
- if (!modelForm.getRowActions().isEmpty()) {
- writer.append("<row-actions>");
- visitActions(modelForm.getRowActions());
- writer.append("</row-actions>");
- }
- for (ModelForm.AltRowStyle rowStyle : modelForm.getAltRowStyles()) {
- writer.append("<alt-row-style");
- visitAttribute("use-when", rowStyle.useWhen);
- visitAttribute("style", rowStyle.style);
- writer.append("/>");
- }
- for (ModelForm.AltTarget target : modelForm.getAltTargets()) {
- writer.append("<alt-target");
- visitAttribute("use-when", target.useWhen);
- visitAttribute("target", target.targetExdr);
- writer.append("/>");
- }
- for (ModelForm.AutoFieldsService service : modelForm.getAutoFieldsServices()) {
- writer.append("<auto-fields-service");
- visitAttribute("service-name", service.serviceName);
- visitAttribute("map-name", service.mapName);
- visitAttribute("default-field-type", service.defaultFieldType);
- visitAttribute("default-position", service.defaultPosition);
- writer.append("/>");
- }
- for (ModelForm.AutoFieldsEntity entity : modelForm.getAutoFieldsEntities()) {
- writer.append("<auto-fields-entity");
- visitAttribute("entity-name", entity.entityName);
- visitAttribute("map-name", entity.mapName);
- visitAttribute("default-field-type", entity.defaultFieldType);
- visitAttribute("default-position", entity.defaultPosition);
- writer.append("/>");
- }
- for (ModelFormField field : modelForm.getFieldList()) {
- field.getFieldInfo().accept(fieldVisitor);
- }
- visitUpdateAreas(modelForm.getOnPaginateUpdateAreas());
- visitUpdateAreas(modelForm.getOnSortColumnUpdateAreas());
- visitUpdateAreas(modelForm.getOnSubmitUpdateAreas());
+ visitModelForm(modelForm);
writer.append("</form>");
}
@Override
public void visit(ModelGrid modelGrid) throws Exception {
- // TODO: Finish implementation
-
+ writer.append("<grid");
+ visitModelForm(modelGrid);
+ writer.append("</grid>");
}
@Override
@@ -639,6 +539,111 @@ public class XmlWidgetVisitor extends Xm
}
}
+ public void visitModelForm(ModelForm modelForm) throws Exception {
+ visitModelWidget(modelForm);
+ if (modelForm.getParentModelForm() != null) {
+ visitAttribute("extends", modelForm.getParentModelForm().getName());
+ visitAttribute("extends-resource", modelForm.getParentModelForm().getFormLocation());
+ }
+ visitAttribute("view-size", modelForm.getDefaultViewSize());
+ visitAttribute("type", modelForm.getType());
+ visitAttribute("target", modelForm.getTarget());
+ visitAttribute("id", modelForm.getContainerId());
+ visitAttribute("style", modelForm.getContainerStyle());
+ visitAttribute("title", modelForm.getTitle());
+ visitAttribute("tooltip", modelForm.getTooltip());
+ visitAttribute("list-name", modelForm.getListName());
+ visitAttribute("list-entry-name", modelForm.getListEntryName());
+ visitAttribute("default-entity-name", modelForm.getDefaultEntityName());
+ visitAttribute("default-service-name", modelForm.getDefaultServiceName());
+ visitAttribute("form-title-area-style", modelForm.getFormTitleAreaStyle());
+ visitAttribute("form-widget-area-style", modelForm.getFormWidgetAreaStyle());
+ visitAttribute("default-title-area-style", modelForm.getDefaultTitleAreaStyle());
+ visitAttribute("default-widget-area-style", modelForm.getDefaultWidgetAreaStyle());
+ visitAttribute("odd-row-style", modelForm.getOddRowStyle());
+ visitAttribute("even-row-style", modelForm.getEvenRowStyle());
+ visitAttribute("default-table-style", modelForm.getDefaultTableStyle());
+ visitAttribute("header-row-style", modelForm.getHeaderRowStyle());
+ visitAttribute("default-title-style", modelForm.getDefaultTitleStyle());
+ visitAttribute("default-widget-style", modelForm.getDefaultWidgetStyle());
+ visitAttribute("default-tooltip-style", modelForm.getDefaultTooltipStyle());
+ visitAttribute("item-index-separator", modelForm.getItemIndexSeparator());
+ visitAttribute("separate-columns", modelForm.getSeparateColumns());
+ visitAttribute("group-columns", modelForm.getGroupColumns());
+ visitAttribute("target-type", modelForm.getTargetType());
+ visitAttribute("default-map-name", modelForm.getDefaultMapName());
+ visitAttribute("target-window", modelForm.getTargetWindow());
+ visitAttribute("hide-header", modelForm.getHideHeader());
+ visitAttribute("client-autocomplete-fields", modelForm.getClientAutocompleteFields());
+ visitAttribute("paginate-target", modelForm.getPaginateTarget());
+ visitAttribute("sort-field-parameter-name", modelForm.getSortFieldParameterName());
+ visitAttribute("default-required-field-style", modelForm.getDefaultRequiredFieldStyle());
+ visitAttribute("default-sort-field-style", modelForm.getDefaultSortFieldStyle());
+ visitAttribute("default-sort-field-asc-style", modelForm.getDefaultSortFieldAscStyle());
+ visitAttribute("default-sort-field-desc-style", modelForm.getDefaultSortFieldDescStyle());
+ visitAttribute("paginate-target-anchor", modelForm.getPaginateTargetAnchor());
+ visitAttribute("paginate-index-field", modelForm.getPaginateIndexField());
+ visitAttribute("paginate-size-field", modelForm.getPaginateSizeField());
+ visitAttribute("override-list-size", modelForm.getOverrideListSize());
+ visitAttribute("paginate-first-label", modelForm.getPaginateFirstLabel());
+ visitAttribute("paginate-previous-label", modelForm.getPaginatePreviousLabel());
+ visitAttribute("paginate-next-label", modelForm.getPaginateNextLabel());
+ visitAttribute("paginate-last-label", modelForm.getPaginateLastLabel());
+ visitAttribute("paginate-viewsize-label", modelForm.getPaginateViewSizeLabel());
+ visitAttribute("paginate-style", modelForm.getPaginateStyle());
+ visitAttribute("paginate", modelForm.getPaginate());
+ visitAttribute("skip-start", modelForm.getSkipStart());
+ visitAttribute("skip-end", modelForm.getSkipEnd());
+ visitAttribute("use-row-submit", modelForm.getUseRowSubmit());
+ visitAttribute("row-count", modelForm.getRowCount());
+ visitAttribute("focus-field-name", modelForm.getFocusFieldName());
+ writer.append(">");
+ if (!modelForm.getActions().isEmpty()) {
+ writer.append("<actions>");
+ visitActions(modelForm.getActions());
+ writer.append("</actions>");
+ }
+ if (!modelForm.getRowActions().isEmpty()) {
+ writer.append("<row-actions>");
+ visitActions(modelForm.getRowActions());
+ writer.append("</row-actions>");
+ }
+ for (ModelForm.AltRowStyle rowStyle : modelForm.getAltRowStyles()) {
+ writer.append("<alt-row-style");
+ visitAttribute("use-when", rowStyle.useWhen);
+ visitAttribute("style", rowStyle.style);
+ writer.append("/>");
+ }
+ for (ModelForm.AltTarget target : modelForm.getAltTargets()) {
+ writer.append("<alt-target");
+ visitAttribute("use-when", target.useWhen);
+ visitAttribute("target", target.targetExdr);
+ writer.append("/>");
+ }
+ for (ModelForm.AutoFieldsService service : modelForm.getAutoFieldsServices()) {
+ writer.append("<auto-fields-service");
+ visitAttribute("service-name", service.serviceName);
+ visitAttribute("map-name", service.mapName);
+ visitAttribute("default-field-type", service.defaultFieldType);
+ visitAttribute("default-position", service.defaultPosition);
+ writer.append("/>");
+ }
+ for (ModelForm.AutoFieldsEntity entity : modelForm.getAutoFieldsEntities()) {
+ writer.append("<auto-fields-entity");
+ visitAttribute("entity-name", entity.entityName);
+ visitAttribute("map-name", entity.mapName);
+ visitAttribute("default-field-type", entity.defaultFieldType);
+ visitAttribute("default-position", entity.defaultPosition);
+ writer.append("/>");
+ }
+ for (ModelFormField field : modelForm.getFieldList()) {
+ field.getFieldInfo().accept(fieldVisitor);
+ }
+ visitUpdateAreas(modelForm.getOnPaginateUpdateAreas());
+ visitUpdateAreas(modelForm.getOnSortColumnUpdateAreas());
+ visitUpdateAreas(modelForm.getOnSubmitUpdateAreas());
+ }
+
private void visitSubWidgets(Collection<? extends ModelWidget> subWidgets) throws Exception {
for (ModelWidget subWidget : subWidgets) {
subWidget.accept(this);