You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2008/05/23 12:10:49 UTC
svn commit: r659488 - in /ofbiz/trunk/framework: common/webcommon/WEB-INF/
common/webcommon/WEB-INF/actions/
common/webcommon/WEB-INF/actions/includes/ common/webcommon/includes/
common/widget/ example/webapp/example/WEB-INF/ example/webapp/example/WEB...
Author: jacopoc
Date: Fri May 23 03:10:48 2008
New Revision: 659488
URL: http://svn.apache.org/viewvc?rev=659488&view=rev
Log:
Continued work done by Anil Patel about implementation of Ajax.Autocompleter enhancement for form widget text box.
There is now a generic screen (and controller entries) that can be used by Ajax autocompleter fields.
See the example in the example component.
Added:
ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/
ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/
ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh (with props)
ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl (with props)
Removed:
ofbiz/trunk/framework/example/webapp/example/WEB-INF/actions/
ofbiz/trunk/framework/example/webapp/example/includes/
Modified:
ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml
ofbiz/trunk/framework/common/widget/CommonScreens.xml
ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml
ofbiz/trunk/framework/example/widget/example/ExampleForms.xml
ofbiz/trunk/framework/images/webapp/images/selectall.js
Added: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh?rev=659488&view=auto
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh (added)
+++ ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh Fri May 23 03:10:48 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.TreeSet;
+import javolution.util.FastList;
+import org.ofbiz.entity.condition.EntityConditionList;
+import org.ofbiz.entity.condition.EntityExpr;
+import org.ofbiz.entity.condition.EntityFieldValue;
+import org.ofbiz.entity.condition.EntityFunction;
+import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilValidate;
+
+andExprs = FastList.newInstance();
+fieldValue = request.getParameter(fieldName);
+if (UtilValidate.isNotEmpty(fieldValue)) {
+ andExprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue(fieldName)),
+ EntityOperator.LIKE, "%" + fieldValue.toUpperCase() + "%"));
+}
+
+if (andExprs.size() > 0) {
+ entityConditionList = new EntityConditionList(andExprs, EntityOperator.AND);
+ List autocompleteOptions = delegator.findList(entityName, entityConditionList, new TreeSet(StringUtil.toList(selectFields)), StringUtil.toList(sortByFields), null, false);
+ context.put("autocompleteOptions", autocompleteOptions);
+}
Propchange: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml?rev=659488&r1=659487&r2=659488&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml (original)
+++ ofbiz/trunk/framework/common/webcommon/WEB-INF/common-controller.xml Fri May 23 03:10:48 2008
@@ -101,6 +101,11 @@
<response name="error" type="request" value="main"/>
</request-map>
+ <request-map uri="ajaxAutocompleteOptions">
+ <security https="true" auth="true"/>
+ <response name="success" type="view" value="ajaxAutocompleteOptions" />
+ </request-map>
+
<!-- View Mappings -->
<view-map name="error" page="/error/error.jsp"/>
<view-map name="login" type="screen" page="component://common/widget/CommonScreens.xml#login"/>
@@ -109,4 +114,6 @@
<view-map name="LookupLocales" type="screen" page="component://common/widget/LookupScreens.xml#LookupLocales"/>
<view-map name="LookupTimezones" type="screen" page="component://common/widget/LookupScreens.xml#LookupTimezones"/>
+
+ <view-map name="ajaxAutocompleteOptions" type="screen" page="component://common/widget/CommonScreens.xml#ajaxAutocompleteOptions"/>
</site-conf>
Added: ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl?rev=659488&view=auto
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl (added)
+++ ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl Fri May 23 03:10:48 2008
@@ -0,0 +1,25 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<ul>
+ <#list autocompleteOptions as autocompleteOption>
+ <#assign fields = autocompleteOption.values()/>
+ <li><#list fields as field><#if field_index == 1><span class="informal"> </#if>${field}<#if (field_index > 0)><#if field_has_next> <#else></span></#if></#if></#list></li>
+ </#list>
+</ul>
\ No newline at end of file
Propchange: ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/framework/common/webcommon/includes/ajaxAutocompleteOptions.ftl
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/trunk/framework/common/widget/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/widget/CommonScreens.xml?rev=659488&r1=659487&r2=659488&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/widget/CommonScreens.xml (original)
+++ ofbiz/trunk/framework/common/widget/CommonScreens.xml Fri May 23 03:10:48 2008
@@ -87,6 +87,23 @@
</widgets>
</section>
</screen>
+ <!--
+ The following screen is used to generate Ajax list of options for autocomplete fields
+ -->
+ <screen name="ajaxAutocompleteOptions">
+ <section>
+ <actions>
+ <set field="entityName" from-field="parameters.entityName"/>
+ <set field="fieldName" from-field="parameters.fieldName"/>
+ <set field="selectFields" from-field="parameters.selectFields"/>
+ <set field="sortByFields" from-field="parameters.sortByFields"/>
+ <script location="component://common/webcommon/WEB-INF/actions/includes/findAutocompleteOptions.bsh"/>
+ </actions>
+ <widgets>
+ <platform-specific><html><html-template location="component://common/webcommon/includes/ajaxAutocompleteOptions.ftl"/></html></platform-specific>
+ </widgets>
+ </section>
+ </screen>
<!-- Global decorator for General Screens/Pages -->
<screen name="GlobalDecorator">
Modified: ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml?rev=659488&r1=659487&r2=659488&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml Fri May 23 03:10:48 2008
@@ -154,11 +154,6 @@
<response name="success" type="view" value="EditExampleFeatureExampleAppls"/>
<response name="error" type="view" value="EditExampleFeatureExampleAppls"/>
</request-map>
- <request-map uri="ExampleFeatureOptions">
- <security https="true" auth="true"/>
- <response name="success" type="view" value="ExampleFeatureOptions"/>
- <response name="error" type="view" value="ExampleFeatureOptions"/>
- </request-map>
<request-map uri="FormWidgetExamples"><security https="true" auth="true"/><response name="success" type="view" value="FormWidgetExamples"/></request-map>
@@ -183,7 +178,6 @@
<view-map name="FormWidgetExamples" type="screen" page="component://example/widget/example/FormWidgetExampleScreens.xml#FormWidgetExamples"/>
<view-map name="LookupExampleFeature" type="screen" page="component://example/widget/example/ExampleFeatureScreens.xml#LookupExampleFeature"/>
- <view-map name="ExampleFeatureOptions" type="screen" page="component://example/widget/example/ExampleFeatureScreens.xml#ExampleFeatureOptions"/>
<!-- ajax view mappings -->
<view-map name="findExampleAjax" type="screen" page="component://example/widget/example/ExampleAjaxScreens.xml#AjaxExample"/>
<view-map name="ListExampleFormOnly" type="screen" page="component://example/widget/example/ExampleAjaxScreens.xml#ListExampleFormOnly"/>
Modified: ofbiz/trunk/framework/example/widget/example/ExampleForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/ExampleForms.xml?rev=659488&r1=659487&r2=659488&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/widget/example/ExampleForms.xml (original)
+++ ofbiz/trunk/framework/example/widget/example/ExampleForms.xml Fri May 23 03:10:48 2008
@@ -173,8 +173,8 @@
<form name="AddExampleFeatureAppl" type="single" target="example_createExampleFeatureAppl" title="">
<auto-fields-service service-name="createExampleFeatureAppl"/>
<field name="exampleId"><hidden/></field>
- <field name="exampleFeatureId" id-name="exampleFeatureId"><text server-autocomplete-target="ExampleFeatureOptions"></text></field>
- <!-- <field name="exampleFeatureId" title="${uiLabelMap.ExampleFeature}" id-name="exampleFeatureId"><lookup target-form-name="LookupExampleFeature"/></field> -->
+ <field name="exampleFeatureId" id-name="exampleFeatureId"><text server-autocomplete-target="ajaxAutocompleteOptions" server-autocomplete-params="entityName=ExampleFeature&fieldName=exampleFeatureId&selectFields=[exampleFeatureId, description]&sortByFields=[-exampleFeatureId]"></text></field>
+ <!-- <field name="exampleFeatureId" title="${uiLabelMap.ExampleFeature}" id-name="exampleFeatureId"><lookup target-form-name="LookupExampleFeature"/></field> -->
<field name="exampleFeatureApplTypeId" title="${uiLabelMap.CommonType}">
<drop-down allow-empty="false">
<entity-options entity-name="ExampleFeatureApplType" description="${description}">
Modified: ofbiz/trunk/framework/images/webapp/images/selectall.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/selectall.js?rev=659488&r1=659487&r2=659488&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/selectall.js Fri May 23 03:10:48 2008
@@ -289,7 +289,7 @@
function ajaxAutoCompleter(textFieldId,url,params) {
var optionsDivId = textFieldId + "_autoCompleterOptions";
$(textFieldId ).insert({after: '<div class="autocomplete"' + 'id=' + optionsDivId + '></div>'});
- new Ajax.Autocompleter($(textFieldId), optionsDivId, url, params);
+ new Ajax.Autocompleter($(textFieldId), optionsDivId, url, {parameters: params});
}
// ===== End of Ajax Functions ===== //