Hi Adrian,
I may be totally wrong (sorry but I don't have time to look at the details now) but we should pay attention to add dependencies to the WidgetWorker class: that class contains a lot of bad code (html dependent code) and I would prefer to see it cleaned up before its use is even increased. Kind regards, Jacopo On May 19, 2010, at 7:38 PM, [hidden email] wrote: > Author: adrianc > Date: Wed May 19 17:38:08 2010 > New Revision: 946298 > > URL: http://svn.apache.org/viewvc?rev=946298&view=rev > Log: > Moved 4 methods from ModelWidget to WidgetWorker and made them static. ModelWidget is supposed to be nothing more than a super class for the model widget classes, but it was starting to look like a "catch-all" or utility class. > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java > > 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=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Wed May 19 17:38:08 2010 > @@ -23,9 +23,6 @@ import java.util.Map; > import org.w3c.dom.Element; > import org.ofbiz.base.util.UtilGenerics; > import org.ofbiz.base.util.UtilProperties; > -import org.ofbiz.base.util.UtilValidate; > -import org.ofbiz.entity.Delegator; > -import org.ofbiz.service.LocalDispatcher; > > /** > * Widget Library - Widget model class. ModelWidget is a base class that is > @@ -119,43 +116,4 @@ public class ModelWidget implements Seri > } > return result; > } > - > - public int getPaginatorNumber(Map<String, Object> context) { > - int paginator_number = 0; > - Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); > - if (globalCtx != null) { > - Integer paginateNumberInt= (Integer)globalCtx.get("PAGINATOR_NUMBER"); > - if (paginateNumberInt == null) { > - paginateNumberInt = Integer.valueOf(0); > - globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt); > - } > - paginator_number = paginateNumberInt.intValue(); > - } > - return paginator_number; > - } > - > - public void incrementPaginatorNumber(Map<String, Object> context) { > - Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); > - if (globalCtx != null) { > - Boolean NO_PAGINATOR = (Boolean) globalCtx.get("NO_PAGINATOR"); > - if (UtilValidate.isNotEmpty(NO_PAGINATOR)) { > - globalCtx.remove("NO_PAGINATOR"); > - } else { > - Integer paginateNumberInt = Integer.valueOf(getPaginatorNumber(context) + 1); > - globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt); > - } > - } > - } > - > - public LocalDispatcher getDispatcher(Map<String, Object> context) { > - LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher"); > - return dispatcher; > - } > - > - public Delegator getDelegator(Map<String, Object> context) { > - Delegator delegator = (Delegator) context.get("delegator"); > - return delegator; > - } > - > - > } > > 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=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Wed May 19 17:38:08 2010 > @@ -22,7 +22,6 @@ import java.io.IOException; > import java.io.StringWriter; > import java.math.BigDecimal; > import java.text.DateFormat; > -import java.util.List; > import java.util.Map; > import java.util.TimeZone; > > @@ -30,7 +29,6 @@ import javax.servlet.ServletContext; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > -import org.ofbiz.base.util.Debug; > import org.ofbiz.base.util.StringUtil; > import org.ofbiz.base.util.UtilDateTime; > import org.ofbiz.base.util.UtilGenerics; > @@ -38,6 +36,8 @@ import org.ofbiz.base.util.UtilHttp; > import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.base.util.collections.FlexibleMapAccessor; > import org.ofbiz.base.util.string.FlexibleStringExpander; > +import org.ofbiz.entity.Delegator; > +import org.ofbiz.service.LocalDispatcher; > import org.ofbiz.webapp.control.ConfigXMLReader; > import org.ofbiz.webapp.control.RequestHandler; > import org.ofbiz.webapp.taglib.ContentUrlTag; > @@ -405,4 +405,40 @@ public class WidgetWorker { > return combinedName.substring(pos + 1); > } > > + public static int getPaginatorNumber(Map<String, Object> context) { > + int paginator_number = 0; > + Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); > + if (globalCtx != null) { > + Integer paginateNumberInt= (Integer)globalCtx.get("PAGINATOR_NUMBER"); > + if (paginateNumberInt == null) { > + paginateNumberInt = Integer.valueOf(0); > + globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt); > + } > + paginator_number = paginateNumberInt.intValue(); > + } > + return paginator_number; > + } > + > + public static void incrementPaginatorNumber(Map<String, Object> context) { > + Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); > + if (globalCtx != null) { > + Boolean NO_PAGINATOR = (Boolean) globalCtx.get("NO_PAGINATOR"); > + if (UtilValidate.isNotEmpty(NO_PAGINATOR)) { > + globalCtx.remove("NO_PAGINATOR"); > + } else { > + Integer paginateNumberInt = Integer.valueOf(getPaginatorNumber(context) + 1); > + globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt); > + } > + } > + } > + > + public static LocalDispatcher getDispatcher(Map<String, Object> context) { > + LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher"); > + return dispatcher; > + } > + > + public static Delegator getDelegator(Map<String, Object> context) { > + Delegator delegator = (Delegator) context.get("delegator"); > + return delegator; > + } > } > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java Wed May 19 17:38:08 2010 > @@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRes > > import org.ofbiz.base.util.UtilFormatOut; > import org.ofbiz.base.util.UtilValidate; > +import org.ofbiz.widget.WidgetWorker; > import org.ofbiz.widget.form.FormStringRenderer; > import org.ofbiz.widget.form.ModelForm; > import org.ofbiz.widget.form.ModelFormField; > @@ -116,7 +117,7 @@ public class FoFormRenderer extends Html > ModelFormField modelFormField = dropDownField.getModelFormField(); > ModelForm modelForm = modelFormField.getModelForm(); > String currentValue = modelFormField.getEntry(context); > - List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > // if the current value should go first, display it > if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { > String explicitDescription = dropDownField.getCurrentDescription(context); > > 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=946298&r1=946297&r2=946298&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 Wed May 19 17:38:08 2010 > @@ -673,7 +673,7 @@ public class MacroFormRenderer implement > ModelFormField modelFormField = dropDownField.getModelFormField(); > ModelForm modelForm = modelFormField.getModelForm(); > String currentValue = modelFormField.getEntry(context); > - List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete(); > String event = modelFormField.getEvent(); > String action = modelFormField.getAction(context); > @@ -903,7 +903,7 @@ public class MacroFormRenderer implement > } > } > > - List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > items.append("["); > for (ModelFormField.OptionValue optionValue : allOptionValues) { > if (items.length() >1) { > @@ -947,7 +947,7 @@ public class MacroFormRenderer implement > public void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField) throws IOException { > ModelFormField modelFormField = radioField.getModelFormField(); > ModelForm modelForm = modelFormField.getModelForm(); > - List<ModelFormField.OptionValue> allOptionValues = radioField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = radioField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > String currentValue = modelFormField.getEntry(context); > String className = ""; > String alert = "false"; > @@ -1211,7 +1211,7 @@ public class MacroFormRenderer implement > > String displayHelpText = UtilProperties.getPropertyValue("widget.properties", "widget.form.displayhelpText"); > if ("Y".equals(displayHelpText)) { > - Delegator delegator = modelFormField.getModelForm().getDelegator(context); > + Delegator delegator = WidgetWorker.getDelegator(context); > Locale locale = (Locale)context.get("locale"); > String entityName = modelFormField.getEntityName(); > String fieldName = modelFormField.getFieldName(); > @@ -2123,7 +2123,7 @@ public class MacroFormRenderer implement > } > > // get the parameterized pagination index and size fields > - int paginatorNumber = modelForm.getPaginatorNumber(context); > + int paginatorNumber = WidgetWorker.getPaginatorNumber(context); > String viewIndexParam = modelForm.getMultiPaginateIndexField(context); > String viewSizeParam = modelForm.getMultiPaginateSizeField(context); > > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Wed May 19 17:38:08 2010 > @@ -59,6 +59,7 @@ import org.ofbiz.service.ModelParam; > import org.ofbiz.service.ModelService; > import org.ofbiz.webapp.control.ConfigXMLReader; > import org.ofbiz.widget.ModelWidget; > +import org.ofbiz.widget.WidgetWorker; > import org.w3c.dom.Element; > > import bsh.EvalError; > @@ -794,7 +795,7 @@ public class ModelForm extends ModelWidg > public void renderFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { > // increment the paginator, only for list and multi forms > if ("list".equals(this.type) || "multi".equals(this.type)) { > - this.incrementPaginatorNumber(context); > + WidgetWorker.incrementPaginatorNumber(context); > } > > //if pagination is disabled, update the defualt view size > @@ -2245,7 +2246,7 @@ public class ModelForm extends ModelWidg > field = DEFAULT_PAG_INDEX_FIELD; > } > // append the paginator number > - field = field + "_" + getPaginatorNumber(context); > + field = field + "_" + WidgetWorker.getPaginatorNumber(context); > return field; > } > > @@ -2260,7 +2261,7 @@ public class ModelForm extends ModelWidg > // try parameters.VIEW_INDEX as that is an old OFBiz convention > Map<String, Object> parameters = UtilGenerics.cast(context.get("parameters")); > if (parameters != null) { > - value = parameters.get("VIEW_INDEX" + "_" + getPaginatorNumber(context)); > + value = parameters.get("VIEW_INDEX" + "_" + WidgetWorker.getPaginatorNumber(context)); > > if (value == null) { > value = parameters.get(field); > @@ -2300,7 +2301,7 @@ public class ModelForm extends ModelWidg > field = DEFAULT_PAG_SIZE_FIELD; > } > // append the paginator number > - field = field + "_" + getPaginatorNumber(context); > + field = field + "_" + WidgetWorker.getPaginatorNumber(context); > return field; > } > > @@ -2315,7 +2316,7 @@ public class ModelForm extends ModelWidg > // try parameters.VIEW_SIZE as that is an old OFBiz convention > Map<String, Object> parameters = UtilGenerics.cast(context.get("parameters")); > if (parameters != null) { > - value = parameters.get("VIEW_SIZE" + "_" + getPaginatorNumber(context)); > + value = parameters.get("VIEW_SIZE" + "_" + WidgetWorker.getPaginatorNumber(context)); > > if (value == null) { > value = parameters.get(field); > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Wed May 19 17:38:08 2010 > @@ -357,7 +357,7 @@ public abstract class ModelFormAction { > try { > Map<String, Object> serviceContext = null; > if (autoFieldMapBool) { > - serviceContext = this.modelForm.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); > + serviceContext = WidgetWorker.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); > } else { > serviceContext = new HashMap<String, Object>(); > } > @@ -368,9 +368,9 @@ public abstract class ModelFormAction { > > Map<String, Object> result = null; > if (this.ignoreError) { > - result = this.modelForm.getDispatcher(context).runSync(serviceNameExpanded, serviceContext, -1, true); > + result = WidgetWorker.getDispatcher(context).runSync(serviceNameExpanded, serviceContext, -1, true); > } else { > - result = this.modelForm.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); > + result = WidgetWorker.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); > } > > if (!this.resultMapNameAcsr.isEmpty()) { > @@ -419,7 +419,7 @@ public abstract class ModelFormAction { > @Override > public void runAction(Map<String, Object> context) { > try { > - finder.runFind(context, this.modelForm.getDelegator(context)); > + finder.runFind(context, WidgetWorker.getDelegator(context)); > } catch (GeneralException e) { > String errMsg = "Error doing entity query by condition: " + e.toString(); > Debug.logError(e, errMsg, module); > @@ -457,7 +457,7 @@ public abstract class ModelFormAction { > public void runAction(Map<String, Object> context) { > try { > // don't want to do this: context.put("defaultFormResultList", null); > - finder.runFind(context, this.modelForm.getDelegator(context)); > + finder.runFind(context, WidgetWorker.getDelegator(context)); > Object obj = context.get(this.actualListName); > if (obj != null && ((obj instanceof List) || (obj instanceof EntityListIterator))) { > String modelFormListName = modelForm.getListName(); > @@ -501,7 +501,7 @@ public abstract class ModelFormAction { > public void runAction(Map<String, Object> context) { > try { > // don't want to do this: context.put("defaultFormResultList", null); > - finder.runFind(context, this.modelForm.getDelegator(context)); > + finder.runFind(context, WidgetWorker.getDelegator(context)); > Object obj = context.get(this.actualListName); > if (obj != null && ((obj instanceof List) || (obj instanceof EntityListIterator))) { > String modelFormListName = modelForm.getListName(); > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Wed May 19 17:38:08 2010 > @@ -2232,7 +2232,7 @@ public class ModelFormField { > if (UtilValidate.isEmpty(fieldKey)) { > fieldKey = this.modelFormField.fieldName; > } > - Delegator delegator = this.modelFormField.modelForm.getDelegator(context); > + Delegator delegator = WidgetWorker.getDelegator(context); > String fieldValue = modelFormField.getEntry(context); > try { > value = delegator.findOne(this.entityName, this.cache, fieldKey, fieldValue); > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Wed May 19 17:38:08 2010 > @@ -709,7 +709,7 @@ public class HtmlFormRenderer extends Ht > ModelForm modelForm = modelFormField.getModelForm(); > ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete(); > boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled; > - List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > > String event = modelFormField.getEvent(); > String action = modelFormField.getAction(context); > @@ -955,7 +955,7 @@ public class HtmlFormRenderer extends Ht > String currentValue = modelFormField.getEntry(context); > Boolean allChecked = checkField.isAllChecked(context); > > - List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > String event = modelFormField.getEvent(); > String action = modelFormField.getAction(context); > > @@ -1005,7 +1005,7 @@ public class HtmlFormRenderer extends Ht > public void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField) throws IOException { > ModelFormField modelFormField = radioField.getModelFormField(); > ModelForm modelForm = modelFormField.getModelForm(); > - List<ModelFormField.OptionValue> allOptionValues = radioField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = radioField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > String currentValue = modelFormField.getEntry(context); > String event = modelFormField.getEvent(); > String action = modelFormField.getAction(context); > @@ -2308,7 +2308,7 @@ public class HtmlFormRenderer extends Ht > } > > // get the parameterized pagination index and size fields > - int paginatorNumber = modelForm.getPaginatorNumber(context); > + int paginatorNumber = WidgetWorker.getPaginatorNumber(context); > String viewIndexParam = modelForm.getMultiPaginateIndexField(context); > String viewSizeParam = modelForm.getMultiPaginateSizeField(context); > > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Wed May 19 17:38:08 2010 > @@ -261,7 +261,7 @@ public class HtmlScreenRenderer extends > } > > // get the parametrized pagination index and size fields > - int paginatorNumber = modelForm.getPaginatorNumber(context); > + int paginatorNumber = WidgetWorker.getPaginatorNumber(context); > String viewIndexParam = modelForm.getMultiPaginateIndexField(context); > String viewSizeParam = modelForm.getMultiPaginateSizeField(context); > > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java Wed May 19 17:38:08 2010 > @@ -404,7 +404,7 @@ public abstract class ModelMenuAction { > try { > Map<String, Object> serviceContext = null; > if (autoFieldMapBool) { > - serviceContext = this.modelMenu.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); > + serviceContext = WidgetWorker.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); > } else { > serviceContext = FastMap.newInstance(); > } > @@ -417,7 +417,7 @@ public abstract class ModelMenuAction { > } > } > > - Map<String, Object> result = this.modelMenu.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); > + Map<String, Object> result = WidgetWorker.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); > > if (!this.resultMapNameAcsr.isEmpty()) { > this.resultMapNameAcsr.put(context, result); > @@ -443,7 +443,7 @@ public abstract class ModelMenuAction { > @Override > public void runAction(Map<String, Object> context) { > try { > - finder.runFind(context, this.modelMenu.getDelegator(context)); > + finder.runFind(context, WidgetWorker.getDelegator(context)); > } catch (GeneralException e) { > String errMsg = "Error doing entity query by condition: " + e.toString(); > Debug.logError(e, errMsg, module); > @@ -463,7 +463,7 @@ public abstract class ModelMenuAction { > @Override > public void runAction(Map<String, Object> context) { > try { > - finder.runFind(context, this.modelMenu.getDelegator(context)); > + finder.runFind(context, WidgetWorker.getDelegator(context)); > } catch (GeneralException e) { > String errMsg = "Error doing entity query by condition: " + e.toString(); > Debug.logError(e, errMsg, module); > @@ -483,7 +483,7 @@ public abstract class ModelMenuAction { > @Override > public void runAction(Map<String, Object> context) { > try { > - finder.runFind(context, this.modelMenu.getDelegator(context)); > + finder.runFind(context, WidgetWorker.getDelegator(context)); > } catch (GeneralException e) { > String errMsg = "Error doing entity query by condition: " + e.toString(); > Debug.logError(e, errMsg, module); > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java Wed May 19 17:38:08 2010 > @@ -406,7 +406,7 @@ public class ModelMenuItem { > List<GenericValue> portalPages = null; > String parentPortalPageId = this.getParentPortalPageId(context); > if (UtilValidate.isNotEmpty(parentPortalPageId)) { > - Delegator delegator = modelMenu.getDelegator(context); > + Delegator delegator = WidgetWorker.getDelegator(context); > try { > // first get public pages > EntityCondition cond = > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java Wed May 19 17:38:08 2010 > @@ -43,6 +43,7 @@ import org.ofbiz.base.util.collections.F > import org.ofbiz.base.util.collections.MapStack; > import org.ofbiz.base.util.string.FlexibleStringExpander; > import org.ofbiz.webapp.control.RequestHandler; > +import org.ofbiz.widget.WidgetWorker; > import org.w3c.dom.Element; > > > @@ -125,8 +126,8 @@ public class IterateSectionWidget extend > Debug.logError("Object not list or map type", module); > return; > } > - this.incrementPaginatorNumber(context); > - int startPageNumber = this.getPaginatorNumber(context); > + WidgetWorker.incrementPaginatorNumber(context); > + int startPageNumber = WidgetWorker.getPaginatorNumber(context); > getListLimits(context, theList); > int rowCount = 0; > Iterator<?> iter = theList.iterator(); > @@ -265,8 +266,8 @@ public class IterateSectionWidget extend > if (getPaginate(context)) { > try { > Map<String, String> params = UtilGenerics.cast(context.get("parameters")); > - String viewIndexString = params.get("VIEW_INDEX" + "_" + getPaginatorNumber(context)); > - String viewSizeString = params.get("VIEW_SIZE" + "_" + getPaginatorNumber(context)); > + String viewIndexString = params.get("VIEW_INDEX" + "_" + WidgetWorker.getPaginatorNumber(context)); > + String viewSizeString = params.get("VIEW_SIZE" + "_" + WidgetWorker.getPaginatorNumber(context)); > viewIndex = Integer.parseInt(viewIndexString); > viewSize = Integer.parseInt(viewSizeString); > } catch (Exception e) { > @@ -302,7 +303,7 @@ public class IterateSectionWidget extend > } > > String queryString = UtilHttp.urlEncodeArgs(inputFields); > - int paginatorNumber = this.getPaginatorNumber(context); > + int paginatorNumber = WidgetWorker.getPaginatorNumber(context); > queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber); > > > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Wed May 19 17:38:08 2010 > @@ -728,7 +728,7 @@ public class MacroScreenRenderer impleme > } > > // get the parametrized pagination index and size fields > - int paginatorNumber = modelForm.getPaginatorNumber(context); > + int paginatorNumber = WidgetWorker.getPaginatorNumber(context); > String viewIndexParam = modelForm.getMultiPaginateIndexField(context); > String viewSizeParam = modelForm.getMultiPaginateSizeField(context); > > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java Wed May 19 17:38:08 2010 > @@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletReq > import javax.servlet.http.HttpServletResponse; > > import org.ofbiz.base.util.UtilValidate; > +import org.ofbiz.widget.WidgetWorker; > import org.ofbiz.widget.form.FormStringRenderer; > import org.ofbiz.widget.form.ModelForm; > import org.ofbiz.widget.form.ModelFormField; > @@ -109,7 +110,7 @@ public class TextFormRenderer implements > ModelFormField modelFormField = dropDownField.getModelFormField(); > ModelForm modelForm = modelFormField.getModelForm(); > String currentValue = modelFormField.getEntry(context); > - List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > // if the current value should go first, display it > if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { > String explicitDescription = dropDownField.getCurrentDescription(context); > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java Wed May 19 17:38:08 2010 > @@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletReq > import javax.servlet.http.HttpServletResponse; > > import org.ofbiz.base.util.UtilValidate; > +import org.ofbiz.widget.WidgetWorker; > import org.ofbiz.widget.form.FormStringRenderer; > import org.ofbiz.widget.form.ModelForm; > import org.ofbiz.widget.form.ModelFormField; > @@ -114,7 +115,7 @@ public class XmlFormRenderer implements > ModelFormField modelFormField = dropDownField.getModelFormField(); > ModelForm modelForm = modelFormField.getModelForm(); > String currentValue = modelFormField.getEntry(context); > - List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context)); > + List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); > // if the current value should go first, display it > if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { > String explicitDescription = dropDownField.getCurrentDescription(context); > > |
Be my guest.
-Adrian --- On Wed, 5/19/10, Jacopo Cappellato <[hidden email]> wrote: > From: Jacopo Cappellato <[hidden email]> > Subject: Re: svn commit: r946298 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget: ./ fo/ form/ html/ menu/ screen/ text/ xml/ > To: [hidden email] > Date: Wednesday, May 19, 2010, 11:48 PM > Hi Adrian, > > I may be totally wrong (sorry but I don't have time to look > at the details now) but we should pay attention to add > dependencies to the WidgetWorker class: that class contains > a lot of bad code (html dependent code) and I would prefer > to see it cleaned up before its use is even increased. > > Kind regards, > > Jacopo > > On May 19, 2010, at 7:38 PM, [hidden email] > wrote: > > > Author: adrianc > > Date: Wed May 19 17:38:08 2010 > > New Revision: 946298 > > > > URL: http://svn.apache.org/viewvc?rev=946298&view=rev > > Log: > > Moved 4 methods from ModelWidget to WidgetWorker and > made them static. ModelWidget is supposed to be nothing more > than a super class for the model widget classes, but it was > starting to look like a "catch-all" or utility class. > > > > Modified: > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java > > > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java > > > > 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=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java > Wed May 19 17:38:08 2010 > > @@ -23,9 +23,6 @@ import java.util.Map; > > import org.w3c.dom.Element; > > import org.ofbiz.base.util.UtilGenerics; > > import org.ofbiz.base.util.UtilProperties; > > -import org.ofbiz.base.util.UtilValidate; > > -import org.ofbiz.entity.Delegator; > > -import org.ofbiz.service.LocalDispatcher; > > > > /** > > * Widget Library - Widget model class. > ModelWidget is a base class that is > > @@ -119,43 +116,4 @@ public class ModelWidget > implements Seri > > } > > return result; > > } > > - > > - public int > getPaginatorNumber(Map<String, Object> context) { > > - int paginator_number = > 0; > > - Map<String, Object> > globalCtx = > UtilGenerics.checkMap(context.get("globalContext")); > > - if (globalCtx != null) { > > - Integer > paginateNumberInt= > (Integer)globalCtx.get("PAGINATOR_NUMBER"); > > - if > (paginateNumberInt == null) { > > - > paginateNumberInt = Integer.valueOf(0); > > - > globalCtx.put("PAGINATOR_NUMBER", > paginateNumberInt); > > - } > > - > paginator_number = paginateNumberInt.intValue(); > > - } > > - return paginator_number; > > - } > > - > > - public void > incrementPaginatorNumber(Map<String, Object> context) > { > > - Map<String, Object> > globalCtx = > UtilGenerics.checkMap(context.get("globalContext")); > > - if (globalCtx != null) { > > - Boolean > NO_PAGINATOR = (Boolean) globalCtx.get("NO_PAGINATOR"); > > - if > (UtilValidate.isNotEmpty(NO_PAGINATOR)) { > > - > globalCtx.remove("NO_PAGINATOR"); > > - } else { > > - > Integer paginateNumberInt = > Integer.valueOf(getPaginatorNumber(context) + 1); > > - > globalCtx.put("PAGINATOR_NUMBER", > paginateNumberInt); > > - } > > - } > > - } > > - > > - public LocalDispatcher > getDispatcher(Map<String, Object> context) { > > - LocalDispatcher > dispatcher = (LocalDispatcher) context.get("dispatcher"); > > - return dispatcher; > > - } > > - > > - public Delegator > getDelegator(Map<String, Object> context) { > > - Delegator delegator = > (Delegator) context.get("delegator"); > > - return delegator; > > - } > > - > > - > > } > > > > 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=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java > Wed May 19 17:38:08 2010 > > @@ -22,7 +22,6 @@ import java.io.IOException; > > import java.io.StringWriter; > > import java.math.BigDecimal; > > import java.text.DateFormat; > > -import java.util.List; > > import java.util.Map; > > import java.util.TimeZone; > > > > @@ -30,7 +29,6 @@ import > javax.servlet.ServletContext; > > import javax.servlet.http.HttpServletRequest; > > import javax.servlet.http.HttpServletResponse; > > > > -import org.ofbiz.base.util.Debug; > > import org.ofbiz.base.util.StringUtil; > > import org.ofbiz.base.util.UtilDateTime; > > import org.ofbiz.base.util.UtilGenerics; > > @@ -38,6 +36,8 @@ import > org.ofbiz.base.util.UtilHttp; > > import org.ofbiz.base.util.UtilValidate; > > import > org.ofbiz.base.util.collections.FlexibleMapAccessor; > > import > org.ofbiz.base.util.string.FlexibleStringExpander; > > +import org.ofbiz.entity.Delegator; > > +import org.ofbiz.service.LocalDispatcher; > > import org.ofbiz.webapp.control.ConfigXMLReader; > > import org.ofbiz.webapp.control.RequestHandler; > > import org.ofbiz.webapp.taglib.ContentUrlTag; > > @@ -405,4 +405,40 @@ public class WidgetWorker { > > return > combinedName.substring(pos + 1); > > } > > > > + public static int > getPaginatorNumber(Map<String, Object> context) { > > + int paginator_number = > 0; > > + Map<String, Object> > globalCtx = > UtilGenerics.checkMap(context.get("globalContext")); > > + if (globalCtx != null) { > > + Integer > paginateNumberInt= > (Integer)globalCtx.get("PAGINATOR_NUMBER"); > > + if > (paginateNumberInt == null) { > > + > paginateNumberInt = Integer.valueOf(0); > > + > globalCtx.put("PAGINATOR_NUMBER", > paginateNumberInt); > > + } > > + > paginator_number = paginateNumberInt.intValue(); > > + } > > + return paginator_number; > > + } > > + > > + public static void > incrementPaginatorNumber(Map<String, Object> context) > { > > + Map<String, Object> > globalCtx = > UtilGenerics.checkMap(context.get("globalContext")); > > + if (globalCtx != null) { > > + Boolean > NO_PAGINATOR = (Boolean) globalCtx.get("NO_PAGINATOR"); > > + if > (UtilValidate.isNotEmpty(NO_PAGINATOR)) { > > + > globalCtx.remove("NO_PAGINATOR"); > > + } else { > > + > Integer paginateNumberInt = > Integer.valueOf(getPaginatorNumber(context) + 1); > > + > globalCtx.put("PAGINATOR_NUMBER", > paginateNumberInt); > > + } > > + } > > + } > > + > > + public static LocalDispatcher > getDispatcher(Map<String, Object> context) { > > + LocalDispatcher > dispatcher = (LocalDispatcher) context.get("dispatcher"); > > + return dispatcher; > > + } > > + > > + public static Delegator > getDelegator(Map<String, Object> context) { > > + Delegator delegator = > (Delegator) context.get("delegator"); > > + return delegator; > > + } > > } > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java > Wed May 19 17:38:08 2010 > > @@ -27,6 +27,7 @@ import > javax.servlet.http.HttpServletRes > > > > import org.ofbiz.base.util.UtilFormatOut; > > import org.ofbiz.base.util.UtilValidate; > > +import org.ofbiz.widget.WidgetWorker; > > import org.ofbiz.widget.form.FormStringRenderer; > > import org.ofbiz.widget.form.ModelForm; > > import org.ofbiz.widget.form.ModelFormField; > > @@ -116,7 +117,7 @@ public class FoFormRenderer > extends Html > > ModelFormField > modelFormField = dropDownField.getModelFormField(); > > ModelForm > modelForm = modelFormField.getModelForm(); > > String > currentValue = modelFormField.getEntry(context); > > - > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > // if the > current value should go first, display it > > if > (UtilValidate.isNotEmpty(currentValue) && > "first-in-list".equals(dropDownField.getCurrent())) { > > > String explicitDescription = > dropDownField.getCurrentDescription(context); > > > > 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=946298&r1=946297&r2=946298&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 > Wed May 19 17:38:08 2010 > > @@ -673,7 +673,7 @@ public class MacroFormRenderer > implement > > ModelFormField > modelFormField = dropDownField.getModelFormField(); > > ModelForm > modelForm = modelFormField.getModelForm(); > > String > currentValue = modelFormField.getEntry(context); > > - > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > > ModelFormField.AutoComplete autoComplete = > dropDownField.getAutoComplete(); > > String event = > modelFormField.getEvent(); > > String action = > modelFormField.getAction(context); > > @@ -903,7 +903,7 @@ public class MacroFormRenderer > implement > > } > > } > > > > - > List<ModelFormField.OptionValue> allOptionValues = > checkField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > checkField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > > items.append("["); > > for > (ModelFormField.OptionValue optionValue : allOptionValues) > { > > if > (items.length() >1) { > > @@ -947,7 +947,7 @@ public class MacroFormRenderer > implement > > public void > renderRadioField(Appendable writer, Map<String, > Object> context, RadioField radioField) throws > IOException { > > ModelFormField > modelFormField = radioField.getModelFormField(); > > ModelForm > modelForm = modelFormField.getModelForm(); > > - > List<ModelFormField.OptionValue> allOptionValues = > radioField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > radioField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > String > currentValue = modelFormField.getEntry(context); > > String className > = ""; > > String alert = > "false"; > > @@ -1211,7 +1211,7 @@ public class MacroFormRenderer > implement > > > > > String displayHelpText = > UtilProperties.getPropertyValue("widget.properties", > "widget.form.displayhelpText"); > > if > ("Y".equals(displayHelpText)) { > > - > Delegator delegator = > modelFormField.getModelForm().getDelegator(context); > > + > Delegator delegator = > WidgetWorker.getDelegator(context); > > > Locale locale = > (Locale)context.get("locale"); > > > String entityName = > modelFormField.getEntityName(); > > > String fieldName = > modelFormField.getFieldName(); > > @@ -2123,7 +2123,7 @@ public class MacroFormRenderer > implement > > } > > > > // get the > parameterized pagination index and size fields > > - int paginatorNumber = > modelForm.getPaginatorNumber(context); > > + int paginatorNumber = > WidgetWorker.getPaginatorNumber(context); > > String > viewIndexParam = > modelForm.getMultiPaginateIndexField(context); > > String > viewSizeParam = > modelForm.getMultiPaginateSizeField(context); > > > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java > Wed May 19 17:38:08 2010 > > @@ -59,6 +59,7 @@ import > org.ofbiz.service.ModelParam; > > import org.ofbiz.service.ModelService; > > import org.ofbiz.webapp.control.ConfigXMLReader; > > import org.ofbiz.widget.ModelWidget; > > +import org.ofbiz.widget.WidgetWorker; > > import org.w3c.dom.Element; > > > > import bsh.EvalError; > > @@ -794,7 +795,7 @@ public class ModelForm extends > ModelWidg > > public void > renderFormString(Appendable writer, Map<String, > Object> context, FormStringRenderer formStringRenderer) > throws IOException { > > // > increment the paginator, only for list and multi forms > > if > ("list".equals(this.type) || "multi".equals(this.type)) { > > - > this.incrementPaginatorNumber(context); > > + > WidgetWorker.incrementPaginatorNumber(context); > > } > > > > //if pagination > is disabled, update the defualt view size > > @@ -2245,7 +2246,7 @@ public class ModelForm extends > ModelWidg > > > field = DEFAULT_PAG_INDEX_FIELD; > > } > > // append > the paginator number > > - field = field + "_" + > getPaginatorNumber(context); > > + field = field + "_" + > WidgetWorker.getPaginatorNumber(context); > > return field; > > } > > > > @@ -2260,7 +2261,7 @@ public class ModelForm extends > ModelWidg > > > // try parameters.VIEW_INDEX as that is an > old OFBiz convention > > > Map<String, Object> parameters = > UtilGenerics.cast(context.get("parameters")); > > > if (parameters != null) { > > - > value = parameters.get("VIEW_INDEX" + > "_" + getPaginatorNumber(context)); > > + > value = parameters.get("VIEW_INDEX" + > "_" + WidgetWorker.getPaginatorNumber(context)); > > > > > if (value == null) { > > > value = > parameters.get(field); > > @@ -2300,7 +2301,7 @@ public class ModelForm extends > ModelWidg > > > field = DEFAULT_PAG_SIZE_FIELD; > > } > > // append > the paginator number > > - field = field + "_" + > getPaginatorNumber(context); > > + field = field + "_" + > WidgetWorker.getPaginatorNumber(context); > > return field; > > } > > > > @@ -2315,7 +2316,7 @@ public class ModelForm extends > ModelWidg > > > // try parameters.VIEW_SIZE as that is an > old OFBiz convention > > > Map<String, Object> parameters = > UtilGenerics.cast(context.get("parameters")); > > > if (parameters != null) { > > - > value = parameters.get("VIEW_SIZE" + > "_" + getPaginatorNumber(context)); > > + > value = parameters.get("VIEW_SIZE" + > "_" + WidgetWorker.getPaginatorNumber(context)); > > > > > if (value == null) { > > > value = > parameters.get(field); > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java > Wed May 19 17:38:08 2010 > > @@ -357,7 +357,7 @@ public abstract class > ModelFormAction { > > > try { > > > Map<String, Object> serviceContext = > null; > > > if (autoFieldMapBool) { > > - > serviceContext = > this.modelForm.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, > ModelService.IN_PARAM, context); > > + > serviceContext = > WidgetWorker.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, > ModelService.IN_PARAM, context); > > > } else { > > > serviceContext = new > HashMap<String, Object>(); > > > } > > @@ -368,9 +368,9 @@ public abstract class > ModelFormAction { > > > > > Map<String, Object> result = null; > > > if (this.ignoreError) { > > - > result = > this.modelForm.getDispatcher(context).runSync(serviceNameExpanded, > serviceContext, -1, true); > > + > result = > WidgetWorker.getDispatcher(context).runSync(serviceNameExpanded, > serviceContext, -1, true); > > > } else { > > - > result = > this.modelForm.getDispatcher(context).runSync(serviceNameExpanded, > serviceContext); > > + > result = > WidgetWorker.getDispatcher(context).runSync(serviceNameExpanded, > serviceContext); > > > } > > > > > if (!this.resultMapNameAcsr.isEmpty()) { > > @@ -419,7 +419,7 @@ public abstract class > ModelFormAction { > > @Override > > public void > runAction(Map<String, Object> context) { > > > try { > > - > finder.runFind(context, > this.modelForm.getDelegator(context)); > > + > finder.runFind(context, > WidgetWorker.getDelegator(context)); > > } > catch (GeneralException e) { > > > String errMsg = "Error doing entity query > by condition: " + e.toString(); > > > Debug.logError(e, errMsg, module); > > @@ -457,7 +457,7 @@ public abstract class > ModelFormAction { > > public void > runAction(Map<String, Object> context) { > > > try { > > > // don't want to do this: > context.put("defaultFormResultList", null); > > - > finder.runFind(context, > this.modelForm.getDelegator(context)); > > + > finder.runFind(context, > WidgetWorker.getDelegator(context)); > > > Object obj = > context.get(this.actualListName); > > > if (obj != null && ((obj > instanceof List) || (obj instanceof EntityListIterator))) { > > > String modelFormListName = > modelForm.getListName(); > > @@ -501,7 +501,7 @@ public abstract class > ModelFormAction { > > public void > runAction(Map<String, Object> context) { > > > try { > > > // don't want to do this: > context.put("defaultFormResultList", null); > > - > finder.runFind(context, > this.modelForm.getDelegator(context)); > > + > finder.runFind(context, > WidgetWorker.getDelegator(context)); > > > Object obj = > context.get(this.actualListName); > > > if (obj != null && ((obj > instanceof List) || (obj instanceof EntityListIterator))) { > > > String modelFormListName = > modelForm.getListName(); > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java > Wed May 19 17:38:08 2010 > > @@ -2232,7 +2232,7 @@ public class ModelFormField { > > if > (UtilValidate.isEmpty(fieldKey)) { > > > fieldKey = this.modelFormField.fieldName; > > } > > - Delegator > delegator = > this.modelFormField.modelForm.getDelegator(context); > > + Delegator > delegator = WidgetWorker.getDelegator(context); > > > String fieldValue = > modelFormField.getEntry(context); > > > try { > > > value = delegator.findOne(this.entityName, > this.cache, fieldKey, fieldValue); > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java > Wed May 19 17:38:08 2010 > > @@ -709,7 +709,7 @@ public class HtmlFormRenderer > extends Ht > > ModelForm > modelForm = modelFormField.getModelForm(); > > > ModelFormField.AutoComplete autoComplete = > dropDownField.getAutoComplete(); > > boolean > ajaxEnabled = autoComplete != null && > this.javaScriptEnabled; > > - > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > > > String event = > modelFormField.getEvent(); > > String action = > modelFormField.getAction(context); > > @@ -955,7 +955,7 @@ public class HtmlFormRenderer > extends Ht > > String > currentValue = modelFormField.getEntry(context); > > Boolean > allChecked = checkField.isAllChecked(context); > > > > - > List<ModelFormField.OptionValue> allOptionValues = > checkField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > checkField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > String event = > modelFormField.getEvent(); > > String action = > modelFormField.getAction(context); > > > > @@ -1005,7 +1005,7 @@ public class HtmlFormRenderer > extends Ht > > public void > renderRadioField(Appendable writer, Map<String, > Object> context, RadioField radioField) throws > IOException { > > ModelFormField > modelFormField = radioField.getModelFormField(); > > ModelForm > modelForm = modelFormField.getModelForm(); > > - > List<ModelFormField.OptionValue> allOptionValues = > radioField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > radioField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > String > currentValue = modelFormField.getEntry(context); > > String event = > modelFormField.getEvent(); > > String action = > modelFormField.getAction(context); > > @@ -2308,7 +2308,7 @@ public class HtmlFormRenderer > extends Ht > > } > > > > // get the > parameterized pagination index and size fields > > - int paginatorNumber = > modelForm.getPaginatorNumber(context); > > + int paginatorNumber = > WidgetWorker.getPaginatorNumber(context); > > String > viewIndexParam = > modelForm.getMultiPaginateIndexField(context); > > String > viewSizeParam = > modelForm.getMultiPaginateSizeField(context); > > > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java > Wed May 19 17:38:08 2010 > > @@ -261,7 +261,7 @@ public class HtmlScreenRenderer > extends > > } > > > > // get the > parametrized pagination index and size fields > > - int paginatorNumber = > modelForm.getPaginatorNumber(context); > > + int paginatorNumber = > WidgetWorker.getPaginatorNumber(context); > > String > viewIndexParam = > modelForm.getMultiPaginateIndexField(context); > > String > viewSizeParam = > modelForm.getMultiPaginateSizeField(context); > > > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java > Wed May 19 17:38:08 2010 > > @@ -404,7 +404,7 @@ public abstract class > ModelMenuAction { > > > try { > > > Map<String, Object> serviceContext = > null; > > > if (autoFieldMapBool) { > > - > serviceContext = > this.modelMenu.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, > ModelService.IN_PARAM, context); > > + > serviceContext = > WidgetWorker.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, > ModelService.IN_PARAM, context); > > > } else { > > > serviceContext = > FastMap.newInstance(); > > > } > > @@ -417,7 +417,7 @@ public abstract class > ModelMenuAction { > > > } > > > } > > > > - > Map<String, Object> result = > this.modelMenu.getDispatcher(context).runSync(serviceNameExpanded, > serviceContext); > > + > Map<String, Object> result = > WidgetWorker.getDispatcher(context).runSync(serviceNameExpanded, > serviceContext); > > > > > if (!this.resultMapNameAcsr.isEmpty()) { > > > this.resultMapNameAcsr.put(context, > result); > > @@ -443,7 +443,7 @@ public abstract class > ModelMenuAction { > > @Override > > public void > runAction(Map<String, Object> context) { > > > try { > > - > finder.runFind(context, > this.modelMenu.getDelegator(context)); > > + > finder.runFind(context, > WidgetWorker.getDelegator(context)); > > } > catch (GeneralException e) { > > > String errMsg = "Error doing entity query > by condition: " + e.toString(); > > > Debug.logError(e, errMsg, module); > > @@ -463,7 +463,7 @@ public abstract class > ModelMenuAction { > > @Override > > public void > runAction(Map<String, Object> context) { > > > try { > > - > finder.runFind(context, > this.modelMenu.getDelegator(context)); > > + > finder.runFind(context, > WidgetWorker.getDelegator(context)); > > } > catch (GeneralException e) { > > > String errMsg = "Error doing entity query > by condition: " + e.toString(); > > > Debug.logError(e, errMsg, module); > > @@ -483,7 +483,7 @@ public abstract class > ModelMenuAction { > > @Override > > public void > runAction(Map<String, Object> context) { > > > try { > > - > finder.runFind(context, > this.modelMenu.getDelegator(context)); > > + > finder.runFind(context, > WidgetWorker.getDelegator(context)); > > } > catch (GeneralException e) { > > > String errMsg = "Error doing entity query > by condition: " + e.toString(); > > > Debug.logError(e, errMsg, module); > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java > Wed May 19 17:38:08 2010 > > @@ -406,7 +406,7 @@ public class ModelMenuItem { > > > List<GenericValue> portalPages = > null; > > String > parentPortalPageId = this.getParentPortalPageId(context); > > if > (UtilValidate.isNotEmpty(parentPortalPageId)) { > > - Delegator > delegator = modelMenu.getDelegator(context); > > + Delegator > delegator = WidgetWorker.getDelegator(context); > > > try { > > > // first get public pages > > > EntityCondition cond = > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java > Wed May 19 17:38:08 2010 > > @@ -43,6 +43,7 @@ import > org.ofbiz.base.util.collections.F > > import org.ofbiz.base.util.collections.MapStack; > > import > org.ofbiz.base.util.string.FlexibleStringExpander; > > import org.ofbiz.webapp.control.RequestHandler; > > +import org.ofbiz.widget.WidgetWorker; > > import org.w3c.dom.Element; > > > > > > @@ -125,8 +126,8 @@ public class IterateSectionWidget > extend > > > Debug.logError("Object not list or map > type", module); > > > return; > > } > > - > this.incrementPaginatorNumber(context); > > - int startPageNumber = > this.getPaginatorNumber(context); > > + > WidgetWorker.incrementPaginatorNumber(context); > > + int startPageNumber = > WidgetWorker.getPaginatorNumber(context); > > > getListLimits(context, theList); > > int rowCount = > 0; > > > Iterator<?> iter = > theList.iterator(); > > @@ -265,8 +266,8 @@ public class IterateSectionWidget > extend > > if > (getPaginate(context)) { > > > try { > > > Map<String, String> params = > UtilGenerics.cast(context.get("parameters")); > > - > String viewIndexString = params.get("VIEW_INDEX" + > "_" + getPaginatorNumber(context)); > > - > String viewSizeString = params.get("VIEW_SIZE" + "_" > + getPaginatorNumber(context)); > > + > String viewIndexString = params.get("VIEW_INDEX" + > "_" + WidgetWorker.getPaginatorNumber(context)); > > + > String viewSizeString = params.get("VIEW_SIZE" + "_" > + WidgetWorker.getPaginatorNumber(context)); > > > viewIndex = > Integer.parseInt(viewIndexString); > > > viewSize = > Integer.parseInt(viewSizeString); > > } > catch (Exception e) { > > @@ -302,7 +303,7 @@ public class IterateSectionWidget > extend > > } > > > > String > queryString = UtilHttp.urlEncodeArgs(inputFields); > > - int paginatorNumber = > this.getPaginatorNumber(context); > > + int paginatorNumber = > WidgetWorker.getPaginatorNumber(context); > > queryString = > UtilHttp.stripViewParamsFromQueryString(queryString, "" + > paginatorNumber); > > > > > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java > Wed May 19 17:38:08 2010 > > @@ -728,7 +728,7 @@ public class MacroScreenRenderer > impleme > > } > > > > // get the > parametrized pagination index and size fields > > - int paginatorNumber = > modelForm.getPaginatorNumber(context); > > + int paginatorNumber = > WidgetWorker.getPaginatorNumber(context); > > String > viewIndexParam = > modelForm.getMultiPaginateIndexField(context); > > String > viewSizeParam = > modelForm.getMultiPaginateSizeField(context); > > > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java > Wed May 19 17:38:08 2010 > > @@ -26,6 +26,7 @@ import > javax.servlet.http.HttpServletReq > > import javax.servlet.http.HttpServletResponse; > > > > import org.ofbiz.base.util.UtilValidate; > > +import org.ofbiz.widget.WidgetWorker; > > import org.ofbiz.widget.form.FormStringRenderer; > > import org.ofbiz.widget.form.ModelForm; > > import org.ofbiz.widget.form.ModelFormField; > > @@ -109,7 +110,7 @@ public class TextFormRenderer > implements > > ModelFormField > modelFormField = dropDownField.getModelFormField(); > > ModelForm > modelForm = modelFormField.getModelForm(); > > String > currentValue = modelFormField.getEntry(context); > > - > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > // if the > current value should go first, display it > > if > (UtilValidate.isNotEmpty(currentValue) && > "first-in-list".equals(dropDownField.getCurrent())) { > > > String explicitDescription = > dropDownField.getCurrentDescription(context); > > > > Modified: > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java?rev=946298&r1=946297&r2=946298&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java > (original) > > +++ > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java > Wed May 19 17:38:08 2010 > > @@ -26,6 +26,7 @@ import > javax.servlet.http.HttpServletReq > > import javax.servlet.http.HttpServletResponse; > > > > import org.ofbiz.base.util.UtilValidate; > > +import org.ofbiz.widget.WidgetWorker; > > import org.ofbiz.widget.form.FormStringRenderer; > > import org.ofbiz.widget.form.ModelForm; > > import org.ofbiz.widget.form.ModelFormField; > > @@ -114,7 +115,7 @@ public class XmlFormRenderer > implements > > ModelFormField > modelFormField = dropDownField.getModelFormField(); > > ModelForm > modelForm = modelFormField.getModelForm(); > > String > currentValue = modelFormField.getEntry(context); > > - > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > modelForm.getDelegator(context)); > > + > List<ModelFormField.OptionValue> allOptionValues = > dropDownField.getAllOptionValues(context, > WidgetWorker.getDelegator(context)); > > // if the > current value should go first, display it > > if > (UtilValidate.isNotEmpty(currentValue) && > "first-in-list".equals(dropDownField.getCurrent())) { > > > String explicitDescription = > dropDownField.getCurrentDescription(context); > > > > > > |
Free forum by Nabble | Edit this page |