Author: erwan
Date: Sat Jun 26 14:06:39 2010 New Revision: 958228 URL: http://svn.apache.org/viewvc?rev=958228&view=rev Log: Allowing parameters in on-event-update-area via parameter child element Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=958228&r1=958227&r2=958228&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Jun 26 14:06:39 2010 @@ -371,6 +371,9 @@ under the License. <xs:documentation>Area to be updated when a form event occurs.</xs:documentation> </xs:annotation> <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter"/> + </xs:sequence> <xs:attributeGroup ref="attlist.on-form-event-update-area"/> </xs:complexType> </xs:element> 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=958228&r1=958227&r2=958228&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Sat Jun 26 14:06:39 2010 @@ -2795,6 +2795,7 @@ public class MacroFormRenderer implement } else { ajaxUrl += ","; } + Map<String, String> parameters = updateArea.getParameterMap((Map<String, Object>) context); String targetUrl = updateArea.getAreaTarget(context); String ajaxParams = getAjaxParamsFromTarget(targetUrl); if (UtilValidate.isNotEmpty(extraParams)) { @@ -2803,6 +2804,17 @@ public class MacroFormRenderer implement } ajaxParams += extraParams; } + if(UtilValidate.isNotEmpty(parameters)){ + if(UtilValidate.isEmpty(ajaxParams)){ + ajaxParams = ""; + } + for (String key : parameters.keySet()) { + if (ajaxParams.length()>0){ + ajaxParams += "&"; + } + ajaxParams += key + "=" + parameters.get(key); + } + } ajaxUrl += updateArea.getAreaId() + ","; ajaxUrl += this.rh.makeLink(this.request, this.response, UtilHttp.removeQueryStringFromTarget(targetUrl)); ajaxUrl += "," + ajaxParams; 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=958228&r1=958227&r2=958228&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 Sat Jun 26 14:06:39 2010 @@ -2727,6 +2727,7 @@ public class ModelForm extends ModelWidg protected String eventType; protected String areaId; protected String areaTarget; + List<WidgetWorker.Parameter> parameterList =FastList.newInstance(); /** XML constructor. * @param updateAreaElement The <code><on-xxx-update-area></code> * XML element. @@ -2735,6 +2736,10 @@ public class ModelForm extends ModelWidg this.eventType = updateAreaElement.getAttribute("event-type"); this.areaId = updateAreaElement.getAttribute("area-id"); this.areaTarget = updateAreaElement.getAttribute("area-target"); + List<? extends Element> parameterElementList = UtilXml.childElementList(updateAreaElement, "parameter"); + for (Element parameterElement: parameterElementList) { + this.parameterList.add(new WidgetWorker.Parameter(parameterElement)); + } } /** String constructor. * @param areaId The id of the widget element to be updated @@ -2762,6 +2767,14 @@ public class ModelForm extends ModelWidg public String getAreaTarget(Map<String, ? extends Object> context) { return FlexibleStringExpander.expandString(areaTarget, context); } + public Map<String, String> getParameterMap(Map<String, Object> context) { + Map<String, String> fullParameterMap = FastMap.newInstance(); + for (WidgetWorker.Parameter parameter: this.parameterList) { + fullParameterMap.put(parameter.getName(), parameter.getValue(context)); + } + + return fullParameterMap; + } } public static class AutoFieldsService { |
Free forum by Nabble | Edit this page |