Author: mbrohl
Date: Sun Dec 17 11:07:31 2017 New Revision: 1818472 URL: http://svn.apache.org/viewvc?rev=1818472&view=rev Log: Improved: General refactoring and code improvements, package org.apache.ofbiz.widget.model. (OFBIZ-9955) Thanks Dennis Balkir for reporting and providing the patches. Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/CommonWidgetModels.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FieldInfo.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FormFactory.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MenuFactory.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelAction.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelActionUtil.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelConditionFactory.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFieldVisitor.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormAction.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormFieldBuilder.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelGrid.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenu.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuAction.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuCondition.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuItem.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelScreenCondition.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelScreenWidget.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelSingleForm.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTheme.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTree.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTreeAction.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelTreeCondition.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidget.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ScreenFactory.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ThemeFactory.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/TreeFactory.java Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelAction.java Sun Dec 17 11:07:31 2017 @@ -70,21 +70,21 @@ public abstract class AbstractModelActio * ----------------------------------------------------------------------- * * DEVELOPERS PLEASE READ * ----------------------------------------------------------------------- * - * + * * This model is intended to be a read-only data structure that represents * an XML element. Outside of object construction, the class should not * have any behaviors. - * + * * Instances of this class will be shared by multiple threads - therefore * it is immutable. DO NOT CHANGE THE OBJECT'S STATE AT RUN TIME! - * + * */ public static final String module = AbstractModelAction.class.getName(); /** * Returns a new <code>ModelAction</code> instance, built from <code>actionElement</code>. - * + * * @param modelWidget The <code>ModelWidget</code> that contains the <actions> element * @param actionElement * @return A new <code>ModelAction</code> instance @@ -132,8 +132,9 @@ public abstract class AbstractModelActio * @param context */ public static void runSubActions(List<ModelAction> actions, Map<String, Object> context) { - if (actions == null) + if (actions == null) { return; + } for (ModelAction action : actions) { if (Debug.verboseOn()) { Debug.logVerbose("Running action " + action.getClass().getName(), module); @@ -183,7 +184,7 @@ public abstract class AbstractModelActio /** * Models the <entity-and> element. - * + * * @see <code>widget-screen.xsd</code> */ public static class EntityAnd extends AbstractModelAction { @@ -217,7 +218,7 @@ public abstract class AbstractModelActio /** * Models the <entity-condition> element. - * + * * @see <code>widget-screen.xsd</code> */ public static class EntityCondition extends AbstractModelAction { @@ -251,7 +252,7 @@ public abstract class AbstractModelActio /** * Models the <entity-one> element. - * + * * @see <code>widget-common.xsd</code> */ public static class EntityOne extends AbstractModelAction { @@ -285,7 +286,7 @@ public abstract class AbstractModelActio /** * Models the <get-related> element. - * + * * @see <code>widget-common.xsd</code> */ public static class GetRelated extends AbstractModelAction { @@ -370,7 +371,7 @@ public abstract class AbstractModelActio /** * Models the <get-related-one> element. - * + * * @see <code>widget-common.xsd</code> */ public static class GetRelatedOne extends AbstractModelAction { @@ -435,7 +436,7 @@ public abstract class AbstractModelActio /** * Models the <property-map> element. - * + * * @see <code>widget-common.xsd</code> */ public static class PropertyMap extends AbstractModelAction { @@ -509,7 +510,7 @@ public abstract class AbstractModelActio /** * Models the <property-to-field> element. - * + * * @see <code>widget-common.xsd</code> */ public static class PropertyToField extends AbstractModelAction { @@ -539,7 +540,6 @@ public abstract class AbstractModelActio @Override public void runAction(Map<String, Object> context) { - //String globalStr = this.globalExdr.expandString(context); // default to false //boolean global = "true".equals(globalStr); Locale locale = (Locale) context.get("locale"); @@ -598,7 +598,7 @@ public abstract class AbstractModelActio /** * Models the <script> element. - * + * * @see <code>widget-common.xsd</code> */ public static class Script extends AbstractModelAction { @@ -646,7 +646,7 @@ public abstract class AbstractModelActio /** * Models the <service> element. - * + * * @see <code>widget-screen.xsd</code> */ public static class Service extends AbstractModelAction { @@ -729,7 +729,7 @@ public abstract class AbstractModelActio /** * Models the <set> element. - * + * * @see <code>widget-common.xsd</code> */ public static class SetField extends AbstractModelAction { @@ -778,10 +778,11 @@ public abstract class AbstractModelActio for (int i = trailList.size(); i >= 0; i--) { List<String> subTrail = trailList.subList(0, i); String newKey = null; - if (subTrail.size() > 0) + if (subTrail.size() > 0) { newKey = StringUtil.join(subTrail, "|") + "|" + originalName; - else + } else { newKey = originalName; + } if (storeAgent instanceof ServletContext) { newValue = ((ServletContext) storeAgent).getAttribute(newKey); } else if (storeAgent instanceof HttpSession) { @@ -853,13 +854,15 @@ public abstract class AbstractModelActio } } if (!setIfNull && newValue == null){ - if (Debug.warningOn()) + if (Debug.warningOn()) { Debug.logWarning("Field value not found (null) for the field: [" + this.field.getOriginalName() + " and there was no default value, so field was not set", module); + } return; } if (!setIfEmpty && ObjectType.isEmpty(newValue)){ - if (Debug.warningOn()) + if (Debug.warningOn()) { Debug.logWarning("Field value not found (empty) for the field: [" + this.field.getOriginalName() + " and there was no default value, so field was not set", module); + } return; } if (this.toScope != null && "user".equals(this.toScope)) { Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java Sun Dec 17 11:07:31 2017 @@ -62,14 +62,14 @@ public abstract class AbstractModelCondi * ----------------------------------------------------------------------- * * DEVELOPERS PLEASE READ * ----------------------------------------------------------------------- * - * + * * This model is intended to be a read-only data structure that represents * an XML element. Outside of object construction, the class should not * have any behaviors. - * + * * Instances of this class will be shared by multiple threads - therefore * it is immutable. DO NOT CHANGE THE OBJECT'S STATE AT RUN TIME! - * + * */ public static final String module = AbstractModelCondition.class.getName(); @@ -109,7 +109,7 @@ public abstract class AbstractModelCondi /** * Models the <and> element. - * + * * @see <code>widget-common.xsd</code> */ public static class And extends AbstractModelCondition { @@ -212,7 +212,7 @@ public abstract class AbstractModelCondi /** * Models the <if-compare> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfCompare extends AbstractModelCondition { @@ -225,8 +225,9 @@ public abstract class AbstractModelCondi private IfCompare(ModelConditionFactory factory, ModelWidget modelWidget, Element condElement) { super(factory, modelWidget, condElement); String fieldAcsr = condElement.getAttribute("field"); - if (fieldAcsr.isEmpty()) + if (fieldAcsr.isEmpty()) { fieldAcsr = condElement.getAttribute("field-name"); + } this.fieldAcsr = FlexibleMapAccessor.getInstance(fieldAcsr); this.valueExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("value")); this.operator = condElement.getAttribute("operator"); @@ -287,7 +288,7 @@ public abstract class AbstractModelCondi /** * Models the <if-compare-field> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfCompareField extends AbstractModelCondition { @@ -300,12 +301,14 @@ public abstract class AbstractModelCondi private IfCompareField(ModelConditionFactory factory, ModelWidget modelWidget, Element condElement) { super(factory, modelWidget, condElement); String fieldAcsr = condElement.getAttribute("field"); - if (fieldAcsr.isEmpty()) + if (fieldAcsr.isEmpty()) { fieldAcsr = condElement.getAttribute("field-name"); + } this.fieldAcsr = FlexibleMapAccessor.getInstance(fieldAcsr); String toFieldAcsr = condElement.getAttribute("to-field"); - if (toFieldAcsr.isEmpty()) + if (toFieldAcsr.isEmpty()) { toFieldAcsr = condElement.getAttribute("to-field-name"); + } this.toFieldAcsr = FlexibleMapAccessor.getInstance(toFieldAcsr); this.operator = condElement.getAttribute("operator"); this.type = condElement.getAttribute("type"); @@ -367,7 +370,7 @@ public abstract class AbstractModelCondi /** * Models the <if-empty> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfEmpty extends AbstractModelCondition { @@ -376,8 +379,9 @@ public abstract class AbstractModelCondi private IfEmpty(ModelConditionFactory factory, ModelWidget modelWidget, Element condElement) { super(factory, modelWidget, condElement); String fieldAcsr = condElement.getAttribute("field"); - if (fieldAcsr.isEmpty()) + if (fieldAcsr.isEmpty()) { fieldAcsr = condElement.getAttribute("field-name"); + } this.fieldAcsr = FlexibleMapAccessor.getInstance(fieldAcsr); } @@ -400,7 +404,7 @@ public abstract class AbstractModelCondi /** * Models the <if-entity-permission> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfEntityPermission extends AbstractModelCondition { @@ -428,7 +432,7 @@ public abstract class AbstractModelCondi /** * Models the <if-has-permission> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfHasPermission extends AbstractModelCondition { @@ -480,7 +484,7 @@ public abstract class AbstractModelCondi /** * Models the <if-regexp> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfRegexp extends AbstractModelCondition { @@ -490,8 +494,9 @@ public abstract class AbstractModelCondi private IfRegexp(ModelConditionFactory factory, ModelWidget modelWidget, Element condElement) { super(factory, modelWidget, condElement); String fieldAcsr = condElement.getAttribute("field"); - if (fieldAcsr.isEmpty()) + if (fieldAcsr.isEmpty()) { fieldAcsr = condElement.getAttribute("field-name"); + } this.fieldAcsr = FlexibleMapAccessor.getInstance(fieldAcsr); this.exprExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("expr")); } @@ -521,8 +526,9 @@ public abstract class AbstractModelCondi Debug.logError(e, "Could not convert object to String, using empty String", module); } // always use an empty string by default - if (fieldString == null) + if (fieldString == null) { fieldString = ""; + } PatternMatcher matcher = new Perl5Matcher(); return matcher.matches(fieldString, pattern); } @@ -538,7 +544,7 @@ public abstract class AbstractModelCondi /** * Models the <if-service-permission> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfServicePermission extends AbstractModelCondition { @@ -641,7 +647,7 @@ public abstract class AbstractModelCondi /** * Models the <if-validate-method> element. - * + * * @see <code>widget-common.xsd</code> */ public static class IfValidateMethod extends AbstractModelCondition { @@ -652,8 +658,9 @@ public abstract class AbstractModelCondi private IfValidateMethod(ModelConditionFactory factory, ModelWidget modelWidget, Element condElement) { super(factory, modelWidget, condElement); String fieldAcsr = condElement.getAttribute("field"); - if (fieldAcsr.isEmpty()) + if (fieldAcsr.isEmpty()) { fieldAcsr = condElement.getAttribute("field-name"); + } this.fieldAcsr = FlexibleMapAccessor.getInstance(fieldAcsr); this.methodExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("method")); this.classExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("class")); @@ -679,8 +686,9 @@ public abstract class AbstractModelCondi } } // always use an empty string by default - if (fieldString == null) + if (fieldString == null) { fieldString = ""; + } Class<?>[] paramTypes = new Class[] { String.class }; Object[] params = new Object[] { fieldString }; Class<?> valClass; @@ -723,7 +731,7 @@ public abstract class AbstractModelCondi /** * Models the <not> element. - * + * * @see <code>widget-common.xsd</code> */ public static class Not extends AbstractModelCondition { @@ -752,7 +760,7 @@ public abstract class AbstractModelCondi /** * Models the <or> element. - * + * * @see <code>widget-common.xsd</code> */ public static class Or extends AbstractModelCondition { @@ -786,7 +794,7 @@ public abstract class AbstractModelCondi /** * Models the <xor> element. - * + * * @see <code>widget-common.xsd</code> */ public static class Xor extends AbstractModelCondition { Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/CommonWidgetModels.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/CommonWidgetModels.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/CommonWidgetModels.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/CommonWidgetModels.java Sun Dec 17 11:07:31 2017 @@ -91,8 +91,9 @@ public final class CommonWidgetModels { module); return autEntityParams; } - if (UtilValidate.isEmpty(entityName)) + if (UtilValidate.isEmpty(entityName)) { entityName = defaultEntityName; + } FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(entityName); ModelEntity entity = delegator.getModelEntity(toExpand.expandString(context)); if (entity == null) { @@ -150,8 +151,9 @@ public final class CommonWidgetModels { module); return autServiceParams; } - if (UtilValidate.isEmpty(serviceName)) + if (UtilValidate.isEmpty(serviceName)) { serviceName = defaultServiceName; + } FlexibleStringExpander toExpand = FlexibleStringExpander.getInstance(serviceName); ModelService service = null; try { @@ -168,8 +170,9 @@ public final class CommonWidgetModels { if (paramsIter != null) { while (paramsIter.hasNext()) { ModelParam param = paramsIter.next(); - if (param.getInternal()) + if (param.getInternal()) { continue; + } String paramName = param.getName(); FlexibleMapAccessor<Object> fma = FlexibleMapAccessor.getInstance(paramName); if (!excludeList.contains(paramName)) { @@ -354,9 +357,12 @@ public final class CommonWidgetModels { this.image = null; } } - //Backwards compatibility - if ("ajax-window".equals(linkElement.getAttribute("link-type"))) this.linkType = "layered-modal"; - else this.linkType = linkElement.getAttribute("link-type"); + //Backwards compatibility + if ("ajax-window".equals(linkElement.getAttribute("link-type"))) { + this.linkType = "layered-modal"; + } else { + this.linkType = linkElement.getAttribute("link-type"); + } List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter"); if (parameterElementList.isEmpty()) { this.parameterList = Collections.emptyList(); @@ -580,7 +586,7 @@ public final class CommonWidgetModels { /** * Models the <parameter> element. - * + * * @see <code>widget-form.xsd</code> */ public static class Parameter { @@ -629,8 +635,9 @@ public final class CommonWidgetModels { } if (retVal != null) { TimeZone timeZone = (TimeZone) context.get("timeZone"); - if (timeZone == null) + 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) { Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FieldInfo.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FieldInfo.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FieldInfo.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FieldInfo.java Sun Dec 17 11:07:31 2017 @@ -73,7 +73,7 @@ public abstract class FieldInfo { private static List<Integer> nonInputFieldTypeList = createNonInputFieldTypeList(); private static Map<String, Integer> createFieldTypeMap() { - Map<String, Integer> fieldTypeByName = new HashMap<String, Integer>(); + Map<String, Integer> fieldTypeByName = new HashMap<>(); fieldTypeByName.put("display", Integer.valueOf(1)); fieldTypeByName.put("hyperlink", Integer.valueOf(2)); fieldTypeByName.put("text", Integer.valueOf(3)); @@ -103,7 +103,7 @@ public abstract class FieldInfo { } private static List<Integer> createNonInputFieldTypeList() { - List<Integer> nonInputFieldTypeList = new ArrayList<Integer>(); + List<Integer> nonInputFieldTypeList = new ArrayList<>(); nonInputFieldTypeList.add(FieldInfo.IGNORED); nonInputFieldTypeList.add(FieldInfo.HIDDEN); nonInputFieldTypeList.add(FieldInfo.DISPLAY); @@ -120,9 +120,8 @@ public abstract class FieldInfo { Integer fieldTypeInt = FieldInfo.fieldTypeByName.get(name); if (fieldTypeInt != null) { return fieldTypeInt; - } else { - throw new IllegalArgumentException("Could not get fieldType for field type name " + name); } + throw new IllegalArgumentException("Could not get fieldType for field type name " + name); } public static boolean isInputFieldType(Integer fieldType) { @@ -151,7 +150,7 @@ public abstract class FieldInfo { /** * Returns a new instance of this object. - * + * * @param modelFormField */ public abstract FieldInfo copy(ModelFormField modelFormField); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FormFactory.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FormFactory.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FormFactory.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/FormFactory.java Sun Dec 17 11:07:31 2017 @@ -99,7 +99,7 @@ public class FormFactory { } public static Map<String, ModelForm> readFormDocument(Document formFileDoc, ModelReader entityModelReader, DispatchContext dispatchContext, String formLocation) { - Map<String, ModelForm> modelFormMap = new HashMap<String, ModelForm>(); + Map<String, ModelForm> modelFormMap = new HashMap<>(); if (formFileDoc != null) { // read document and construct ModelForm for each form element Element rootElement = formFileDoc.getDocumentElement(); @@ -134,8 +134,7 @@ public class FormFactory { String formType = formElement.getAttribute("type"); if (formType.isEmpty() || "single".equals(formType) || "upload".equals(formType)) { return new ModelSingleForm(formElement, formLocation, entityModelReader, dispatchContext); - } else { - return new ModelGrid(formElement, formLocation, entityModelReader, dispatchContext); } + return new ModelGrid(formElement, formLocation, entityModelReader, dispatchContext); } } Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/GridFactory.java Sun Dec 17 11:07:31 2017 @@ -100,7 +100,7 @@ public class GridFactory { } public static Map<String, ModelGrid> readGridDocument(Document gridFileDoc, ModelReader entityModelReader, DispatchContext dispatchContext, String gridLocation) { - Map<String, ModelGrid> modelGridMap = new HashMap<String, ModelGrid>(); + Map<String, ModelGrid> modelGridMap = new HashMap<>(); if (gridFileDoc != null) { // read document and construct ModelGrid for each grid element Element rootElement = gridFileDoc.getDocumentElement(); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java Sun Dec 17 11:07:31 2017 @@ -19,7 +19,6 @@ package org.apache.ofbiz.widget.model; import java.io.IOException; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -143,7 +142,6 @@ public class HtmlWidget extends ModelScr public static void renderHtmlTemplate(Appendable writer, FlexibleStringExpander locationExdr, Map<String, Object> context) { String location = locationExdr.expandString(context); - //Debug.logInfo("Rendering template at location [" + location + "] with context: \n" + context, module); if (UtilValidate.isEmpty(location)) { throw new IllegalArgumentException("Template location is empty with search string location " + locationExdr.getOriginal()); @@ -168,19 +166,7 @@ public class HtmlWidget extends ModelScr if (insertWidgetBoundaryComments) { writer.append(HtmlWidgetRenderer.formatBoundaryComment("End", "Template", location)); } - } catch (IllegalArgumentException e) { - String errMsg = "Error rendering included template at location [" + location + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - writeError(writer, errMsg); - } catch (MalformedURLException e) { - String errMsg = "Error rendering included template at location [" + location + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - writeError(writer, errMsg); - } catch (TemplateException e) { - String errMsg = "Error rendering included template at location [" + location + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - writeError(writer, errMsg); - } catch (IOException e) { + } catch (IllegalArgumentException | TemplateException | IOException e) { String errMsg = "Error rendering included template at location [" + location + "]: " + e.toString(); Debug.logError(e, errMsg, module); writeError(writer, errMsg); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java Sun Dec 17 11:07:31 2017 @@ -277,23 +277,6 @@ public class IterateSectionWidget extend viewSize = this.getViewSize(); } - - /* - int highIndex = -1; - try { - highIndex = modelForm.getHighIndex(); - } catch (Exception e) { - highIndex = 0; - } - - int lowIndex = -1; - try { - lowIndex = modelForm.getLowIndex(); - } catch (Exception e) { - lowIndex = 0; - } - */ - int lowIndex = viewIndex * viewSize; int highIndex = (viewIndex + 1) * viewSize; // if this is all there seems to be (if listSize < 0, then size is unknown) @@ -314,9 +297,11 @@ public class IterateSectionWidget extend if (viewIndex > 0) { writer.append(" <a href=\""); StringBuilder linkText = new StringBuilder(targetService); - if (linkText.indexOf("?") < 0) linkText.append("?"); - else linkText.append("&"); - //if (queryString != null && !"null".equals(queryString)) linkText += queryString + "&"; + if (linkText.indexOf("?") < 0) { + linkText.append("?"); + } else { + linkText.append("&"); + } if (UtilValidate.isNotEmpty(queryString)) { linkText.append(queryString).append("&"); } @@ -336,8 +321,11 @@ public class IterateSectionWidget extend if (highIndex < listSize) { writer.append(" <a href=\""); StringBuilder linkText = new StringBuilder(targetService); - if (linkText.indexOf("?") < 0) linkText.append("?"); - else linkText.append("&"); + if (linkText.indexOf("?") < 0) { + linkText.append("?"); + } else { + linkText.append("&"); + } if (UtilValidate.isNotEmpty(queryString)) { linkText.append(queryString).append("&"); } @@ -381,6 +369,4 @@ public class IterateSectionWidget extend return paginate; } -} - - +} \ No newline at end of file Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MenuFactory.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MenuFactory.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MenuFactory.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/MenuFactory.java Sun Dec 17 11:07:31 2017 @@ -75,7 +75,7 @@ public class MenuFactory { } public static Map<String, ModelMenu> readMenuDocument(Document menuFileDoc, String menuLocation) { - Map<String, ModelMenu> modelMenuMap = new HashMap<String, ModelMenu>(); + Map<String, ModelMenu> modelMenuMap = new HashMap<>(); if (menuFileDoc != null) { // read document and construct ModelMenu for each menu element Element rootElement = menuFileDoc.getDocumentElement(); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelAction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelAction.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelAction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelAction.java Sun Dec 17 11:07:31 2017 @@ -28,7 +28,7 @@ public interface ModelAction { /** * Executes this action. - * + * * @param context * @throws GeneralException */ Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelActionUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelActionUtil.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelActionUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelActionUtil.java Sun Dec 17 11:07:31 2017 @@ -24,7 +24,7 @@ import org.apache.ofbiz.base.util.UtilVa import org.apache.ofbiz.base.util.collections.FlexibleMapAccessor; public class ModelActionUtil { - + /** * @param context * @param result Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelConditionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelConditionFactory.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelConditionFactory.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelConditionFactory.java Sun Dec 17 11:07:31 2017 @@ -27,7 +27,7 @@ import org.w3c.dom.Element; 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>. Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFieldVisitor.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFieldVisitor.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFieldVisitor.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFieldVisitor.java Sun Dec 17 11:07:31 2017 @@ -64,7 +64,7 @@ public interface ModelFieldVisitor { void visit(DropDownField dropDownField) throws Exception ; void visit(FileField fileField) throws Exception ; - + void visit(FormField formField) throws Exception ; void visit(GridField gridField) throws Exception ; Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sun Dec 17 11:07:31 2017 @@ -56,7 +56,7 @@ import org.w3c.dom.Element; /** * Abstract base class for the <form> and <grid> elements. - * + * * @see <code>widget-form.xsd</code> */ @SuppressWarnings("serial") @@ -66,18 +66,18 @@ public abstract class ModelForm extends * ----------------------------------------------------------------------- * * DEVELOPERS PLEASE READ * ----------------------------------------------------------------------- * - * + * * This model is intended to be a read-only data structure that represents * an XML element. Outside of object construction, the class should not * have any behaviors. All behavior should be contained in model visitors. - * + * * 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 = ModelForm.class.getName(); @@ -1079,7 +1079,7 @@ public abstract class ModelForm extends String size = this.overrideListSize.expandString(context); try { size = size.replaceAll("[^0-9.]", ""); - if (!size.isEmpty()) { + if (!size.isEmpty()) { listSize = Integer.parseInt(size); } } catch (NumberFormatException e) { Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormAction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormAction.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormAction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormAction.java Sun Dec 17 11:07:31 2017 @@ -71,7 +71,7 @@ public abstract class ModelFormAction { /** * Models the <call-parent-actions> element. - * + * * @see <code>widget-form.xsd</code> */ @SuppressWarnings("serial") @@ -121,7 +121,7 @@ public abstract class ModelFormAction { /** * Models the <service> element. - * + * * @see <code>widget-form.xsd</code> */ @SuppressWarnings("serial") @@ -152,15 +152,17 @@ public abstract class ModelFormAction { // this is deprecated, but support it for now anyway resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement .getAttribute("result-map-list-iterator")); - if (resultMapListNameExdr.isEmpty()) + if (resultMapListNameExdr.isEmpty()) { resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement .getAttribute("result-map-list-iterator-name")); + } } } else { resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("result-map-list")); - if (resultMapListNameExdr.isEmpty()) + if (resultMapListNameExdr.isEmpty()) { resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement .getAttribute("result-map-list-name")); + } } this.resultMapListNameExdr = resultMapListNameExdr; this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java?rev=1818472&r1=1818471&r2=1818472&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java Sun Dec 17 11:07:31 2017 @@ -80,7 +80,7 @@ import org.w3c.dom.Element; /** * Models the <field> element. - * + * * @see <code>widget-form.xsd</code> */ public class ModelFormField { @@ -89,14 +89,14 @@ public class ModelFormField { * ----------------------------------------------------------------------- * * DEVELOPERS PLEASE READ * ----------------------------------------------------------------------- * - * + * * This model is intended to be a read-only data structure that represents * an XML element. Outside of object construction, the class should not * have any behaviors. All behavior should be contained in model visitors. - * + * * Instances of this class will be shared by multiple threads - therefore * it is immutable. DO NOT CHANGE THE OBJECT'S STATE AT RUN TIME! - * + * */ public static final String module = ModelFormField.class.getName(); @@ -204,8 +204,9 @@ public class ModelFormField { } public String getAction(Map<String, ? extends Object> context) { - if (UtilValidate.isNotEmpty(this.action)) + if (UtilValidate.isNotEmpty(this.action)) { return action.expandString(context); + } return null; } @@ -214,11 +215,12 @@ public class ModelFormField { * with this field. This can be used to get additional information about the field. * Use the getServiceName() method to get the Entity name that the field is in. * - * @return returns the name of the Service Attribute + * @return returns the name of the Service Attribute */ public String getAttributeName() { - if (UtilValidate.isNotEmpty(this.attributeName)) + if (UtilValidate.isNotEmpty(this.attributeName)) { return this.attributeName; + } return this.name; } @@ -242,8 +244,9 @@ public class ModelFormField { } public String getEntityName() { - if (UtilValidate.isNotEmpty(this.entityName)) + if (UtilValidate.isNotEmpty(this.entityName)) { return this.entityName; + } return this.modelForm.getDefaultEntityName(); } @@ -265,11 +268,13 @@ public class ModelFormField { Boolean useRequestParameters = (Boolean) context.get("useRequestParameters"); Locale locale = (Locale) context.get("locale"); - if (locale == null) + if (locale == null) { locale = Locale.getDefault(); + } TimeZone timeZone = (TimeZone) context.get("timeZone"); - if (timeZone == null) + if (timeZone == null) { timeZone = TimeZone.getDefault(); + } UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder"); @@ -279,7 +284,6 @@ public class ModelFormField { // if isError is TRUE and useRequestParameters is not FALSE (ie is null or TRUE) then parameters will be used if ((Boolean.TRUE.equals(isError) && !Boolean.FALSE.equals(useRequestParameters)) || (Boolean.TRUE.equals(useRequestParameters))) { - //Debug.logInfo("Getting entry, isError true so getting from parameters for field " + this.getName() + " of form " + this.modelForm.getName(), module); Map<String, Object> parameters = UtilGenerics.checkMap(context.get("parameters"), String.class, Object.class); String parameterName = this.getParameterName(context); if (parameters != null && parameters.get(parameterName) != null) { @@ -296,11 +300,9 @@ public class ModelFormField { returnValue = defaultValue; } } else { - //Debug.logInfo("Getting entry, isError false so getting from Map in context for field " + this.getName() + " of form " + this.modelForm.getName(), module); Map<String, ? extends Object> dataMap = this.getMap(context); boolean dataMapIsContext = false; if (dataMap == null) { - //Debug.logInfo("Getting entry, no Map found with name " + this.getMapName() + ", using context for field " + this.getName() + " of form " + this.modelForm.getName(), module); dataMap = context; dataMapIsContext = true; } @@ -327,10 +329,11 @@ public class ModelFormField { if (dataMapIsContext && retVal == null && !Boolean.FALSE.equals(useRequestParameters)) { Map<String, ? extends Object> parameters = UtilGenerics.checkMap(context.get("parameters")); if (parameters != null) { - if (UtilValidate.isNotEmpty(this.entryAcsr)) + if (UtilValidate.isNotEmpty(this.entryAcsr)) { retVal = this.entryAcsr.get(parameters); - else + } else { retVal = parameters.get(this.name); + } } } @@ -378,8 +381,9 @@ public class ModelFormField { } if (this.getEncodeOutput() && returnValue != null) { - if (simpleEncoder != null) + if (simpleEncoder != null) { returnValue = simpleEncoder.encode(returnValue); + } } if (returnValue != null) { @@ -393,8 +397,9 @@ public class ModelFormField { } public String getEntryName() { - if (UtilValidate.isNotEmpty(this.entryAcsr)) + if (UtilValidate.isNotEmpty(this.entryAcsr)) { return this.entryAcsr.getOriginalName(); + } return this.name; } @@ -414,8 +419,9 @@ public class ModelFormField { * @return return the name of the Entity Field that corresponds with this field */ public String getFieldName() { - if (UtilValidate.isNotEmpty(this.fieldName)) + if (UtilValidate.isNotEmpty(this.fieldName)) { return this.fieldName; + } return this.name; } @@ -428,8 +434,9 @@ public class ModelFormField { } public String getIdName() { - if (UtilValidate.isNotEmpty(idName)) + if (UtilValidate.isNotEmpty(idName)) { return idName; + } String parentFormName = this.getParentFormName(); if (UtilValidate.isNotEmpty(parentFormName)) { return parentFormName + "_" + this.getFieldName(); @@ -442,10 +449,10 @@ public class ModelFormField { } public Map<String, ? extends Object> getMap(Map<String, ? extends Object> context) { - if (UtilValidate.isEmpty(this.mapAcsr)) - return this.modelForm.getDefaultMap(context); //Debug.logInfo("Getting Map from default of the form because of no mapAcsr for field " + this.getName(), module); + if (UtilValidate.isEmpty(this.mapAcsr)) { + return this.modelForm.getDefaultMap(context); + } - // Debug.logInfo("Getting Map from mapAcsr for field " + this.getName() + ", map-name=" + mapAcsr.getOriginalName() + ", context type=" + context.getClass().toString(), module); Map<String, ? extends Object> result = null; try { result = mapAcsr.get(context); @@ -471,8 +478,9 @@ public class ModelFormField { * @return returns the name of the Map in the form context that contains the entry */ public String getMapName() { - if (UtilValidate.isNotEmpty(this.mapAcsr)) + if (UtilValidate.isNotEmpty(this.mapAcsr)) { return this.mapAcsr.getOriginalName(); + } return this.modelForm.getDefaultMapName(); } @@ -504,10 +512,11 @@ public class ModelFormField { */ public String getParameterName(Map<String, ? extends Object> context) { String baseName; - if (UtilValidate.isNotEmpty(this.parameterName)) + if (UtilValidate.isNotEmpty(this.parameterName)) { baseName = this.parameterName; - else + } else { baseName = this.name; + } Integer itemIndex = (Integer) context.get("itemIndex"); if (itemIndex != null && "multi".equals(this.modelForm.getType())) { @@ -517,8 +526,9 @@ public class ModelFormField { } public int getPosition() { - if (this.position == null) + if (this.position == null) { return 1; + } return position.intValue(); } @@ -531,8 +541,9 @@ public class ModelFormField { } public String getRequiredFieldStyle() { - if (UtilValidate.isNotEmpty(this.requiredFieldStyle)) + if (UtilValidate.isNotEmpty(this.requiredFieldStyle)) { return this.requiredFieldStyle; + } return this.modelForm.getDefaultRequiredFieldStyle(); } @@ -541,8 +552,9 @@ public class ModelFormField { } public String getServiceName() { - if (UtilValidate.isNotEmpty(this.serviceName)) + if (UtilValidate.isNotEmpty(this.serviceName)) { return this.serviceName; + } return this.modelForm.getDefaultServiceName(); } @@ -567,20 +579,23 @@ public class ModelFormField { } public String getSortFieldStyle() { - if (UtilValidate.isNotEmpty(this.sortFieldStyle)) + if (UtilValidate.isNotEmpty(this.sortFieldStyle)) { return this.sortFieldStyle; + } return this.modelForm.getDefaultSortFieldStyle(); } public String getSortFieldStyleAsc() { - if (UtilValidate.isNotEmpty(this.sortFieldAscStyle)) + if (UtilValidate.isNotEmpty(this.sortFieldAscStyle)) { return this.sortFieldAscStyle; + } return this.modelForm.getDefaultSortFieldAscStyle(); } public String getSortFieldStyleDesc() { - if (UtilValidate.isNotEmpty(this.sortFieldDescStyle)) + if (UtilValidate.isNotEmpty(this.sortFieldDescStyle)) { return this.sortFieldDescStyle; + } return this.modelForm.getDefaultSortFieldDescStyle(); } @@ -589,12 +604,14 @@ public class ModelFormField { } public String getTitle(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.title)) + if (UtilValidate.isNotEmpty(this.title)) { return title.expandString(context); + } // create a title from the name of this field; expecting a Java method/field style name, ie productName or productCategoryId - if (UtilValidate.isEmpty(this.name)) + if (UtilValidate.isEmpty(this.name)) { return ""; // this should never happen, ie name is required + } // search for a localized label for the field's name Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap")); @@ -627,14 +644,16 @@ public class ModelFormField { } public String getTitleAreaStyle() { - if (UtilValidate.isNotEmpty(this.titleAreaStyle)) + if (UtilValidate.isNotEmpty(this.titleAreaStyle)) { return this.titleAreaStyle; + } return this.modelForm.getDefaultTitleAreaStyle(); } public String getTitleStyle() { - if (UtilValidate.isNotEmpty(this.titleStyle)) + if (UtilValidate.isNotEmpty(this.titleStyle)) { return this.titleStyle; + } return this.modelForm.getDefaultTitleStyle(); } @@ -644,19 +663,22 @@ public class ModelFormField { public String getTooltip(Map<String, Object> context) { String tooltipString = ""; - if (UtilValidate.isNotEmpty(tooltip)) + if (UtilValidate.isNotEmpty(tooltip)) { tooltipString = tooltip.expandString(context); + } if (this.getEncodeOutput()) { UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder"); - if (simpleEncoder != null) + if (simpleEncoder != null) { tooltipString = simpleEncoder.encode(tooltipString); + } } return tooltipString; } public String getTooltipStyle() { - if (UtilValidate.isNotEmpty(this.tooltipStyle)) + if (UtilValidate.isNotEmpty(this.tooltipStyle)) { return this.tooltipStyle; + } return this.modelForm.getDefaultTooltipStyle(); } @@ -665,32 +687,37 @@ public class ModelFormField { } public String getUseWhen(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.useWhen)) + if (UtilValidate.isNotEmpty(this.useWhen)) { return this.useWhen.expandString(context); + } return ""; } public String getIgnoreWhen(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.ignoreWhen)) + if (UtilValidate.isNotEmpty(this.ignoreWhen)) { return this.ignoreWhen.expandString(context); + } return ""; } public String getWidgetAreaStyle() { - if (UtilValidate.isNotEmpty(this.widgetAreaStyle)) + if (UtilValidate.isNotEmpty(this.widgetAreaStyle)) { return this.widgetAreaStyle; + } return this.modelForm.getDefaultWidgetAreaStyle(); } public String getWidgetStyle() { - if (UtilValidate.isNotEmpty(this.widgetStyle)) + if (UtilValidate.isNotEmpty(this.widgetStyle)) { return this.widgetStyle; + } return this.modelForm.getDefaultWidgetStyle(); } public String getParentFormName() { - if (UtilValidate.isNotEmpty(this.parentFormName)) + if (UtilValidate.isNotEmpty(this.parentFormName)) { return this.parentFormName; + } return ""; } @@ -698,12 +725,15 @@ public class ModelFormField { * Checks if field is a row submit field. */ public boolean isRowSubmit() { - if (!"multi".equals(getModelForm().getType())) + if (!"multi".equals(getModelForm().getType())) { return false; - if (getFieldInfo().getFieldType() != FieldInfo.CHECK) + } + if (getFieldInfo().getFieldType() != FieldInfo.CHECK) { return false; - if (!CheckField.ROW_SUBMIT_FIELD_NAME.equals(getName())) + } + if (!CheckField.ROW_SUBMIT_FIELD_NAME.equals(getName())) { return false; + } return true; } @@ -738,8 +768,9 @@ public class ModelFormField { String redCondition = this.redWhen; - if ("never".equals(redCondition)) + if ("never".equals(redCondition)) { return false; + } // for performance resaons we check this first, most fields will be eliminated here and the valueOfs will not be necessary if (UtilValidate.isEmpty(redCondition) || "by-name".equals(redCondition)) { @@ -841,8 +872,9 @@ public class ModelFormField { public boolean shouldUse(Map<String, Object> context) { String useWhenStr = this.getUseWhen(context); - if (UtilValidate.isEmpty(useWhenStr)) + if (UtilValidate.isEmpty(useWhenStr)) { return true; + } try { Object retVal = GroovyUtil.eval(StringUtil.convertOperatorSubstitutions(useWhenStr),context); @@ -868,7 +900,7 @@ public class ModelFormField { /** * Models the <auto-complete> element. - * + * * @see <code>widget-form.xsd</code> */ public static class AutoComplete { @@ -927,7 +959,7 @@ public class ModelFormField { /** * Models the <check> element. - * + * * @see <code>widget-form.xsd</code> */ public static class CheckField extends FieldInfoWithOptions { @@ -970,8 +1002,9 @@ public class ModelFormField { public Boolean isAllChecked(Map<String, Object> context) { String allCheckedStr = this.allChecked.expandString(context); - if (!allCheckedStr.isEmpty()) + if (!allCheckedStr.isEmpty()) { return Boolean.valueOf("true".equals(allCheckedStr)); + } return null; } @@ -984,7 +1017,7 @@ public class ModelFormField { /** * Models the <container> element. - * + * * @see <code>widget-form.xsd</code> */ public static class ContainerField extends FieldInfo { @@ -1020,7 +1053,7 @@ public class ModelFormField { /** * Models the <date-find> element. - * + * * @see <code>widget-form.xsd</code> */ public static class DateFindField extends DateTimeField { @@ -1104,7 +1137,7 @@ public class ModelFormField { /** * Models the <date-time> element. - * + * * @see <code>widget-form.xsd</code> */ public static class DateTimeField extends FieldInfo { @@ -1190,15 +1223,17 @@ public class ModelFormField { * @return Default value string for date-time */ public String getDefaultDateTimeString(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.defaultValue)) + if (UtilValidate.isNotEmpty(this.defaultValue)) { return this.getDefaultValue(context); + } - if ("date".equals(this.type)) + if ("date".equals(this.type)) { return (new java.sql.Date(System.currentTimeMillis())).toString(); - else if ("time".equals(this.type)) + } else if ("time".equals(this.type)) { return (new java.sql.Time(System.currentTimeMillis())).toString(); - else + } else { return UtilDateTime.nowTimestamp().toString(); + } } public FlexibleStringExpander getDefaultValue() { @@ -1237,7 +1272,7 @@ public class ModelFormField { /** * Models the <display-entity> element. - * + * * @see <code>widget-form.xsd</code> */ public static class DisplayEntityField extends DisplayField { @@ -1308,8 +1343,9 @@ public class ModelFormField { // rather than using the context to expand the string, lookup the given entity and use it to expand the string GenericValue value = null; String fieldKey = this.keyFieldName; - if (UtilValidate.isEmpty(fieldKey)) + if (UtilValidate.isEmpty(fieldKey)) { fieldKey = getModelFormField().fieldName; + } Delegator delegator = WidgetWorker.getDelegator(context); String fieldValue = getModelFormField().getEntry(context); @@ -1337,7 +1373,7 @@ public class ModelFormField { // try to get the entry for the field if description doesn't expand to anything if (UtilValidate.isEmpty(retVal)) { retVal = fieldValue; - } + } if (UtilValidate.isEmpty(retVal)) { retVal = ""; } else if (this.getModelFormField().getEncodeOutput()) { @@ -1364,7 +1400,7 @@ public class ModelFormField { /** * Models the <display> element. - * + * * @see <code>widget-form.xsd</code> */ public static class DisplayField extends FieldInfo { @@ -1487,21 +1523,24 @@ public class ModelFormField { public String getDescription(Map<String, Object> context) { String retVal = null; - if (UtilValidate.isNotEmpty(this.description)) + if (UtilValidate.isNotEmpty(this.description)) { retVal = this.description.expandString(context); - else + } else { retVal = getModelFormField().getEntry(context); + } if (UtilValidate.isEmpty(retVal)) { retVal = this.getDefaultValue(context); } else if ("currency".equals(type)) { retVal = retVal.replaceAll(" ", " "); // FIXME : encoding currency is a problem for some locale, we should not have any in retVal other case may arise in future... Locale locale = (Locale) context.get("locale"); - if (locale == null) + if (locale == null) { locale = Locale.getDefault(); + } String isoCode = null; - if (UtilValidate.isNotEmpty(this.currency)) + if (UtilValidate.isNotEmpty(this.currency)) { isoCode = this.currency.expandString(context); + } try { BigDecimal parsedRetVal = (BigDecimal) ObjectType.simpleTypeConvert(retVal, "BigDecimal", null, null, locale, @@ -1587,8 +1626,9 @@ public class ModelFormField { } public String getImageLocation(Map<String, Object> context) { - if (this.imageLocation != null) + if (this.imageLocation != null) { return this.imageLocation.expandString(context); + } return ""; } @@ -1613,7 +1653,7 @@ public class ModelFormField { /** * Models the <drop-down> element. - * + * * @see <code>widget-form.xsd</code> */ public static class DropDownField extends FieldInfoWithOptions { @@ -1743,8 +1783,9 @@ public class ModelFormField { } public String getCurrent() { - if (UtilValidate.isEmpty(this.current)) + if (UtilValidate.isEmpty(this.current)) { return "first-in-list"; + } return this.current; } @@ -1753,8 +1794,9 @@ public class ModelFormField { } public String getCurrentDescription(Map<String, Object> context) { - if (this.currentDescription == null) + if (this.currentDescription == null) { return null; + } return this.currentDescription.expandString(context); } @@ -1770,10 +1812,11 @@ public class ModelFormField { */ public String getParameterNameOther(Map<String, Object> context) { String baseName; - if (UtilValidate.isNotEmpty(getModelFormField().parameterName)) + if (UtilValidate.isNotEmpty(getModelFormField().parameterName)) { baseName = getModelFormField().parameterName; - else + } else { baseName = getModelFormField().name; + } baseName += "_OTHER"; Integer itemIndex = (Integer) context.get("itemIndex"); @@ -1812,7 +1855,7 @@ public class ModelFormField { /** * Models the <entity-options> element. - * + * * @see <code>widget-form.xsd</code> */ public static class EntityOptions extends OptionSource { @@ -1907,7 +1950,7 @@ public class ModelFormField { if (!localizedOrderBy) { values = delegator.findList(this.entityName, findCondition, null, this.orderByList, null, this.cache); } else { - //if entity has localized label + //if entity has localized label values = delegator.findList(this.entityName, findCondition, null, null, null, this.cache); values = EntityUtil.localizedOrderBy(values, this.orderByList, locale); } @@ -1974,8 +2017,9 @@ public class ModelFormField { } public String getKeyFieldName() { - if (UtilValidate.isNotEmpty(this.keyFieldName)) + if (UtilValidate.isNotEmpty(this.keyFieldName)) { return this.keyFieldName; + } return getModelFormField().getFieldName(); // get the modelFormField fieldName } @@ -1987,11 +2031,13 @@ public class ModelFormField { public static abstract class FieldInfoWithOptions extends FieldInfo { public static String getDescriptionForOptionKey(String key, List<OptionValue> allOptionValues) { - if (UtilValidate.isEmpty(key)) + if (UtilValidate.isEmpty(key)) { return ""; + } - if (UtilValidate.isEmpty(allOptionValues)) + if (UtilValidate.isEmpty(allOptionValues)) { return key; + } for (OptionValue optionValue : allOptionValues) { if (key.equals(optionValue.getKey())) { @@ -2080,7 +2126,7 @@ public class ModelFormField { /** * Models the <file> element. - * + * * @see <code>widget-form.xsd</code> */ public static class FileField extends TextField { @@ -2113,10 +2159,10 @@ public class ModelFormField { formStringRenderer.renderFileField(writer, context, this); } } - + /** * Models the <include-form> element. - * + * * @see <code>widget-form.xsd</code> */ public static class FormField extends FieldInfo { @@ -2194,10 +2240,10 @@ public class ModelFormField { return modelForm; } } - + /** * Models the <include-grid> element. - * + * * @see <code>widget-form.xsd</code> */ public static class GridField extends FieldInfo { @@ -2278,7 +2324,7 @@ public class ModelFormField { /** * Models the <hidden> element. - * + * * @see <code>widget-form.xsd</code> */ public static class HiddenField extends FieldInfo { @@ -2339,7 +2385,7 @@ public class ModelFormField { /** * Models the <hyperlink> element. - * + * * @see <code>widget-form.xsd</code> */ public static class HyperlinkField extends FieldInfo { @@ -2380,8 +2426,9 @@ public class ModelFormField { public String getConfirmation(Map<String, Object> context) { String message = getConfirmationMsg(context); - if (UtilValidate.isNotEmpty(message)) + if (UtilValidate.isNotEmpty(message)) { return message; + } if (getRequestConfirmation()) { String defaultMessage = UtilProperties.getPropertyValue("general", "default.confirmation.message", "${uiLabelMap.CommonConfirm}"); @@ -2486,7 +2533,7 @@ public class ModelFormField { public List<Parameter> getParameterList() { return link.getParameterList(); } - + public Map<String, String> getParameterMap(Map<String, Object> context, String defaultEntityName, String defaultServiceName) { return link.getParameterMap(context, defaultEntityName, defaultServiceName); } @@ -2560,7 +2607,7 @@ public class ModelFormField { /** * Models the <ignored> element. - * + * * @see <code>widget-form.xsd</code> */ public static class IgnoredField extends FieldInfo { @@ -2600,7 +2647,7 @@ public class ModelFormField { /** * Models the <image> element. - * + * * @see <code>widget-form.xsd</code> */ public static class ImageField extends FieldInfo { @@ -2669,8 +2716,9 @@ public class ModelFormField { } public String getAlternate(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.alternate)) + if (UtilValidate.isNotEmpty(this.alternate)) { return this.alternate.expandString(context); + } return ""; } @@ -2690,8 +2738,9 @@ public class ModelFormField { } public String getDescription(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.description)) + if (UtilValidate.isNotEmpty(this.description)) { return this.description.expandString(context); + } return ""; } @@ -2700,8 +2749,9 @@ public class ModelFormField { } public String getStyle(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.style)) + if (UtilValidate.isNotEmpty(this.style)) { return this.style.expandString(context); + } return ""; } @@ -2714,8 +2764,9 @@ public class ModelFormField { } public String getValue(Map<String, Object> context) { - if (UtilValidate.isNotEmpty(this.value)) + if (UtilValidate.isNotEmpty(this.value)) { return this.value.expandString(context); + } return getModelFormField().getEntry(context); } @@ -2728,7 +2779,7 @@ public class ModelFormField { /** * Models the <in-place-editor> element. - * + * * @see <code>widget-form.xsd</code> */ public static class InPlaceEditor { @@ -2908,7 +2959,7 @@ public class ModelFormField { /** * Models the <list-options> element. - * + * * @see <code>widget-form.xsd</code> */ public static class ListOptions extends OptionSource { @@ -2997,7 +3048,7 @@ public class ModelFormField { /** * Models the <lookup> element. - * + * * @see <code>widget-form.xsd</code> */ public static class LookupField extends TextField { @@ -3129,7 +3180,7 @@ public class ModelFormField { /** * Models the <include-menu> element. - * + * * @see <code>widget-form.xsd</code> */ public static class MenuField extends FieldInfo { @@ -3239,7 +3290,7 @@ public class ModelFormField { /** * Models the <password> element. - * + * * @see <code>widget-form.xsd</code> */ public static class PasswordField extends TextField { @@ -3275,7 +3326,7 @@ public class ModelFormField { /** * Models the <radio> element. - * + * * @see <code>widget-form.xsd</code> */ public static class RadioField extends FieldInfoWithOptions { @@ -3315,7 +3366,7 @@ public class ModelFormField { /** * Models the <range-find> element. - * + * * @see <code>widget-form.xsd</code> */ public static class RangeFindField extends TextField { @@ -3367,7 +3418,7 @@ public class ModelFormField { /** * Models the <reset> element. - * + * * @see <code>widget-form.xsd</code> */ public static class ResetField extends FieldInfo { @@ -3404,10 +3455,10 @@ public class ModelFormField { formStringRenderer.renderResetField(writer, context, this); } } - + /** * Models the <include-screen> element. - * + * * @see <code>widget-form.xsd</code> */ public static class ScreenField extends FieldInfo { @@ -3476,7 +3527,7 @@ public class ModelFormField { /** * Models the <option> element. - * + * * @see <code>widget-form.xsd</code> */ public static class SingleOption extends OptionSource { @@ -3523,7 +3574,7 @@ public class ModelFormField { /** * Models the <sub-hyperlink> element. - * + * * @see <code>widget-form.xsd</code> */ public static class SubHyperlink { @@ -3604,7 +3655,7 @@ public class ModelFormField { public Map<String, String> getParameterMap(Map<String, Object> context, String defaultEntityName, String defaultServiceName) { return link.getParameterMap(context, defaultEntityName, defaultServiceName); } - + public Map<String, String> getParameterMap(Map<String, Object> context) { return link.getParameterMap(context); } @@ -3717,7 +3768,9 @@ public class ModelFormField { public boolean shouldIgnore(Map<String, Object> context) { boolean shouldIgnore = true; String ignoreWhen = this.getIgnoreWhen(context); - if (UtilValidate.isEmpty(ignoreWhen)) return false; + if (UtilValidate.isEmpty(ignoreWhen)) { + return false; + } try { Object retVal = GroovyUtil.eval(StringUtil.convertOperatorSubstitutions(ignoreWhen),context); @@ -3740,7 +3793,7 @@ public class ModelFormField { /** * Models the <submit> element. - * + * * @see <code>widget-form.xsd</code> */ public static class SubmitField extends FieldInfo { @@ -3806,9 +3859,9 @@ public class ModelFormField { public String getConfirmation(Map<String, Object> context) { String message = getConfirmationMsg(context); - if (UtilValidate.isNotEmpty(message)) + if (UtilValidate.isNotEmpty(message)) { return message; - else if (getRequestConfirmation()) { + } else if (getRequestConfirmation()) { String defaultMessage = UtilProperties.getPropertyValue("general", "default.confirmation.message", "${uiLabelMap.CommonConfirm}"); return FlexibleStringExpander.expandString(defaultMessage, context); @@ -3845,7 +3898,7 @@ public class ModelFormField { /** * Models the <textarea> element. - * + * * @see <code>widget-form.xsd</code> */ public static class TextareaField extends FieldInfo { @@ -3980,7 +4033,7 @@ public class ModelFormField { /** * Models the <text> element. - * + * * @see <code>widget-form.xsd</code> */ public static class TextField extends FieldInfo { @@ -4041,10 +4094,10 @@ public class ModelFormField { this.maxlength = maxlength; this.placeholder = FlexibleStringExpander.getInstance(""); this.readonly = false; - this.size = size; + this.size = size; this.subHyperlink = null; } - + protected TextField(int fieldSource, int size, Integer maxlength, ModelFormField modelFormField) { super(fieldSource, FieldInfo.TEXT, modelFormField); this.clientAutocompleteField = true; @@ -4162,7 +4215,7 @@ public class ModelFormField { /** * Models the <text-find> element. - * + * * @see <code>widget-form.xsd</code> */ public static class TextFindField extends TextField { |
Free forum by Nabble | Edit this page |