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/17 17:47:24 UTC
svn commit: r1652638 [3/6] - in /ofbiz/trunk/framework/widget: dtd/
src/org/ofbiz/widget/ src/org/ofbiz/widget/artifact/
src/org/ofbiz/widget/fo/ src/org/ofbiz/widget/form/
src/org/ofbiz/widget/html/ src/org/ofbiz/widget/menu/
src/org/ofbiz/widget/scre...
Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/CommonWidgetModels.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/CommonWidgetModels.java?rev=1652638&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/CommonWidgetModels.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/CommonWidgetModels.java Sat Jan 17 16:47:23 2015
@@ -0,0 +1,629 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget;
+
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilCodec;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilXml;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
+import org.ofbiz.base.util.string.FlexibleStringExpander;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.entity.model.ModelField;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ModelParam;
+import org.ofbiz.service.ModelService;
+import org.w3c.dom.Element;
+
+/**
+ * A collection of shared/reused widget models.
+ *
+ */
+public final class CommonWidgetModels {
+
+ public static final String module = CommonWidgetModels.class.getName();
+
+ private CommonWidgetModels() {
+ }
+
+ public static class AutoEntityParameters {
+ private String entityName;
+ List<String> excludeList = new ArrayList<String>();
+ boolean includeNonPk;
+ boolean includePk;
+ private String includeType;
+ boolean sendIfEmpty;
+
+ public AutoEntityParameters(Element autoElement) {
+ entityName = UtilXml.checkEmpty(autoElement.getAttribute("entity-name"));
+ sendIfEmpty = "true".equals(autoElement.getAttribute("send-if-empty"));
+ includeType = UtilXml.checkEmpty(autoElement.getAttribute("include"));
+ includePk = "pk".equals(includeType) || "all".equals(includeType);
+ includeNonPk = "nonpk".equals(includeType) || "all".equals(includeType);
+ List<? extends Element> excludes = UtilXml.childElementList(autoElement, "exclude");
+ if (excludes != null) {
+ for (Element exclude : excludes) {
+ if (UtilValidate.isNotEmpty(exclude.getAttribute("field-name"))) {
+ excludeList.add(exclude.getAttribute("field-name"));
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<String, String> getParametersMap(Map<String, Object> context, String defaultEntityName) {
+ Map<String, String> autEntityParams = new HashMap<String, String>();
+ Delegator delegator = (Delegator) context.get("delegator");
+ if (delegator == null) {
+ Debug.logError(
+ "We can not append auto entity Parameters since we could not find delegator in the current context",
+ module);
+ return autEntityParams;
+ }
+ if (UtilValidate.isEmpty(entityName))
+ entityName = defaultEntityName;
+ FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(entityName);
+ ModelEntity entity = delegator.getModelEntity(toExpand.expandString(context));
+ if (entity == null) {
+ Debug.logError("We can not append auto entity Parameters since we could not find entity with name [" + entityName
+ + "]", module);
+ return autEntityParams;
+ }
+
+ Iterator<ModelField> fieldsIter = entity.getFieldsIterator();
+ if (fieldsIter != null) {
+ while (fieldsIter.hasNext()) {
+ ModelField field = fieldsIter.next();
+ String fieldName = field.getName();
+ FlexibleMapAccessor<Object> fma = FlexibleMapAccessor.getInstance(fieldName);
+ boolean shouldExclude = excludeList.contains(fieldName);
+ if ((!shouldExclude) && (!field.getIsAutoCreatedInternal())
+ && ((field.getIsPk() && includePk) || (!field.getIsPk() && includeNonPk))) {
+ Object flexibleValue = fma.get(context);
+ if (UtilValidate.isEmpty(flexibleValue) && context.containsKey("parameters")) {
+ flexibleValue = fma.get((Map<String, Object>) context.get("parameters"));
+ }
+ if (UtilValidate.isNotEmpty(flexibleValue) || sendIfEmpty) {
+ autEntityParams.put(fieldName, String.valueOf(flexibleValue));
+ }
+ }
+ }
+ }
+ return autEntityParams;
+ }
+ }
+
+ public static class AutoServiceParameters {
+ List<String> excludeList = new ArrayList<String>();
+ boolean includeNonPk;
+ boolean includePk;
+ boolean sendIfEmpty;
+ private String serviceName;
+
+ public AutoServiceParameters(Element autoElement) {
+ serviceName = UtilXml.checkEmpty(autoElement.getAttribute("service-name"));
+ sendIfEmpty = "true".equals(autoElement.getAttribute("send-if-empty"));
+ List<? extends Element> excludes = UtilXml.childElementList(autoElement, "exclude");
+ if (excludes != null) {
+ for (Element exclude : excludes) {
+ if (UtilValidate.isNotEmpty(exclude.getAttribute("field-name"))) {
+ excludeList.add(exclude.getAttribute("field-name"));
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<String, String> getParametersMap(Map<String, Object> context, String defaultServiceName) {
+ Map<String, String> autServiceParams = new HashMap<String, String>();
+ LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher");
+ if (dispatcher == null) {
+ Debug.logError(
+ "We can not append auto service Parameters since we could not find dispatcher in the current context",
+ module);
+ return autServiceParams;
+ }
+ if (UtilValidate.isEmpty(serviceName))
+ serviceName = defaultServiceName;
+ FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(serviceName);
+ ModelService service = null;
+ try {
+ service = dispatcher.getDispatchContext().getModelService(toExpand.toString());
+ } catch (GenericServiceException e) {
+ Debug.logError("Resolve service throw an error : " + e, module);
+ }
+ if (service == null) {
+ Debug.logError("We can not append auto service Parameters since we could not find service with name ["
+ + serviceName + "]", module);
+ return autServiceParams;
+ }
+ Iterator<ModelParam> paramsIter = service.getInModelParamList().iterator();
+ if (paramsIter != null) {
+ while (paramsIter.hasNext()) {
+ ModelParam param = paramsIter.next();
+ if (param.getInternal())
+ continue;
+ String paramName = param.getName();
+ FlexibleMapAccessor<Object> fma = FlexibleMapAccessor.getInstance(paramName);
+ if (!excludeList.contains(paramName)) {
+ Object flexibleValue = fma.get(context);
+ if (UtilValidate.isEmpty(flexibleValue) && context.containsKey("parameters")) {
+ flexibleValue = fma.get((Map<String, ? extends Object>) context.get("parameters"));
+ }
+ if (UtilValidate.isNotEmpty(flexibleValue) || sendIfEmpty) {
+ autServiceParams.put(paramName, String.valueOf(flexibleValue));
+ }
+ }
+ }
+ }
+ return autServiceParams;
+ }
+ }
+
+ public static final class Image {
+ private final FlexibleStringExpander alt;
+ private final FlexibleStringExpander borderExdr;
+ private final FlexibleStringExpander heightExdr;
+ private final FlexibleStringExpander idExdr;
+ private final String name;
+ private final FlexibleStringExpander srcExdr;
+ private final FlexibleStringExpander styleExdr;
+ private final FlexibleStringExpander titleExdr;
+ private final String urlMode;
+ private final FlexibleStringExpander widthExdr;
+
+ public Image(Element imageElement) {
+ this.name = imageElement.getAttribute("name");
+ String src = imageElement.getAttribute("image-location");
+ if (src.isEmpty()) {
+ src = imageElement.getAttribute("src");
+ } else {
+ // Form field version, log warning.
+ }
+ this.srcExdr = FlexibleStringExpander.getInstance(src);
+ this.idExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("id"));
+ this.styleExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("style"));
+ this.widthExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("width"));
+ this.heightExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("height"));
+ this.borderExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("border"));
+ String alt = imageElement.getAttribute("alternate");
+ if (alt.isEmpty()) {
+ alt = imageElement.getAttribute("alt"); // Common version, no warning.
+ } else {
+ // Form field version, log warning.
+ }
+ this.alt = FlexibleStringExpander.getInstance(alt);
+ String urlMode = imageElement.getAttribute("url-mode");
+ if (urlMode.isEmpty()) {
+ urlMode = "content";
+ }
+ this.urlMode = urlMode;
+ String title = imageElement.getAttribute("image-title");
+ if (title.isEmpty()) {
+ title = imageElement.getAttribute("title");
+ } else {
+ // Form field version, log warning.
+ }
+ this.titleExdr = FlexibleStringExpander.getInstance(title);
+ }
+
+ public FlexibleStringExpander getAlt() {
+ return alt;
+ }
+
+ public String getAlt(Map<String, Object> context) {
+ String alt = this.alt.expandString(context);
+ // FIXME: Encoding should be done by the renderer, not by the model.
+ UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
+ if (simpleEncoder != null) {
+ alt = simpleEncoder.encode(alt);
+ }
+ return alt;
+ }
+
+ public String getBorder(Map<String, Object> context) {
+ return this.borderExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getBorderExdr() {
+ return borderExdr;
+ }
+
+ public String getHeight(Map<String, Object> context) {
+ return this.heightExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getHeightExdr() {
+ return heightExdr;
+ }
+
+ public String getId(Map<String, Object> context) {
+ return this.idExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getIdExdr() {
+ return idExdr;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSrc(Map<String, Object> context) {
+ return this.srcExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getSrcExdr() {
+ return srcExdr;
+ }
+
+ public String getStyle(Map<String, Object> context) {
+ return this.styleExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getStyleExdr() {
+ return styleExdr;
+ }
+
+ public FlexibleStringExpander getTitleExdr() {
+ return titleExdr;
+ }
+
+ public String getUrlMode() {
+ return this.urlMode;
+ }
+
+ public String getWidth(Map<String, Object> context) {
+ return this.widthExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getWidthExdr() {
+ return widthExdr;
+ }
+ }
+
+ public static final class Link {
+ // FIXME: This is a bad practice. Client code should not need to "know" what this value is.
+ public static final String DEFAULT_URL_MODE = "intra-app";
+ private final AutoEntityParameters autoEntityParameters;
+ private final AutoServiceParameters autoServiceParameters;
+ private final boolean encode;
+ private final boolean fullPath;
+ private final FlexibleStringExpander idExdr;
+ private final Image image;
+ private final String linkType; // anchor or hidden form
+ private final FlexibleStringExpander nameExdr;
+ private final List<Parameter> parameterList;
+ private final FlexibleStringExpander prefixExdr;
+ private final boolean secure;
+ private final Integer size;
+ private final FlexibleStringExpander styleExdr;
+ private final FlexibleStringExpander targetExdr;
+ private final FlexibleStringExpander targetWindowExdr;
+ private final FlexibleStringExpander textExdr;
+ private final String urlMode;
+ // FIXME: These don't belong in this class
+ private final String height;
+ private final String width;
+
+ public Link(Element linkElement) {
+ this.textExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("text"));
+ this.idExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("id"));
+ this.styleExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("style"));
+ this.nameExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("name"));
+ this.targetExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("target"));
+ this.targetWindowExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("target-window"));
+ this.prefixExdr = FlexibleStringExpander.getInstance(linkElement.getAttribute("prefix"));
+ this.urlMode = linkElement.getAttribute("url-mode");
+ this.fullPath = "true".equals(linkElement.getAttribute("full-path"));
+ this.secure = "true".equals(linkElement.getAttribute("secure"));
+ this.encode = "true".equals(linkElement.getAttribute("encode"));
+ Element imageElement = UtilXml.firstChildElement(linkElement, "image");
+ if (imageElement != null) {
+ this.image = new Image(imageElement);
+ } else {
+ // TODO: Look for ModelFormField attributes
+ this.image = null;
+ }
+ this.linkType = linkElement.getAttribute("link-type");
+ List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter");
+ if (parameterElementList.isEmpty()) {
+ this.parameterList = Collections.emptyList();
+ } else {
+ List<Parameter> parameterList = new ArrayList<Parameter>(
+ parameterElementList.size());
+ for (Element parameterElement : parameterElementList) {
+ parameterList.add(new Parameter(parameterElement));
+ }
+ this.parameterList = Collections.unmodifiableList(parameterList);
+ }
+ Element autoServiceParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-service");
+ if (autoServiceParamsElement != null) {
+ this.autoServiceParameters = new AutoServiceParameters(autoServiceParamsElement);
+ } else {
+ this.autoServiceParameters = null;
+ }
+ Element autoEntityParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-entity");
+ if (autoEntityParamsElement != null) {
+ this.autoEntityParameters = new AutoEntityParameters(autoEntityParamsElement);
+ } else {
+ this.autoEntityParameters = null;
+ }
+ Integer size = null;
+ String sizeAttr = linkElement.getAttribute("size");
+ if (!sizeAttr.isEmpty()) {
+ size = Integer.valueOf(sizeAttr);
+ }
+ this.size = size;
+ this.width = linkElement.getAttribute("width");
+ this.height = linkElement.getAttribute("height");
+ }
+
+ // Portal constructor
+ public Link(GenericValue portalPage, List<Parameter> parameterList, String target, Locale locale) {
+ this.autoEntityParameters = null;
+ this.autoServiceParameters = null;
+ this.encode = false;
+ this.fullPath = false;
+ this.idExdr = FlexibleStringExpander.getInstance("");
+ this.image = null;
+ this.linkType = "";
+ this.nameExdr = FlexibleStringExpander.getInstance("");
+ this.parameterList = Collections.unmodifiableList(parameterList);
+ this.prefixExdr = FlexibleStringExpander.getInstance("");
+ this.secure = false;
+ this.styleExdr = FlexibleStringExpander.getInstance("");
+ this.targetExdr = FlexibleStringExpander.getInstance(target);
+ this.targetWindowExdr = FlexibleStringExpander.getInstance("");
+ this.textExdr = FlexibleStringExpander.getInstance((String) portalPage.get("portalPageName", locale));
+ this.urlMode = "intra-app";
+ this.size = null;
+ this.width = "";
+ this.height = "";
+ }
+
+ public AutoEntityParameters getAutoEntityParameters() {
+ return autoEntityParameters;
+ }
+
+ public AutoServiceParameters getAutoServiceParameters() {
+ return autoServiceParameters;
+ }
+
+ public boolean getEncode() {
+ return this.encode;
+ }
+
+ public boolean getFullPath() {
+ return this.fullPath;
+ }
+
+ public String getHeight() {
+ return this.height;
+ }
+
+ public String getId(Map<String, Object> context) {
+ return this.idExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getIdExdr() {
+ return idExdr;
+ }
+
+ public Image getImage() {
+ return this.image;
+ }
+
+ public String getLinkType() {
+ return this.linkType;
+ }
+
+ public String getName() {
+ return nameExdr.getOriginal();
+ }
+
+ public String getName(Map<String, Object> context) {
+ return this.nameExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getNameExdr() {
+ return nameExdr;
+ }
+
+ public List<Parameter> getParameterList() {
+ return parameterList;
+ }
+
+ public Map<String, String> getParameterMap(Map<String, Object> context) {
+ Map<String, String> fullParameterMap = new HashMap<String, String>();
+ for (Parameter parameter : this.parameterList) {
+ fullParameterMap.put(parameter.getName(), parameter.getValue(context));
+ }
+ if (autoServiceParameters != null) {
+ fullParameterMap.putAll(autoServiceParameters.getParametersMap(context, null));
+ }
+ if (autoEntityParameters != null) {
+ fullParameterMap.putAll(autoEntityParameters.getParametersMap(context, null));
+ }
+ return fullParameterMap;
+ }
+
+ public String getPrefix(Map<String, Object> context) {
+ return this.prefixExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getPrefixExdr() {
+ return prefixExdr;
+ }
+
+ public boolean getSecure() {
+ return this.secure;
+ }
+
+ public Integer getSize() {
+ return size;
+ }
+
+ public String getStyle(Map<String, Object> context) {
+ return this.styleExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getStyleExdr() {
+ return styleExdr;
+ }
+
+ public String getTarget(Map<String, Object> context) {
+ Map<String, Object> expanderContext = context;
+ UtilCodec.SimpleEncoder simpleEncoder = context == null ? null : (UtilCodec.SimpleEncoder) context
+ .get("simpleEncoder");
+ if (simpleEncoder != null) {
+ expanderContext = UtilCodec.HtmlEncodingMapWrapper.getHtmlEncodingMapWrapper(context, simpleEncoder);
+ }
+ return this.targetExdr.expandString(expanderContext);
+ }
+
+ public FlexibleStringExpander getTargetExdr() {
+ return targetExdr;
+ }
+
+ public String getTargetWindow(Map<String, Object> context) {
+ return this.targetWindowExdr.expandString(context);
+ }
+
+ public FlexibleStringExpander getTargetWindowExdr() {
+ return targetWindowExdr;
+ }
+
+ public String getText(Map<String, Object> context) {
+ String text = this.textExdr.expandString(context);
+ // FIXME: Encoding should be done by the renderer, not by the model.
+ UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
+ if (simpleEncoder != null) {
+ text = simpleEncoder.encode(text);
+ }
+ return text;
+ }
+
+ public FlexibleStringExpander getTextExdr() {
+ return textExdr;
+ }
+
+ public String getUrlMode() {
+ return this.urlMode;
+ }
+
+ public String getWidth() {
+ return this.width;
+ }
+ }
+
+ /**
+ * Models the <parameter> element.
+ *
+ * @see <code>widget-form.xsd</code>
+ */
+ public static class Parameter {
+ protected FlexibleMapAccessor<Object> fromField;
+ protected String name;
+ protected FlexibleStringExpander value;
+
+ public Parameter(Element element) {
+ this.name = element.getAttribute("param-name");
+ this.value = UtilValidate.isNotEmpty(element.getAttribute("value")) ? FlexibleStringExpander.getInstance(element
+ .getAttribute("value")) : null;
+ this.fromField = UtilValidate.isNotEmpty(element.getAttribute("from-field")) ? FlexibleMapAccessor
+ .getInstance(element.getAttribute("from-field")) : null;
+ }
+
+ public Parameter(String paramName, String paramValue, boolean isField) {
+ this.name = paramName;
+ if (isField) {
+ this.fromField = FlexibleMapAccessor.getInstance(paramValue);
+ } else {
+ this.value = FlexibleStringExpander.getInstance(paramValue);
+ }
+ }
+
+ public FlexibleMapAccessor<Object> getFromField() {
+ return fromField;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public FlexibleStringExpander getValue() {
+ return value;
+ }
+
+ public String getValue(Map<String, Object> context) {
+ if (this.value != null) {
+ return this.value.expandString(context);
+ }
+ Object retVal = null;
+ if (this.fromField != null && this.fromField.get(context) != null) {
+ retVal = this.fromField.get(context);
+ } else {
+ retVal = context.get(this.name);
+ }
+ if (retVal != null) {
+ TimeZone timeZone = (TimeZone) context.get("timeZone");
+ if (timeZone == null)
+ timeZone = TimeZone.getDefault();
+ String returnValue = null;
+ // format string based on the user's time zone (not locale because these are parameters)
+ if (retVal instanceof Double || retVal instanceof Float || retVal instanceof BigDecimal) {
+ returnValue = retVal.toString();
+ } else if (retVal instanceof java.sql.Date) {
+ DateFormat df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, null);
+ returnValue = df.format((java.util.Date) retVal);
+ } else if (retVal instanceof java.sql.Time) {
+ DateFormat df = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, null);
+ returnValue = df.format((java.util.Date) retVal);
+ } else if (retVal instanceof java.sql.Timestamp) {
+ DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, null);
+ returnValue = df.format((java.util.Date) retVal);
+ } else if (retVal instanceof java.util.Date) {
+ DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM dd hh:mm:ss z yyyy", timeZone, null);
+ returnValue = df.format((java.util.Date) retVal);
+ } else {
+ returnValue = retVal.toString();
+ }
+ return returnValue;
+ } else {
+ return null;
+ }
+ }
+ }
+}
Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelAction.java?rev=1652638&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelAction.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelAction.java Sat Jan 17 16:47:23 2015
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget;
+
+import java.util.Map;
+
+import org.ofbiz.base.util.GeneralException;
+
+public interface ModelAction {
+
+ void accept(ModelActionVisitor visitor) throws Exception;
+
+ /**
+ * Executes this action.
+ *
+ * @param context
+ * @throws GeneralException
+ */
+ void runAction(Map<String, Object> context) throws GeneralException;
+}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelActionVisitor.java Sat Jan 17 16:47:23 2015
@@ -4,7 +4,7 @@
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
+ * "License") throws Exception ; you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@@ -23,41 +23,41 @@ import org.ofbiz.widget.menu.ModelMenuAc
import org.ofbiz.widget.tree.ModelTreeAction;
/**
- * A <code>ModelWidgetAction</code> visitor.
+ * A <code>ModelAction</code> visitor.
*/
public interface ModelActionVisitor {
- void visit(ModelFormAction.CallParentActions callParentActions);
+ void visit(ModelFormAction.CallParentActions callParentActions) throws Exception;
- void visit(ModelWidgetAction.EntityAnd entityAnd);
+ void visit(AbstractModelAction.EntityAnd entityAnd) throws Exception;
- void visit(ModelWidgetAction.EntityCondition entityCondition);
+ void visit(AbstractModelAction.EntityCondition entityCondition) throws Exception;
- void visit(ModelWidgetAction.EntityOne entityOne);
+ void visit(AbstractModelAction.EntityOne entityOne) throws Exception;
- void visit(ModelWidgetAction.GetRelated getRelated);
+ void visit(AbstractModelAction.GetRelated getRelated) throws Exception;
- void visit(ModelWidgetAction.GetRelatedOne getRelatedOne);
+ void visit(AbstractModelAction.GetRelatedOne getRelatedOne) throws Exception;
- void visit(ModelWidgetAction.PropertyMap propertyMap);
+ void visit(AbstractModelAction.PropertyMap propertyMap) throws Exception;
- void visit(ModelWidgetAction.PropertyToField propertyToField);
+ void visit(AbstractModelAction.PropertyToField propertyToField) throws Exception;
- void visit(ModelWidgetAction.Script script);
+ void visit(AbstractModelAction.Script script) throws Exception;
- void visit(ModelWidgetAction.Service service);
+ void visit(AbstractModelAction.Service service) throws Exception;
- void visit(ModelWidgetAction.SetField setField);
+ void visit(AbstractModelAction.SetField setField) throws Exception;
- void visit(ModelFormAction.Service service);
+ void visit(ModelFormAction.Service service) throws Exception;
- void visit(ModelMenuAction.SetField setField);
+ void visit(ModelMenuAction.SetField setField) throws Exception;
- void visit(ModelTreeAction.Script script);
+ void visit(ModelTreeAction.Script script) throws Exception;
- void visit(ModelTreeAction.Service service);
+ void visit(ModelTreeAction.Service service) throws Exception;
- void visit(ModelTreeAction.EntityAnd entityAnd);
+ void visit(ModelTreeAction.EntityAnd entityAnd) throws Exception;
- void visit(ModelTreeAction.EntityCondition entityCondition);
+ void visit(ModelTreeAction.EntityCondition entityCondition) throws Exception;
}
Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelCondition.java?rev=1652638&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelCondition.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelCondition.java Sat Jan 17 16:47:23 2015
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget;
+
+import java.util.Map;
+
+public interface ModelCondition {
+
+ void accept(ModelConditionVisitor visitor) throws Exception;
+
+ boolean eval(Map<String, Object> context);
+}
Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionFactory.java?rev=1652638&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionFactory.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionFactory.java Sat Jan 17 16:47:23 2015
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget;
+
+import org.w3c.dom.Element;
+
+/**
+ * A factory for <code>Condition</code> instances.
+ *
+ */
+public interface ModelConditionFactory {
+ /**
+ * Returns a new <code>ModelCondition</code> instance built from <code>conditionElement</code>.
+ *
+ * @param modelWidget The <code>ModelWidget</code> that contains the <code>Condition</code> instance.
+ * @param conditionElement The XML element used to build the <code>Condition</code> instance.
+ * @return A new <code>ModelCondition</code> instance built from <code>conditionElement</code>.
+ * @throws IllegalArgumentException if no model was found for the XML element
+ */
+ ModelCondition newInstance(ModelWidget modelWidget, Element conditionElement);
+}
Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionVisitor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionVisitor.java?rev=1652638&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionVisitor.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelConditionVisitor.java Sat Jan 17 16:47:23 2015
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") throws Exception ; you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget;
+
+import org.ofbiz.widget.AbstractModelCondition.And;
+import org.ofbiz.widget.AbstractModelCondition.IfCompare;
+import org.ofbiz.widget.AbstractModelCondition.IfCompareField;
+import org.ofbiz.widget.AbstractModelCondition.IfEmpty;
+import org.ofbiz.widget.AbstractModelCondition.IfEntityPermission;
+import org.ofbiz.widget.AbstractModelCondition.IfHasPermission;
+import org.ofbiz.widget.AbstractModelCondition.IfRegexp;
+import org.ofbiz.widget.AbstractModelCondition.IfServicePermission;
+import org.ofbiz.widget.AbstractModelCondition.IfValidateMethod;
+import org.ofbiz.widget.AbstractModelCondition.Not;
+import org.ofbiz.widget.AbstractModelCondition.Or;
+import org.ofbiz.widget.AbstractModelCondition.Xor;
+import org.ofbiz.widget.menu.ModelMenuCondition;
+import org.ofbiz.widget.screen.ModelScreenCondition.IfEmptySection;
+import org.ofbiz.widget.tree.ModelTreeCondition;
+
+/**
+ * A <code>ModelCondition</code> visitor.
+ */
+public interface ModelConditionVisitor {
+
+ void visit(And and) throws Exception;
+
+ void visit(IfCompare ifCompare) throws Exception;
+
+ void visit(IfCompareField ifCompareField) throws Exception;
+
+ void visit(IfEmpty ifEmpty) throws Exception;
+
+ void visit(IfEntityPermission ifEntityPermission) throws Exception;
+
+ void visit(IfHasPermission ifHasPermission) throws Exception;
+
+ void visit(IfRegexp ifRegexp) throws Exception;
+
+ void visit(IfServicePermission ifServicePermission) throws Exception;
+
+ void visit(IfValidateMethod ifValidateMethod) throws Exception;
+
+ void visit(Not not) throws Exception;
+
+ void visit(Or or) throws Exception;
+
+ void visit(Xor xor) throws Exception;
+
+ void visit(ModelMenuCondition modelMenuCondition) throws Exception;
+
+ void visit(ModelTreeCondition modelTreeCondition) throws Exception;
+
+ void visit(IfEmptySection ifEmptySection) throws Exception;
+}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelFieldVisitor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelFieldVisitor.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelFieldVisitor.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelFieldVisitor.java Sat Jan 17 16:47:23 2015
@@ -4,7 +4,7 @@
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
+ * "License") throws Exception ; you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@@ -45,45 +45,45 @@ import org.ofbiz.widget.form.ModelFormFi
*/
public interface ModelFieldVisitor {
- void visit(CheckField checkField);
+ void visit(CheckField checkField) throws Exception ;
- void visit(ContainerField containerField);
+ void visit(ContainerField containerField) throws Exception ;
- void visit(DateFindField dateTimeField);
+ void visit(DateFindField dateTimeField) throws Exception ;
- void visit(DateTimeField dateTimeField);
+ void visit(DateTimeField dateTimeField) throws Exception ;
- void visit(DisplayEntityField displayField);
+ void visit(DisplayEntityField displayField) throws Exception ;
- void visit(DisplayField displayField);
+ void visit(DisplayField displayField) throws Exception ;
- void visit(DropDownField dropDownField);
+ void visit(DropDownField dropDownField) throws Exception ;
- void visit(FileField textField);
+ void visit(FileField textField) throws Exception ;
- void visit(HiddenField hiddenField);
+ void visit(HiddenField hiddenField) throws Exception ;
- void visit(HyperlinkField hyperlinkField);
+ void visit(HyperlinkField hyperlinkField) throws Exception ;
- void visit(IgnoredField ignoredField);
+ void visit(IgnoredField ignoredField) throws Exception ;
- void visit(ImageField imageField);
+ void visit(ImageField imageField) throws Exception ;
- void visit(LookupField textField);
+ void visit(LookupField textField) throws Exception ;
- void visit(PasswordField textField);
+ void visit(PasswordField textField) throws Exception ;
- void visit(RadioField radioField);
+ void visit(RadioField radioField) throws Exception ;
- void visit(RangeFindField textField);
+ void visit(RangeFindField textField) throws Exception ;
- void visit(ResetField resetField);
+ void visit(ResetField resetField) throws Exception ;
- void visit(SubmitField submitField);
+ void visit(SubmitField submitField) throws Exception ;
- void visit(TextareaField textareaField);
+ void visit(TextareaField textareaField) throws Exception ;
- void visit(TextField textField);
+ void visit(TextField textField) throws Exception ;
- void visit(TextFindField textField);
+ void visit(TextFindField textField) throws Exception ;
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Sat Jan 17 16:47:23 2015
@@ -21,8 +21,10 @@ package org.ofbiz.widget;
import java.io.Serializable;
import java.util.Map;
+import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.widget.xml.XmlWidgetVisitor;
import org.w3c.dom.Element;
/**
@@ -32,11 +34,13 @@ import org.w3c.dom.Element;
@SuppressWarnings("serial")
public abstract class ModelWidget implements Serializable {
+ public static final String module = ModelWidget.class.getName();
/**
* The parameter name used to control widget boundary comments. Currently
* set to "widgetVerbose".
*/
public static final String enableBoundaryCommentsParam = "widgetVerbose";
+
private final String name;
private final String systemId;
private final int startColumn;
@@ -100,7 +104,14 @@ public abstract class ModelWidget implem
@Override
public String toString() {
- return getClass().getSimpleName() + "[" + getSystemId() + "#" + getName() + "@" + getStartColumn() + "," + getStartLine() + "]";
+ StringBuilder sb = new StringBuilder();
+ ModelWidgetVisitor visitor = new XmlWidgetVisitor(sb);
+ try {
+ accept(visitor);
+ } catch (Exception e) {
+ Debug.logWarning(e, "Exception thrown in XmlWidgetVisitor: ", module);
+ }
+ return sb.toString();
}
/**
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidgetVisitor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidgetVisitor.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidgetVisitor.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidgetVisitor.java Sat Jan 17 16:47:23 2015
@@ -66,13 +66,13 @@ public interface ModelWidgetVisitor {
void visit(ModelScreenWidget.HorizontalSeparator horizontalSeparator) throws Exception;
- void visit(ModelScreenWidget.Image image) throws Exception;
+ void visit(ModelScreenWidget.ScreenImage image) throws Exception;
void visit(ModelScreenWidget.IncludeScreen includeScreen) throws Exception;
void visit(ModelScreenWidget.Label label) throws Exception;
- void visit(ModelScreenWidget.Link link) throws Exception;
+ void visit(ModelScreenWidget.ScreenLink link) throws Exception;
void visit(ModelScreenWidget.Menu menu) throws Exception;
@@ -91,4 +91,6 @@ public interface ModelWidgetVisitor {
void visit(ModelTree.ModelNode modelNode) throws Exception;
void visit(ModelTree.ModelNode.ModelSubNode modelSubNode) throws Exception;
+
+ void visit(ModelScreenWidget.Column column) throws Exception;
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Sat Jan 17 16:47:23 2015
@@ -20,16 +20,9 @@ package org.ofbiz.widget;
import java.io.IOException;
import java.io.StringWriter;
-import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import java.util.TimeZone;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -37,33 +30,23 @@ import javax.servlet.http.HttpServletRes
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilCodec;
-import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.base.util.UtilXml;
-import org.ofbiz.base.util.collections.FlexibleMapAccessor;
-import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.model.ModelEntity;
-import org.ofbiz.entity.model.ModelField;
-import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.service.ModelParam;
-import org.ofbiz.service.ModelService;
import org.ofbiz.webapp.control.ConfigXMLReader;
import org.ofbiz.webapp.control.RequestHandler;
import org.ofbiz.webapp.control.WebAppConfigurationException;
import org.ofbiz.webapp.taglib.ContentUrlTag;
import org.ofbiz.widget.form.ModelForm;
import org.ofbiz.widget.form.ModelFormField;
-import org.w3c.dom.Element;
-public class WidgetWorker {
+public final class WidgetWorker {
public static final String module = WidgetWorker.class.getName();
- public WidgetWorker () {}
+ private WidgetWorker () {}
public static void buildHyperlinkUrl(Appendable externalWriter, String target, String targetType, Map<String, String> parameterMap,
String prefix, boolean fullPath, boolean secure, boolean encode, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
@@ -329,202 +312,6 @@ public class WidgetWorker {
return formName + modelForm.getItemIndexSeparator() + modelFormField.getName();
}
}
-
- /**
- * Models the <parameter> element.
- *
- * @see <code>widget-form.xsd</code>
- */
- public static class Parameter {
- protected String name;
- protected FlexibleStringExpander value;
- protected FlexibleMapAccessor<Object> fromField;
-
- public Parameter(Element element) {
- this.name = element.getAttribute("param-name");
- this.value = UtilValidate.isNotEmpty(element.getAttribute("value")) ? FlexibleStringExpander.getInstance(element.getAttribute("value")) : null;
- this.fromField = UtilValidate.isNotEmpty(element.getAttribute("from-field")) ? FlexibleMapAccessor.getInstance(element.getAttribute("from-field")) : null;
- }
-
- public Parameter(String paramName, String paramValue, boolean isField) {
- this.name = paramName;
- if (isField) {
- this.fromField = FlexibleMapAccessor.getInstance(paramValue);
- } else {
- this.value = FlexibleStringExpander.getInstance(paramValue);
- }
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue(Map<String, Object> context) {
- if (this.value != null) {
- return this.value.expandString(context);
- }
-
- Object retVal = null;
- if (this.fromField != null && this.fromField.get(context) != null) {
- retVal = this.fromField.get(context);
- } else {
- retVal = context.get(this.name);
- }
-
- if (retVal != null) {
- TimeZone timeZone = (TimeZone) context.get("timeZone");
- if (timeZone == null) timeZone = TimeZone.getDefault();
-
- String returnValue = null;
- // format string based on the user's time zone (not locale because these are parameters)
- if (retVal instanceof Double || retVal instanceof Float || retVal instanceof BigDecimal) {
- returnValue = retVal.toString();
- } else if (retVal instanceof java.sql.Date) {
- DateFormat df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, null);
- returnValue = df.format((java.util.Date) retVal);
- } else if (retVal instanceof java.sql.Time) {
- DateFormat df = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, null);
- returnValue = df.format((java.util.Date) retVal);
- } else if (retVal instanceof java.sql.Timestamp) {
- DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, null);
- returnValue = df.format((java.util.Date) retVal);
- } else if (retVal instanceof java.util.Date) {
- DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM dd hh:mm:ss z yyyy", timeZone, null);
- returnValue = df.format((java.util.Date) retVal);
- } else {
- returnValue = retVal.toString();
- }
- return returnValue;
- } else {
- return null;
- }
- }
- }
-
- public static class AutoServiceParameters {
- private String serviceName;
- List<String> excludeList = new ArrayList<String>();
- boolean includePk;
- boolean includeNonPk;
- boolean sendIfEmpty;
- public AutoServiceParameters(Element autoElement){
- serviceName = UtilXml.checkEmpty(autoElement.getAttribute("service-name"));
- sendIfEmpty = "true".equals(autoElement.getAttribute("send-if-empty"));
- List<? extends Element> excludes = UtilXml.childElementList(autoElement, "exclude");
- if (excludes != null) {
- for (Element exclude: excludes) {
- if (UtilValidate.isNotEmpty(exclude.getAttribute("field-name"))) {
- excludeList.add(exclude.getAttribute("field-name"));
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public Map<String, String> getParametersMap(Map<String, Object> context, String defaultServiceName) {
- Map<String, String> autServiceParams = new HashMap<String, String>();
- LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher");
- if (dispatcher == null) {
- Debug.logError("We can not append auto service Parameters since we could not find dispatcher in the current context", module);
- return autServiceParams;
- }
- if (UtilValidate.isEmpty(serviceName)) serviceName = defaultServiceName;
- FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(serviceName);
- ModelService service = null;
- try {
- service = dispatcher.getDispatchContext().getModelService(toExpand.toString());
- } catch (GenericServiceException e) {
- Debug.logError("Resolve service throw an error : " + e, module);
- }
- if (service == null) {
- Debug.logError("We can not append auto service Parameters since we could not find service with name [" + serviceName + "]", module);
- return autServiceParams;
- }
-
- Iterator<ModelParam> paramsIter = service.getInModelParamList().iterator();
- if (paramsIter != null) {
- while (paramsIter.hasNext()) {
- ModelParam param = paramsIter.next();
- if (param.getInternal()) continue;
- String paramName = param.getName();
- FlexibleMapAccessor<Object> fma = FlexibleMapAccessor.getInstance(paramName);
- if (!excludeList.contains(paramName)) {
- Object flexibleValue = fma.get(context);
- if (UtilValidate.isEmpty(flexibleValue) && context.containsKey("parameters")) {
- flexibleValue = fma.get((Map<String, ? extends Object>) context.get("parameters"));
- }
- if (UtilValidate.isNotEmpty(flexibleValue) || sendIfEmpty) {
- autServiceParams.put(paramName, String.valueOf(flexibleValue));
- }
- }
- }
- }
- return autServiceParams;
- }
- }
-
- public static class AutoEntityParameters {
- private String entityName;
- private String includeType;
- List<String> excludeList = new ArrayList<String>();
- boolean includePk;
- boolean includeNonPk;
- boolean sendIfEmpty;
- public AutoEntityParameters(Element autoElement){
- entityName = UtilXml.checkEmpty(autoElement.getAttribute("entity-name"));
- sendIfEmpty = "true".equals(autoElement.getAttribute("send-if-empty"));
- includeType = UtilXml.checkEmpty(autoElement.getAttribute("include"));
- includePk = "pk".equals(includeType) || "all".equals(includeType);
- includeNonPk = "nonpk".equals(includeType) || "all".equals(includeType);
- List<? extends Element> excludes = UtilXml.childElementList(autoElement, "exclude");
- if (excludes != null) {
- for (Element exclude: excludes) {
- if (UtilValidate.isNotEmpty(exclude.getAttribute("field-name"))) {
- excludeList.add(exclude.getAttribute("field-name"));
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public Map<String, String> getParametersMap(Map<String, Object> context, String defaultEntityName) {
- Map<String, String> autEntityParams = new HashMap<String, String>();
- Delegator delegator = (Delegator) context.get("delegator");
- if (delegator == null) {
- Debug.logError("We can not append auto entity Parameters since we could not find delegator in the current context", module);
- return autEntityParams;
- }
- if (UtilValidate.isEmpty(entityName)) entityName = defaultEntityName;
- FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(entityName);
- ModelEntity entity = delegator.getModelEntity(toExpand.expandString(context));
- if (entity == null) {
- Debug.logError("We can not append auto entity Parameters since we could not find entity with name [" + entityName + "]", module);
- return autEntityParams;
- }
-
- Iterator<ModelField> fieldsIter = entity.getFieldsIterator();
- if (fieldsIter != null) {
- while (fieldsIter.hasNext()) {
- ModelField field = fieldsIter.next();
- String fieldName = field.getName();
- FlexibleMapAccessor<Object> fma = FlexibleMapAccessor.getInstance(fieldName);
- boolean shouldExclude = excludeList.contains(fieldName);
- if ((!shouldExclude) && (!field.getIsAutoCreatedInternal())
- && ((field.getIsPk() && includePk) || (!field.getIsPk() && includeNonPk))) {
- Object flexibleValue = fma.get(context);
- if (UtilValidate.isEmpty(flexibleValue) && context.containsKey("parameters")) {
- flexibleValue = fma.get((Map<String, Object>) context.get("parameters"));
- }
- if (UtilValidate.isNotEmpty(flexibleValue) || sendIfEmpty) {
- autEntityParams.put(fieldName, String.valueOf(flexibleValue));
- }
- }
- }
- }
- return autEntityParams;
- }
- }
-
public static String determineAutoLinkType(String linkType, String target, String targetType, HttpServletRequest request) {
if ("auto".equals(linkType)) {
if ("intra-app".equals(targetType)) {
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=1652638&r1=1652637&r2=1652638&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 Sat Jan 17 16:47:23 2015
@@ -23,19 +23,19 @@ import java.util.Set;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.webapp.control.ConfigXMLReader;
+import org.ofbiz.widget.AbstractModelAction.EntityAnd;
+import org.ofbiz.widget.AbstractModelAction.EntityCondition;
+import org.ofbiz.widget.AbstractModelAction.EntityOne;
+import org.ofbiz.widget.AbstractModelAction.GetRelated;
+import org.ofbiz.widget.AbstractModelAction.GetRelatedOne;
+import org.ofbiz.widget.AbstractModelAction.PropertyMap;
+import org.ofbiz.widget.AbstractModelAction.PropertyToField;
+import org.ofbiz.widget.AbstractModelAction.Script;
+import org.ofbiz.widget.AbstractModelAction.Service;
+import org.ofbiz.widget.AbstractModelAction.SetField;
+import org.ofbiz.widget.ModelAction;
import org.ofbiz.widget.ModelActionVisitor;
import org.ofbiz.widget.ModelFieldVisitor;
-import org.ofbiz.widget.ModelWidgetAction;
-import org.ofbiz.widget.ModelWidgetAction.EntityAnd;
-import org.ofbiz.widget.ModelWidgetAction.EntityCondition;
-import org.ofbiz.widget.ModelWidgetAction.EntityOne;
-import org.ofbiz.widget.ModelWidgetAction.GetRelated;
-import org.ofbiz.widget.ModelWidgetAction.GetRelatedOne;
-import org.ofbiz.widget.ModelWidgetAction.PropertyMap;
-import org.ofbiz.widget.ModelWidgetAction.PropertyToField;
-import org.ofbiz.widget.ModelWidgetAction.Script;
-import org.ofbiz.widget.ModelWidgetAction.Service;
-import org.ofbiz.widget.ModelWidgetAction.SetField;
import org.ofbiz.widget.ModelWidgetVisitor;
import org.ofbiz.widget.form.FieldInfo;
import org.ofbiz.widget.form.ModelForm;
@@ -86,10 +86,10 @@ import org.ofbiz.widget.screen.ModelScre
import org.ofbiz.widget.screen.ModelScreenWidget.DecoratorSectionInclude;
import org.ofbiz.widget.screen.ModelScreenWidget.Form;
import org.ofbiz.widget.screen.ModelScreenWidget.HorizontalSeparator;
-import org.ofbiz.widget.screen.ModelScreenWidget.Image;
+import org.ofbiz.widget.screen.ModelScreenWidget.ScreenImage;
import org.ofbiz.widget.screen.ModelScreenWidget.IncludeScreen;
import org.ofbiz.widget.screen.ModelScreenWidget.Label;
-import org.ofbiz.widget.screen.ModelScreenWidget.Link;
+import org.ofbiz.widget.screen.ModelScreenWidget.ScreenLink;
import org.ofbiz.widget.screen.ModelScreenWidget.Menu;
import org.ofbiz.widget.screen.ModelScreenWidget.PlatformSpecific;
import org.ofbiz.widget.screen.ModelScreenWidget.PortalPage;
@@ -113,58 +113,88 @@ public final class ArtifactInfoGatherer
}
@Override
- public void visit(CallParentActions callParentActions) {
+ public void visit(CallParentActions callParentActions) throws Exception {
}
@Override
- public void visit(EntityAnd entityAnd) {
- infoContext.addEntityName(entityAnd.getFinder().getEntityName());
+ public void visit(Column column) throws Exception {
}
@Override
- public void visit(EntityCondition entityCondition) {
- infoContext.addEntityName(entityCondition.getFinder().getEntityName());
+ public void visit(ColumnContainer columnContainer) throws Exception {
+ for (Column column : columnContainer.getColumns()) {
+ for (ModelScreenWidget widget : column.getSubWidgets()) {
+ widget.accept(this);
+ }
+ }
}
@Override
- public void visit(EntityOne entityOne) {
- infoContext.addEntityName(entityOne.getFinder().getEntityName());
+ public void visit(Container container) throws Exception {
+ for (ModelScreenWidget widget : container.getSubWidgets()) {
+ widget.accept(this);
+ }
}
@Override
- public void visit(GetRelated getRelated) {
- infoContext.addEntityName(getRelated.getRelationName());
+ public void visit(Content content) throws Exception {
+ infoContext.addEntityName("Content");
+ if (!content.getDataResourceId().isEmpty()) {
+ infoContext.addEntityName("DataResource");
+ }
}
@Override
- public void visit(GetRelatedOne getRelatedOne) {
- infoContext.addEntityName(getRelatedOne.getRelationName());
+ public void visit(DecoratorScreen decoratorScreen) throws Exception {
+ for (ModelScreenWidget section : decoratorScreen.getSectionMap().values()) {
+ section.accept(this);
+ }
}
@Override
- public void visit(PropertyMap propertyMap) {
+ public void visit(DecoratorSection decoratorSection) throws Exception {
+ for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) {
+ widget.accept(this);
+ }
}
@Override
- public void visit(PropertyToField propertyToField) {
+ public void visit(DecoratorSectionInclude decoratorSectionInclude) throws Exception {
}
@Override
- public void visit(Script script) {
+ public void visit(EntityAnd entityAnd) throws Exception {
+ infoContext.addEntityName(entityAnd.getFinder().getEntityName());
}
@Override
- public void visit(Service service) {
- infoContext.addServiceName(service.getServiceNameExdr().getOriginal());
- // TODO: Look for entityName in performFind service call
+ public void visit(EntityCondition entityCondition) throws Exception {
+ infoContext.addEntityName(entityCondition.getFinder().getEntityName());
}
@Override
- public void visit(SetField setField) {
+ public void visit(EntityOne entityOne) throws Exception {
+ infoContext.addEntityName(entityOne.getFinder().getEntityName());
}
@Override
- public void visit(HtmlWidget htmlWidget) throws Exception {
+ public void visit(Form form) throws Exception {
+ String formLocation = form.getLocation().concat("#").concat(form.getName());
+ infoContext.addFormLocation(formLocation);
+ }
+
+ @Override
+ public void visit(GetRelated getRelated) throws Exception {
+ infoContext.addEntityName(getRelated.getRelationName());
+ }
+
+ @Override
+ public void visit(GetRelatedOne getRelatedOne) throws Exception {
+ infoContext.addEntityName(getRelatedOne.getRelationName());
+ }
+
+ @Override
+ public void visit(HorizontalSeparator horizontalSeparator) throws Exception {
}
@Override
@@ -180,6 +210,14 @@ public final class ArtifactInfoGatherer
}
@Override
+ public void visit(HtmlWidget htmlWidget) throws Exception {
+ }
+
+ @Override
+ public void visit(IncludeScreen includeScreen) throws Exception {
+ }
+
+ @Override
public void visit(IterateSectionWidget iterateSectionWidget) throws Exception {
for (Section section : iterateSectionWidget.getSectionList()) {
section.accept(this);
@@ -187,14 +225,22 @@ public final class ArtifactInfoGatherer
}
@Override
+ public void visit(Label label) throws Exception {
+ }
+
+ @Override
+ public void visit(Menu menu) throws Exception {
+ }
+
+ @Override
public void visit(ModelForm modelForm) throws Exception {
if (modelForm.getActions() != null) {
- for (ModelWidgetAction action : modelForm.getActions()) {
+ for (ModelAction action : modelForm.getActions()) {
action.accept(this);
}
}
if (modelForm.getRowActions() != null) {
- for (ModelWidgetAction action : modelForm.getRowActions()) {
+ for (ModelAction action : modelForm.getRowActions()) {
action.accept(this);
}
}
@@ -265,7 +311,7 @@ public final class ArtifactInfoGatherer
}
@Override
- public void visit(ModelFormAction.Service service) {
+ public void visit(ModelFormAction.Service service) throws Exception {
infoContext.addServiceName(service.getServiceName());
// TODO: Look for entityName in performFind service call
}
@@ -275,7 +321,7 @@ public final class ArtifactInfoGatherer
}
@Override
- public void visit(ModelMenuAction.SetField setField) {
+ public void visit(ModelMenuAction.SetField setField) throws Exception {
}
@Override
@@ -283,6 +329,10 @@ public final class ArtifactInfoGatherer
}
@Override
+ public void visit(ModelNode modelNode) throws Exception {
+ }
+
+ @Override
public void visit(ModelScreen modelScreen) throws Exception {
String screenLocation = modelScreen.getSourceLocation().concat("#").concat(modelScreen.getName());
infoContext.addScreenLocation(screenLocation);
@@ -290,71 +340,58 @@ public final class ArtifactInfoGatherer
}
@Override
- public void visit(ColumnContainer columnContainer) throws Exception {
- for (Column column : columnContainer.getColumns()) {
- for (ModelScreenWidget widget : column.getSubWidgets()) {
- widget.accept(this);
- }
- }
+ public void visit(ModelSubNode modelSubNode) throws Exception {
}
@Override
- public void visit(Container container) throws Exception {
- for (ModelScreenWidget widget : container.getSubWidgets()) {
- widget.accept(this);
- }
+ public void visit(ModelTree modelTree) throws Exception {
}
@Override
- public void visit(Content content) throws Exception {
- infoContext.addEntityName("Content");
- if (!content.getDataResourceId().isEmpty()) {
- infoContext.addEntityName("DataResource");
- }
+ public void visit(ModelTreeAction.EntityAnd entityAnd) throws Exception {
}
@Override
- public void visit(DecoratorScreen decoratorScreen) throws Exception {
- for (ModelScreenWidget section : decoratorScreen.getSectionMap().values()) {
- section.accept(this);
- }
+ public void visit(ModelTreeAction.EntityCondition entityCondition) throws Exception {
}
@Override
- public void visit(DecoratorSection decoratorSection) throws Exception {
- for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) {
- widget.accept(this);
- }
+ public void visit(ModelTreeAction.Script script) throws Exception {
}
@Override
- public void visit(DecoratorSectionInclude decoratorSectionInclude) throws Exception {
+ public void visit(ModelTreeAction.Service service) throws Exception {
}
@Override
- public void visit(Form form) throws Exception {
- String formLocation = form.getLocation().concat("#").concat(form.getName());
- infoContext.addFormLocation(formLocation);
+ public void visit(PlatformSpecific platformSpecific) throws Exception {
}
@Override
- public void visit(HorizontalSeparator horizontalSeparator) throws Exception {
+ public void visit(PortalPage portalPage) throws Exception {
}
@Override
- public void visit(Image image) throws Exception {
+ public void visit(PropertyMap propertyMap) throws Exception {
}
@Override
- public void visit(IncludeScreen includeScreen) throws Exception {
+ public void visit(PropertyToField propertyToField) throws Exception {
}
@Override
- public void visit(Label label) throws Exception {
+ public void visit(ScreenImage image) throws Exception {
}
@Override
- public void visit(Link link) throws Exception {
+ public void visit(Screenlet screenlet) throws Exception {
+ for (ModelScreenWidget widget : screenlet.getSubWidgets()) {
+ widget.accept(this);
+ }
+ }
+
+ @Override
+ public void visit(ScreenLink link) throws Exception {
String target = link.getTarget(null);
String urlMode = link.getUrlMode();
try {
@@ -370,27 +407,12 @@ public final class ArtifactInfoGatherer
}
@Override
- public void visit(Menu menu) throws Exception {
- }
-
- @Override
- public void visit(PlatformSpecific platformSpecific) throws Exception {
- }
-
- @Override
- public void visit(PortalPage portalPage) throws Exception {
- }
-
- @Override
- public void visit(Screenlet screenlet) throws Exception {
- for (ModelScreenWidget widget : screenlet.getSubWidgets()) {
- widget.accept(this);
- }
+ public void visit(Script script) throws Exception {
}
@Override
public void visit(Section section) throws Exception {
- for (ModelWidgetAction action : section.getActions()) {
+ for (ModelAction action : section.getActions()) {
action.accept(this);
}
for (ModelScreenWidget subWidget : section.getSubWidgets()) {
@@ -402,35 +424,17 @@ public final class ArtifactInfoGatherer
}
@Override
- public void visit(Tree tree) throws Exception {
- }
-
- @Override
- public void visit(ModelTree modelTree) throws Exception {
- }
-
- @Override
- public void visit(ModelNode modelNode) throws Exception {
- }
-
- @Override
- public void visit(ModelSubNode modelSubNode) throws Exception {
- }
-
- @Override
- public void visit(ModelTreeAction.EntityAnd entityAnd) {
- }
-
- @Override
- public void visit(ModelTreeAction.EntityCondition entityCondition) {
+ public void visit(Service service) throws Exception {
+ infoContext.addServiceName(service.getServiceNameExdr().getOriginal());
+ // TODO: Look for entityName in performFind service call
}
@Override
- public void visit(ModelTreeAction.Script script) {
+ public void visit(SetField setField) throws Exception {
}
@Override
- public void visit(ModelTreeAction.Service service) {
+ public void visit(Tree tree) throws Exception {
}
private class FieldInfoGatherer implements ModelFieldVisitor {
@@ -469,7 +473,7 @@ public final class ArtifactInfoGatherer
public void visit(DisplayEntityField displayField) {
if (displayField.getSubHyperlink() != null) {
String target = displayField.getSubHyperlink().getTarget(null);
- String urlMode = displayField.getSubHyperlink().getTargetType();
+ String urlMode = displayField.getSubHyperlink().getUrlMode();
addRequestLocations(target, urlMode);
}
}
@@ -482,7 +486,7 @@ public final class ArtifactInfoGatherer
public void visit(DropDownField dropDownField) {
if (dropDownField.getSubHyperlink() != null) {
String target = dropDownField.getSubHyperlink().getTarget(null);
- String urlMode = dropDownField.getSubHyperlink().getTargetType();
+ String urlMode = dropDownField.getSubHyperlink().getUrlMode();
addRequestLocations(target, urlMode);
}
}
@@ -491,7 +495,7 @@ public final class ArtifactInfoGatherer
public void visit(FileField textField) {
if (textField.getSubHyperlink() != null) {
String target = textField.getSubHyperlink().getTarget(null);
- String urlMode = textField.getSubHyperlink().getTargetType();
+ String urlMode = textField.getSubHyperlink().getUrlMode();
addRequestLocations(target, urlMode);
}
}
@@ -503,7 +507,7 @@ public final class ArtifactInfoGatherer
@Override
public void visit(HyperlinkField hyperlinkField) {
String target = hyperlinkField.getTarget(null);
- String urlMode = hyperlinkField.getTargetType();
+ String urlMode = hyperlinkField.getUrlMode();
addRequestLocations(target, urlMode);
}
@@ -515,7 +519,7 @@ public final class ArtifactInfoGatherer
public void visit(ImageField imageField) {
if (imageField.getSubHyperlink() != null) {
String target = imageField.getSubHyperlink().getTarget(null);
- String urlMode = imageField.getSubHyperlink().getTargetType();
+ String urlMode = imageField.getSubHyperlink().getUrlMode();
addRequestLocations(target, urlMode);
}
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java Sat Jan 17 16:47:23 2015
@@ -118,11 +118,11 @@ public class FoScreenRenderer extends Ht
appendWhitespace(writer);
}
- public void renderLink(Appendable writer, Map<String, Object> context, ModelScreenWidget.Link link) throws IOException {
+ public void renderLink(Appendable writer, Map<String, Object> context, ModelScreenWidget.ScreenLink link) throws IOException {
// TODO: not implemented
}
- public void renderImage(Appendable writer, Map<String, Object> context, ModelScreenWidget.Image image) throws IOException {
+ public void renderImage(Appendable writer, Map<String, Object> context, ModelScreenWidget.ScreenImage image) throws IOException {
// TODO: not implemented
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FieldInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FieldInfo.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FieldInfo.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FieldInfo.java Sat Jan 17 16:47:23 2015
@@ -23,7 +23,9 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import org.ofbiz.base.util.Debug;
import org.ofbiz.widget.ModelFieldVisitor;
+import org.ofbiz.widget.xml.XmlWidgetFieldVisitor;
import org.w3c.dom.Element;
/**
@@ -31,6 +33,8 @@ import org.w3c.dom.Element;
*/
public abstract class FieldInfo {
+ public static final String module = FieldInfo.class.getName();
+
public static final int DISPLAY = 1;
public static final int HYPERLINK = 2;
public static final int TEXT = 3;
@@ -113,7 +117,7 @@ public abstract class FieldInfo {
this.modelFormField = modelFormField;
}
- public abstract void accept(ModelFieldVisitor visitor);
+ public abstract void accept(ModelFieldVisitor visitor) throws Exception;
/**
* Returns a new instance of this object.
@@ -136,4 +140,16 @@ public abstract class FieldInfo {
public abstract void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer)
throws IOException;
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ ModelFieldVisitor visitor = new XmlWidgetFieldVisitor(sb);
+ try {
+ accept(visitor);
+ } catch (Exception e) {
+ Debug.logWarning(e, "Exception thrown in XmlWidgetFieldVisitor: ", module);
+ }
+ return sb.toString();
+ }
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormRenderer.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormRenderer.java Sat Jan 17 16:47:23 2015
@@ -41,7 +41,7 @@ import org.ofbiz.base.util.string.Flexib
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.util.EntityListIterator;
-import org.ofbiz.widget.ModelWidgetAction;
+import org.ofbiz.widget.AbstractModelAction;
import org.ofbiz.widget.WidgetWorker;
import org.ofbiz.widget.form.ModelForm.FieldGroup;
import org.ofbiz.widget.form.ModelForm.FieldGroupBase;
@@ -736,7 +736,7 @@ public class FormRenderer {
previousItem = new HashMap<String, Object>();
previousItem.putAll(itemMap);
- ModelWidgetAction.runSubActions(modelForm.getRowActions(), localContext);
+ AbstractModelAction.runSubActions(modelForm.getRowActions(), localContext);
localContext.put("itemIndex", Integer.valueOf(itemIndex - lowIndex));
if (UtilValidate.isNotEmpty(context.get("renderFormSeqNumber"))) {
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1652638&r1=1652637&r2=1652638&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Sat Jan 17 16:47:23 2015
@@ -52,6 +52,7 @@ import org.ofbiz.base.util.template.Free
import org.ofbiz.entity.Delegator;
import org.ofbiz.webapp.control.RequestHandler;
import org.ofbiz.webapp.taglib.ContentUrlTag;
+import org.ofbiz.widget.CommonWidgetModels;
import org.ofbiz.widget.ModelWidget;
import org.ofbiz.widget.WidgetWorker;
import org.ofbiz.widget.form.ModelFormField.CheckField;
@@ -307,7 +308,7 @@ public final class MacroFormRenderer imp
this.request.setAttribute("alternate", encodedAlternate);
this.request.setAttribute("imageTitle", encodedImageTitle);
this.request.setAttribute("descriptionSize", hyperlinkField.getSize());
- makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), hyperlinkField.getParameterMap(context), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context),
+ makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getUrlMode(), hyperlinkField.getTarget(context), hyperlinkField.getParameterMap(context), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context),
hyperlinkField.getConfirmation(context), modelFormField, this.request, this.response, context);
this.appendTooltip(writer, context, modelFormField);
this.request.removeAttribute("image");
@@ -740,7 +741,7 @@ public final class MacroFormRenderer imp
String alert = "false";
String name = modelFormField.getParameterName(context);
String id = modelFormField.getCurrentContainerId(context);
- String multiple = dropDownField.isAllowMultiple() ? "multiple" : "";
+ String multiple = dropDownField.getAllowMultiple() ? "multiple" : "";
String otherFieldName = "";
String formName = modelForm.getName();
String size = dropDownField.getSize();
@@ -792,11 +793,11 @@ public final class MacroFormRenderer imp
}
explicitDescription = encode(explicitDescription, modelFormField, context);
// if allow empty is true, add an empty option
- if (dropDownField.isAllowEmpty()) {
+ if (dropDownField.getAllowEmpty()) {
allowEmpty = "Y";
}
List<String> currentValueList = null;
- if (UtilValidate.isNotEmpty(currentValue) && dropDownField.isAllowMultiple()) {
+ if (UtilValidate.isNotEmpty(currentValue) && dropDownField.getAllowMultiple()) {
// If currentValue is Array, it will start with [
if (currentValue.startsWith("[")) {
currentValueList = StringUtil.toList(currentValue);
@@ -1219,7 +1220,7 @@ public final class MacroFormRenderer imp
FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink());
String fullTarget = target.expandString(context);
targetBuffer.append(fullTarget);
- String targetType = HyperlinkField.DEFAULT_TARGET_TYPE;
+ String targetType = CommonWidgetModels.Link.DEFAULT_URL_MODE;
if (UtilValidate.isNotEmpty(targetBuffer.toString()) && targetBuffer.toString().toLowerCase().startsWith("javascript:")) {
targetType = "plain";
}
@@ -2907,8 +2908,10 @@ public final class MacroFormRenderer imp
}
if (subHyperlink.shouldUse(context)) {
writer.append(' ');
- makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), subHyperlink.getTargetType(), subHyperlink.getTarget(context), subHyperlink.getParameterMap(context), subHyperlink.getDescription(context), subHyperlink.getTargetWindow(context), subHyperlink
- .getConfirmation(context), subHyperlink.getModelFormField(), this.request, this.response, context);
+ makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getStyle(context), subHyperlink.getUrlMode(),
+ subHyperlink.getTarget(context), subHyperlink.getParameterMap(context), subHyperlink.getDescription(context),
+ subHyperlink.getTargetWindow(context), null, subHyperlink.getModelFormField(), this.request, this.response,
+ context);
}
}
@@ -3074,13 +3077,13 @@ public final class MacroFormRenderer imp
}
}
- public void makeHiddenFormLinkForm(Appendable writer, String target, String targetType, String targetWindow, List<WidgetWorker.Parameter> parameterList, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
+ public void makeHiddenFormLinkForm(Appendable writer, String target, String targetType, String targetWindow, List<CommonWidgetModels.Parameter> parameterList, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
StringBuilder actionUrl = new StringBuilder();
WidgetWorker.buildHyperlinkUrl(actionUrl, target, targetType, null, null, false, false, true, request, response, context);
String name = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
StringBuilder parameters = new StringBuilder();
parameters.append("[");
- for (WidgetWorker.Parameter parameter : parameterList) {
+ for (CommonWidgetModels.Parameter parameter : parameterList) {
if (parameters.length() > 1) {
parameters.append(",");
}