You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ap...@apache.org on 2009/08/06 08:50:28 UTC
svn commit: r801518 - in /ofbiz/trunk:
applications/accounting/widget/ap/InvoiceScreens.xml
framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
framework/widget/templates/htmlFormMacroLibrary.ftl
Author: apatel
Date: Thu Aug 6 06:50:27 2009
New Revision: 801518
URL: http://svn.apache.org/viewvc?rev=801518&view=rev
Log:
Fix multi select option in form widget.
Modified:
ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
Modified: ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml?rev=801518&r1=801517&r2=801518&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml Thu Aug 6 06:50:27 2009
@@ -159,7 +159,6 @@
<set field="tabButtonItem" value="commissionRun"/>
<set field="parties" type="List" from-field="parameters.partyIds"/>
<script location="component://accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy"/>
- <set field="parameters.partyIds" value=""/>
</actions>
<widgets>
<decorator-screen name="CommonApInvoiceDecorator" location="component://accounting/widget/ap/CommonScreens.xml">
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=801518&r1=801517&r2=801518&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 Thu Aug 6 06:50:27 2009
@@ -703,6 +703,16 @@
allowEmpty = " ";
}
+ List<String> currentValueList = null;
+ if (UtilValidate.isNotEmpty(currentValue) && dropDownField.isAllowMultiple()) {
+ // If currentValue is Array, it will start with [
+ if (currentValue.startsWith("[")) {
+ currentValueList = StringUtil.toList(currentValue);
+ }
+ else {
+ currentValueList = UtilMisc.toList(currentValue);
+ }
+ }
options.append("[");
Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator();
int count = 0;
@@ -721,6 +731,17 @@
} else {
options.append(optionValue.getDescription());
}
+
+ if (UtilValidate.isNotEmpty(currentValueList)) {
+ options.append("'");
+ options.append(",'selected':'");
+ if (currentValueList.contains(optionValue.getKey())) {
+ options.append("selected");
+ } else {
+ options.append("");
+ }
+ }
+
options.append("'}");
if (ajaxEnabled) {
count++;
Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=801518&r1=801517&r2=801518&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Thu Aug 6 06:50:27 2009
@@ -126,7 +126,7 @@
<script language="JavaScript" type="text/javascript">var data = {${ajaxOptions}};ajaxAutoCompleteDropDown('<#if id?has_content>${id}_description</#if>','${id}',data,{autoSelect:${autoSelect},frequency:${frequency},minChars:${minChars},choices:${choices},partialSearch:${partialSearch},partialChars:${partialChars},ignoreCase:${ignoreCase},fullSearch:${fullSearch});</script>
<#else>
" <@renderClass className alert /><#if id?has_content> id="${id}"</#if><#if multiple?has_content> multiple="multiple"</#if><#if otherFieldSize gt 0> onchange="process_choice(this,document.${formName}.${otherFieldName})"</#if><#if event?has_content> ${event}="${action}"</#if><#if size?has_content> size="${size}"</#if>>
-<#if firstInList?has_content && currentValue?has_content>
+<#if firstInList?has_content && currentValue?has_content && !multiple?has_content>
<option selected="selected" value="${currentValue}">${explicitDescription}</option><#rt/>
<option value="${currentValue}">---</option><#rt/>
</#if>
@@ -134,7 +134,11 @@
<option value=""> </option>
</#if>
<#list options as item>
-<option<#if currentValue?has_content && currentValue == item.key && dDFCurrent?has_content && "selected" == dDFCurrent> selected="selected"<#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected="selected"</#if> value="${item.key}">${item.description}</option><#rt/>
+<#if multiple?has_content>
+ <option<#if currentValue?has_content && item.selected?has_content> selected="${item.selected}" <#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected="selected" </#if> value="${item.key}">${item.description}</option><#rt/>
+<#else>
+ <option<#if currentValue?has_content && currentValue == item.key && dDFCurrent?has_content && "selected" == dDFCurrent> selected="selected"<#elseif !currentValue?has_content && noCurrentSelectedKey?has_content && noCurrentSelectedKey == item.key> selected="selected"</#if> value="${item.key}">${item.description}</option><#rt/>
+</#if>
</#list>
</select>
<#if otherFieldName?has_content>
@@ -466,4 +470,4 @@
</#macro>
<#macro makeHiddenFormLinkForm actionUrl name parameters targetWindow><form method="post" action="${actionUrl}" <#if targetWindow?has_content>target="${targetWindow}"</#if> onSubmit="javascript:submitFormDisableSubmits(this)" name="${name}"><#list parameters as parameter><input name="${parameter.name}" value="${parameter.value}" type="hidden"/></#list></form></#macro>
<#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><a <#if linkStyle?has_content>class="${linkStyle}"</#if> href="javascript:document.${hiddenFormName}.submit()"<#if action?has_content && event?has_content> ${event}="${action}"</#if>><#if imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></#macro>
-<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc linkUrl targetWindow description><a <#if linkStyle?has_content>class="${linkStyle}"</#if> href="${linkUrl}"<#if targetWindow?has_content> target="${targetWindow}"</#if><#if action?has_content && event?has_content> ${event}="${action}"</#if>><#if imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></#macro>
\ No newline at end of file
+<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc linkUrl targetWindow description><a <#if linkStyle?has_content>class="${linkStyle}"</#if> href="${linkUrl}"<#if targetWindow?has_content> target="${targetWindow}"</#if><#if action?has_content && event?has_content> ${event}="${action}"</#if>><#if imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></#macro>