Return-Path: Delivered-To: apmail-ofbiz-commits-archive@www.apache.org Received: (qmail 21044 invoked from network); 16 Feb 2010 16:42:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Feb 2010 16:42:25 -0000 Received: (qmail 4029 invoked by uid 500); 16 Feb 2010 16:42:25 -0000 Delivered-To: apmail-ofbiz-commits-archive@ofbiz.apache.org Received: (qmail 3977 invoked by uid 500); 16 Feb 2010 16:42:24 -0000 Mailing-List: contact commits-help@ofbiz.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ofbiz.apache.org Delivered-To: mailing list commits@ofbiz.apache.org Received: (qmail 3967 invoked by uid 99); 16 Feb 2010 16:42:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2010 16:42:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2010 16:42:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D78322388962; Tue, 16 Feb 2010 16:42:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r910587 - in /ofbiz/trunk/framework: common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy example/widget/example/FormWidgetExampleLookupScreens.xml Date: Tue, 16 Feb 2010 16:42:00 -0000 To: commits@ofbiz.apache.org From: erwan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100216164200.D78322388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: erwan Date: Tue Feb 16 16:42:00 2010 New Revision: 910587 URL: http://svn.apache.org/viewvc?rev=910587&view=rev Log: The auto-completer (in lookup fields) default behavior is "%fieldValue%" (contains operation). This allows to change the behavior to "fieldValue%"(statrWith operation) when setting to "Y" the searchTypeStartWith field Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy ofbiz/trunk/framework/example/widget/example/FormWidgetExampleLookupScreens.xml Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy?rev=910587&r1=910586&r2=910587&view=diff ============================================================================== --- ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy (original) +++ ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy Tue Feb 16 16:42:00 2010 @@ -32,7 +32,10 @@ displayFields = context.displayFields ?: searchFields; searchValueFieldName = parameters.searchValueField; fieldValue = parameters.get(searchValueFieldName); - +searchTypeStartWith = context.searchTypeStartWith; +if( searchTypeStartWith == null){ + searchTypeStartWith = "N"; +} if (searchFields && fieldValue) { searchFieldsList = StringUtil.toList(searchFields); displayFieldsSet = StringUtil.toSet(displayFields); @@ -40,20 +43,26 @@ displayFieldsSet.add(returnField); //add it to select fields, in case it is missing context.returnField = returnField; context.displayFieldsSet = displayFieldsSet; - searchFieldsList.each { fieldName -> - andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue(fieldName)), EntityOperator.LIKE, "%" + fieldValue.toUpperCase() + "%")); + if("Y".equals(searchTypeStartWith.toUpperCase())){ + searchValue = fieldValue.toUpperCase() + "%"; + } + else{ + searchValue = "%" + fieldValue.toUpperCase() + "%"; + } + searchFieldsList.each { fieldName -> + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue(fieldName)), EntityOperator.LIKE, searchValue)); } } - +System.out.println(andExprs); if (andExprs && entityName && displayFieldsSet) { entityConditionList = EntityCondition.makeCondition(andExprs, EntityOperator.OR); - - //if there is an extra condition, add it to main condition + + //if there is an extra condition, add it to main condition if (context.andCondition && context.andCondition instanceof EntityCondition) { entityConditionList = EntityCondition.makeCondition(context.andCondition, entityConditionList); } - - Integer autocompleterViewSize = Integer.valueOf(context.autocompleterViewSize ?: 10); + + Integer autocompleterViewSize = Integer.valueOf(context.autocompleterViewSize ?: 10); EntityFindOptions findOptions = new EntityFindOptions(); findOptions.setMaxRows(autocompleterViewSize); autocompleteOptions = delegator.findList(entityName, entityConditionList, displayFieldsSet, StringUtil.toList(displayFields), findOptions, false); Modified: ofbiz/trunk/framework/example/widget/example/FormWidgetExampleLookupScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/FormWidgetExampleLookupScreens.xml?rev=910587&r1=910586&r2=910587&view=diff ============================================================================== --- ofbiz/trunk/framework/example/widget/example/FormWidgetExampleLookupScreens.xml (original) +++ ofbiz/trunk/framework/example/widget/example/FormWidgetExampleLookupScreens.xml Tue Feb 16 16:42:00 2010 @@ -41,6 +41,10 @@ + + + + @@ -106,24 +110,24 @@ - + - + - + - + - + - + @@ -136,6 +140,6 @@ - - + + \ No newline at end of file