You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/09/13 15:00:22 UTC
svn commit: r442972 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/ajax/api/
theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
theme/standard/src/main/resources/org/apache/myfac...
Author: weber
Date: Wed Sep 13 06:00:21 2006
New Revision: 442972
URL: http://svn.apache.org/viewvc?view=rev&rev=442972
Log:
working on TOBAGO-121 (made autoreload conditional with a valuebinding)
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java?view=diff&rev=442972&r1=442971&r2=442972
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxPhaseListener.java Wed Sep 13 06:00:21 2006
@@ -52,6 +52,9 @@
private static final Log LOG = LogFactory.getLog(AjaxPhaseListener.class);
public static final String AJAX_COMPONENT_ID = "affectedAjaxComponent";
+ public static final String CODE_SUCCESS = "<status code=\"200\"/>";
+ public static final String CODE_NOT_MODIFIED = "<status code=\"304\"/>";
+ public static final String CODE_RELOAD_REQUIRED = "<status code=\"309\"/>";
public static Object getValueForComponent(
FacesContext facesContext, UIComponent component) {
@@ -133,6 +136,8 @@
LOG.debug("Size of AjaxResponse:\n" + buf.length()
+ " = 0x" + Integer.toHexString(buf.length()));
}
+
+ buf.insert(0, CODE_SUCCESS);
buf.insert(0, Integer.toHexString(buf.length()) + "\r\n");
buf.append("\r\n" + 0 + "\r\n\r\n");
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?view=diff&rev=442972&r1=442971&r2=442972
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Wed Sep 13 06:00:21 2006
@@ -21,14 +21,45 @@
* $Id$
*/
-import static org.apache.myfaces.tobago.component.UIData.NONE;
-import static org.apache.myfaces.tobago.TobagoConstants.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_ONCLICK;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ALIGN;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DIRECT_LINK_COUNT;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FOOTER_HEIGHT;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FORCE_VERTICAL_SCROLLBAR;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_IMAGE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_INLINE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_HEIGHT;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MENU_POPUP;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MENU_POPUP_TYPE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTED_LIST_STRING;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DIRECT_LINKS;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_PAGE_RANGE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ROW_RANGE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SORTABLE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_BODY;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_CLASS;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_HEADER;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH_LIST;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_WIDTH_LIST_STRING;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_MENUPOPUP;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_PAGER_PAGE;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_PAGER_ROW;
+import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_LINK;
+import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_MENUBAR;
+import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_MENUCOMMAND;
+import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
+import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
-import org.apache.myfaces.tobago.ajax.api.AjaxPhaseListener;
import org.apache.myfaces.tobago.component.ComponentUtil;
import org.apache.myfaces.tobago.component.UIColumnSelector;
import org.apache.myfaces.tobago.component.UIData;
+import static org.apache.myfaces.tobago.component.UIData.NONE;
import org.apache.myfaces.tobago.component.UIMenu;
import org.apache.myfaces.tobago.component.UIMenuCommand;
import org.apache.myfaces.tobago.component.UIReload;
@@ -46,9 +77,6 @@
import org.apache.myfaces.tobago.util.StringUtil;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import javax.faces.application.Application;
import javax.faces.component.UIColumn;
import javax.faces.component.UICommand;
@@ -114,8 +142,9 @@
final String[] styles = new String[]{"style/tobago-sheet.css"};
final String[] scripts = new String[]{"script/tobago-sheet.js"};
Integer frequency = null;
- if (data.getFacet("reload") != null && data.getFacet("reload") instanceof UIReload) {
- UIReload update = (UIReload) data.getFacet("reload");
+ UIComponent facetReload = data.getFacet("reload");
+ if (facetReload != null && facetReload instanceof UIReload && facetReload.isRendered()) {
+ UIReload update = (UIReload) facetReload;
frequency = update.getFrequency();
}
final String[] cmds = {
Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?view=diff&rev=442972&r1=442971&r2=442972
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Wed Sep 13 06:00:21 2006
@@ -333,41 +333,47 @@
this.setupStart = new Date();
// LOG.debug("Tobago.Sheet.setup(" + this.id +")");
- // ToDo: find a better way to fix this problem
- // IE needs this in case of ajax loading of style classes
- var outerDiv = Tobago.element(this.outerDivId);
- outerDiv.className = outerDiv.className;
- outerDiv.innerHTML = outerDiv.innerHTML;
-
- this.setupElements();
-
- this.setupResizer();
-
- this.adjustHeaderDiv();
- this.adjustResizer();
-
- this.setupHeader();
-
- if (this.firstRowId) {
- this.tobagoLastClickedRowId = this.firstRowIndex;
- }
- this.adjustScrollBars();
-
- if (this.selectable && (this.selectable == "single" || this.selectable == "multi")) {
- this.addSelectionListener();
- this.updateSelectionView();
- }
-
- if (this.ajaxEnabled) {
- this.setupSortHeaders();
- this.setupPagingLinks();
- this.setupPagePaging();
- this.setupRowPaging();
- }
- if (typeof this.autoReload == "number" && Tobago.element(this.contentDivId)) {
- clearTimeout(this.reloadTimer);
- this.reloadTimer = setTimeout(Tobago.bind2(this, "reloadWithAction", this.id), this.autoReload);
- }
+ var divElement = Tobago.element(this.outerDivId);
+ if (divElement.skipUpdate) {
+ // LOG.debug("skip setup");
+ divElement.skipUpdate = false;
+ } else {
+
+ // ToDo: find a better way to fix this problem
+ // IE needs this in case of ajax loading of style classes
+ var outerDiv = divElement;
+ outerDiv.className = outerDiv.className;
+ outerDiv.innerHTML = outerDiv.innerHTML;
+
+ this.setupElements();
+
+ this.setupResizer();
+
+ this.adjustHeaderDiv();
+ this.adjustResizer();
+
+ this.setupHeader();
+
+ if (this.firstRowId) {
+ this.tobagoLastClickedRowId = this.firstRowIndex;
+ }
+ this.adjustScrollBars();
+
+ if (this.selectable && (this.selectable == "single" || this.selectable == "multi")) {
+ this.addSelectionListener();
+ this.updateSelectionView();
+ }
+
+ if (this.ajaxEnabled) {
+ this.setupSortHeaders();
+ this.setupPagingLinks();
+ this.setupPagePaging();
+ this.setupRowPaging();
+ }
+ if (typeof this.autoReload == "number" && Tobago.element(this.contentDivId)) {
+ clearTimeout(this.reloadTimer);
+ this.reloadTimer = setTimeout(Tobago.bind2(this, "reloadWithAction", this.id), this.autoReload);
+ }
this.setupEnd = new Date();
};
Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?view=diff&rev=442972&r1=442971&r2=442972
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Wed Sep 13 06:00:21 2006
@@ -1330,6 +1330,11 @@
}
Tobago.Updater = {
+ CODE_SUCCESS: "<status code=\"200\"/>",
+
+ CODE_NOT_MODIFIED: "<status code=\"304\"/>",
+
+ CODE_RELOAD_REQUIRED: "<status code=\"309\"/>",
options: {
method: 'post',
@@ -1337,7 +1342,28 @@
parameters: '',
evalScripts: true,
createOverlay: true,
- onComplete: function(){} // empty function
+ onComplete: function(){}, // empty function
+ insertion: function(receiver, response) {
+ LOG.debug("response = \"" + response.substring(0, 30 < response.length ? 30 : response.length) + "\"");
+ LOG.debug("this.CODE_NOT_MODIFIED = \"" + Tobago.Updater.CODE_NOT_MODIFIED + "\" ist lang:" + Tobago.Updater.CODE_NOT_MODIFIED.length);
+ if (response.substring(0, Tobago.Updater.CODE_NOT_MODIFIED.length) == Tobago.Updater.CODE_NOT_MODIFIED) {
+ // no update needed, do nothing
+ LOG.debug("skip update");
+ receiver.skipUpdate = true;
+ } else if (response.substring(0, Tobago.Updater.CODE_SUCCESS.length) == Tobago.Updater.CODE_SUCCESS) {
+ // update content
+ LOG.debug("update content");
+ Element.update(receiver, response.substring(20));
+ } else if (response.substring(0, Tobago.Updater.CODE_RELOAD_REQUIRED.length) == Tobago.Updater.CODE_RELOAD_REQUIRED) {
+ // reload complete page
+ LOG.debug("full reload requested");
+ Tobago.submitAction("page:overviewSheet");
+ } else {
+ // unknown response do full page reload
+ LOG.debug("initiating full reload");
+ Tobago.submitAction("page:overviewSheet");
+ }
+ }
},
update: function(container, page, actionId, ajaxComponentId, options) {
@@ -1354,7 +1380,7 @@
var onComplete = requestOptions.onComplete;
requestOptions.onComplete = function(transport, json) {
Tobago.Transport.requestComplete();
- onComplete(transport, json);
+ onComplete(transport, json);
};
// LOG.debug("request url = " + url);