You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2012/04/18 15:24:30 UTC
svn commit: r1327502 - in /ofbiz/trunk/framework: common/config/
common/webcommon/includes/ common/widget/ images/webapp/images/
Author: jleroux
Date: Wed Apr 18 13:24:30 2012
New Revision: 1327502
URL: http://svn.apache.org/viewvc?rev=1327502&view=rev
Log:
A modified patch from Wai "widget <image> tag to use css for resizing" https://issues.apache.org/jira/browse/OFBIZ-4678
1. autocomplete feature shows the message "no records found" during a session timeout. This could be misleading for the user.
2. During a session timeout, clicking on ajax dialog button shows a large frame containing a message indicating session has timeout. Should show a more detailed message.
jleroux: what I adapted:
* Added <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> in htmlheader-for-ajax.ftl
* Replaced also spinner.gif in Tomahawk (better be consistent)
* Added a French label an kept those existing but English (improved by Wai)
* Removed the ajaxErrorText style in ajaxNotLoggedIn screen
Added:
ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl (with props)
ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.ftl (with props)
Modified:
ofbiz/trunk/framework/common/config/CommonUiLabels.xml
ofbiz/trunk/framework/common/widget/CommonScreens.xml
ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
ofbiz/trunk/framework/images/webapp/images/selectall.js
ofbiz/trunk/framework/images/webapp/images/spinner.gif
Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.xml?rev=1327502&r1=1327501&r2=1327502&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/config/CommonUiLabels.xml (original)
+++ ofbiz/trunk/framework/common/config/CommonUiLabels.xml Wed Apr 18 13:24:30 2012
@@ -8324,9 +8324,10 @@
<value xml:lang="it">Servizio ha restituito un'errore: errore restituito</value>
</property>
<property key="CommonSessionTimeoutPleaseLogIn">
+ <value xml:lang="en">Your session has expired. A login is required. You can refresh the page or save your data to login.</value>
<value xml:lang="de">Sie sind nicht mehr angemeldet. Bitte melden Sie sich erneut an.</value>
- <value xml:lang="en">You are not logged in. Please login again.</value>
<value xml:lang="es">No está conectado. Por favor, vuelva a conectarse.</value>
+ <value xml:lang="fr">Votre session est terminée. Veuillez vous identifier à nouveau pour utiliser l'application. Pour vous connecter, vous pouvez actualiser la page, sauvegarder vos données ou utiliser le lien Connexion (ou Déconnexion) en haut à droite.</value>
<value xml:lang="vi">Bạn chÆ°a ÄÄng nháºp. Vui lòng ÄÄng nháºp lại.</value>
</property>
<property key="CommonSet">
Added: ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl?rev=1327502&view=auto
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl (added)
+++ ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl Wed Apr 18 13:24:30 2012
@@ -0,0 +1,21 @@
+<#--
+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.
+-->
+
+ </body>
+</html>
Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlfooter-for-ajax.ftl
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.ftl?rev=1327502&view=auto
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.ftl (added)
+++ ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.ftl Wed Apr 18 13:24:30 2012
@@ -0,0 +1,29 @@
+<#--
+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.
+-->
+<#assign docLangAttr = locale.toString()?replace("_", "-")>
+<#assign langDir = "ltr">
+<#if "ar.iw"?contains(docLangAttr?substring(0, 2))>
+ <#assign langDir = "rtl">
+</#if>
+<html lang="${docLangAttr}" dir="${langDir}" xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ </head>
+ <body>
+<#--<br class="clear" />-->
Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.ftl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.ftl
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlheader-for-ajax.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=1327502&r1=1327501&r2=1327502&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/widget/CommonScreens.xml (original)
+++ ofbiz/trunk/framework/common/widget/CommonScreens.xml Wed Apr 18 13:24:30 2012
@@ -90,20 +90,46 @@ under the License.
</widgets>
</section>
</screen>
+ <!-- decorator used in creating a response to an ajax request -->
+ <screen name="AjaxGlobalDecorator">
+ <section>
+ <actions>
+ <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true" />
+ </actions>
+ <widgets>
+ <platform-specific>
+ <html>
+ <html-template location="component://common/webcommon/includes/htmlheader-for-ajax.ftl" />
+ </html>
+ </platform-specific>
+ <decorator-section-include name="body" />
+ <platform-specific>
+ <html>
+ <html-template location="component://common/webcommon/includes/htmlfooter-for-ajax.ftl" />
+ </html>
+ </platform-specific>
+ </widgets>
+ </section>
+ </screen>
<!--
The following screen is used to generate Ajax list of options for autocomplete fields
-->
<screen name="ajaxAutocompleteOptions">
<section>
<actions>
- <set field="autocompleteOptions" from-field="parameters.autocompleteOptions"/>
+ <set field="autocompleteOptions" from-field="parameters.autocompleteOptions" />
</actions>
<widgets>
- <platform-specific><html><html-template location="component://common/webcommon/includes/ajaxAutocompleteOptions.ftl"/></html></platform-specific>
+ <decorator-screen name="AjaxGlobalDecorator">
+ <decorator-section name="body">
+ <platform-specific>
+ <html><html-template location="component://common/webcommon/includes/ajaxAutocompleteOptions.ftl" /></html>
+ </platform-specific>
+ </decorator-section>
+ </decorator-screen>
</widgets>
</section>
</screen>
-
<!-- Global screen rendering context initialization, intended to be included in screen decorators. Devs - please keep this simple and generic. -->
<screen name="GlobalActions">
<section>
@@ -411,7 +437,15 @@ under the License.
<script location="component://common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy"/>
</actions>
<widgets>
- <platform-specific><html><html-template location="component://common/webcommon/includes/ajaxAutocompleteOptions.ftl"/></html></platform-specific>
+ <decorator-screen name="AjaxGlobalDecorator">
+ <decorator-section name="body">
+ <platform-specific>
+ <html>
+ <html-template location="component://common/webcommon/includes/ajaxAutocompleteOptions.ftl" />
+ </html>
+ </platform-specific>
+ </decorator-section>
+ </decorator-screen>
</widgets>
</section>
</fail-widgets>
@@ -542,9 +576,9 @@ under the License.
<screen name="ajaxNotLoggedIn">
<section>
<widgets>
- <decorator-screen name="LookupDecorator">
+ <decorator-screen name="AjaxGlobalDecorator">
<decorator-section name="body">
- <link target="checkLogin" text="${uiLabelMap.CommonSessionTimeoutPleaseLogIn}"/>
+ <label style="message" text="${uiLabelMap.CommonSessionTimeoutPleaseLogIn}"/>
</decorator-section>
</decorator-screen>
</widgets>
Modified: ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/fieldlookup.js?rev=1327502&r1=1327501&r2=1327502&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/fieldlookup.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/fieldlookup.js Wed Apr 18 13:24:30 2012
@@ -181,12 +181,10 @@ function initiallyCollapseDelayed() {
* Fieldlookup Class & Methods
*************************************/
function ConstructLookup(requestUrl, inputFieldId, dialogTarget, dialogOptionalTarget, formName, width, height, position, modal, ajaxUrl, showDescription, presentation, defaultMinLength, defaultDelay, args) {
-
// add the presentation attribute to the request url to let the request know which decorator should be loaded
if(!presentation) {
var presentation = "layer"
- }
- requestUrl = getViewNameWithSeparator(requestUrl) + "presentation=" + presentation;
+ }
// create Link Element with unique Key
var lookupId = GLOBAL_LOOKUP_REF.createNextKey();
@@ -232,7 +230,7 @@ function ConstructLookup(requestUrl, inp
} else {
positioning = ['left', 'top'];
}
-
+
var lookupFormAction = null;
function lookup_onKeyEnter(event) {
if (event.which == 13) {
@@ -251,35 +249,69 @@ function ConstructLookup(requestUrl, inp
position: positioning,
draggable: true,
resizeable: true,
- open: function() {
- var requestUrlAndArgs = requestUrl;
+ open: function(event,ui) {
+ waitSpinnerShow();
+ jQuery("#" + lookupId).empty();
+
+ var queryArgs = "presentation=" + presentation;
if (typeof args == "object" && jQuery.isArray(args)) {
for (var i = 0; i < args.length; i++) {
- requestUrlAndArgs += "&parm" + i + "=" + jQuery(args[i]).val();
+ queryArgs += "&parm" + i + "=" + jQuery(args[i]).val();
}
}
- jQuery("#" + lookupId).load(requestUrlAndArgs, function(data){
- lookupFormAction = jQuery("#" + lookupId + " form:first").attr("action");
- modifySubmitButton(lookupId);
- jQuery("#" + lookupId).bind("keypress", lookup_onKeyEnter);
- // set up the window chaining
- // if the ACTIVATED_LOOKUP var is set there have to be more than one lookup,
- // before registrating the new lookup we store the id of the old lookup in the
- // preLookup variable of the new lookup object. I.e. lookup_1 calls lookup_8, the lookup_8
- // object need a reference to lookup_1, this reference is set here
- var prevLookup = null
- if (ACTIVATED_LOOKUP) {
- prevLookup = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).lookupId;
- }
- identifyLookup(lookupId);
-
- if (prevLookup) {
- GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).prevLookup = prevLookup;
- }
+
+ jQuery.ajax({
+ type: "post",
+ url: requestUrl,
+ data: queryArgs,
+ timeout: AJAX_REQUEST_TIMEOUT,
+ cache: false,
+ dataFilter: function(data, dataType) {
+ waitSpinnerHide();
+ return data;
+ },
+ success: function(data) {
+ //search for <span style="message...> returned from server
+ var matchFound = data.toString().match(AJAX_SERVER_REPLY_MSG_REGEXPATTERN);
+ if (matchFound != null) {
+ jQuery(event.target).parent().css({'display':'none'});
+ jQuery("#" + lookupId).dialog('close');
+ alert(matchFound[1].trim());
+ return;
+ }
+
+ jQuery("#" + lookupId).html(data);
+
+ lookupFormAction = jQuery("#" + lookupId + " form:first").attr("action");
+ modifySubmitButton(lookupId);
+ jQuery("#" + lookupId).bind("keypress", lookup_onKeyEnter);
+ // set up the window chaining
+ // if the ACTIVATED_LOOKUP var is set there have to be more than one lookup,
+ // before registrating the new lookup we store the id of the old lookup in the
+ // preLookup variable of the new lookup object. I.e. lookup_1 calls lookup_8, the lookup_8
+ // object need a reference to lookup_1, this reference is set here
+ var prevLookup = null
+ if (ACTIVATED_LOOKUP) {
+ prevLookup = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).lookupId;
+ }
+ identifyLookup(lookupId);
+
+ if (prevLookup) {
+ GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).prevLookup = prevLookup;
+ }
+ },
+ error: function(xhr, reason, exception) {
+ //TODO ... need to localize the following error message.
+ alert("An error occurred while communicating with the server:\n\n\nreason=" + reason + "\n\nexception=" + exception);
+ location.reload(true);
+ },
});
},
close: function() {
jQuery("#" + lookupId).unbind("keypress", lookup_onKeyEnter);
+
+ waitSpinnerHide();
+
//when the window is closed the prev Lookup get the focus (if exists)
if (ACTIVATED_LOOKUP) {
var prevLookup = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).prevLookup;
@@ -290,7 +322,6 @@ function ConstructLookup(requestUrl, inp
ACTIVATED_LOOKUP = null;
}
}
-
};
// init Dialog and register
@@ -331,7 +362,6 @@ function ConstructLookup(requestUrl, inp
jQuery("#" + lookupId).dialog("close");
}
});
-
}
function FieldLookupCounter() {
@@ -378,7 +408,6 @@ function FieldLookupCounter() {
};
var GLOBAL_LOOKUP_REF = new FieldLookupCounter;
-
/**
* returns true if a String is empty
* @param value - String value
Modified: ofbiz/trunk/framework/images/webapp/images/selectall.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/selectall.js?rev=1327502&r1=1327501&r2=1327502&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/selectall.js Wed Apr 18 13:24:30 2012
@@ -20,6 +20,12 @@
//Define global variable to store last auto-completer request object (jqXHR).
var LAST_AUTOCOMP_REF = null;
+//the regex pattern to filter out the message returned by server during an ajax call.
+var AJAX_SERVER_REPLY_MSG_REGEXPATTERN = /<span\s+class="message\s+.*">(.*)?<\/span>/;
+
+//default ajax request timeout in milliseconds
+var AJAX_REQUEST_TIMEOUT = 5000;
+
// Check Box Select/Toggle Functions for Select/Toggle All
function toggle(e) {
@@ -427,11 +433,19 @@ function ajaxAutoCompleter(areaCsvString
LAST_AUTOCOMP_REF= jqXHR;
},
success: function(data) {
- // reset the autocomp field
- autocomp = undefined;
-
- //update the result div
+ // reset the autocomp field
+ autocomp = undefined;
+
+ //search for <span style="message...> returned from server
+ var matchFound = data.toString().match(AJAX_SERVER_REPLY_MSG_REGEXPATTERN);
+ if (matchFound != null) {
+ alert(matchFound[1].trim());
+ response(null);
+ return;
+ }
+
jQuery("#" + div + "_auto").html(data);
+
if (typeof autocomp != 'undefined') {
jQuery.each(autocomp, function(index, item){
item.label = jQuery("<div>").html(item.label).text();
@@ -439,8 +453,12 @@ function ajaxAutoCompleter(areaCsvString
// autocomp is the JSON Object which will be used for the autocomplete box
response(autocomp);
}
- }
- })
+ },
+ error: function(xhr, reason, exception) {
+ //TODO ... need to localize the following error message.
+ alert("An error occurred while communicating with the server:\n\n\nreason=" + reason + "\n\nexception=" + exception);
+ },
+ });
},
select: function(event, ui){
//jQuery("#" + areaArray[0]).html(ui.item);
@@ -673,8 +691,8 @@ function ajaxInPlaceEditDisplayField(ele
jElement.editable(function(value, settings){
// removes all line breaks from the value param, because the parseJSON Function can't work with line breaks
- value = value.replace(/\n/g, " ");
- value = value.replace(/\"/g,""");
+ value = value.replace(/\n/g, " ");
+ value = value.replace(/\"/g,""");
var resultField = jQuery.parseJSON('{"' + settings.name + '":"' + value + '"}');
// merge both parameter objects together
Modified: ofbiz/trunk/framework/images/webapp/images/spinner.gif
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/spinner.gif?rev=1327502&r1=1327501&r2=1327502&view=diff
==============================================================================
Binary files - no diff available.