myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1420939 [1/2] - in /myfaces/core/branches/2.1.x-client-window: ./ api/src/main/java/javax/faces/component/ api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/ api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/ im...
Date Wed, 12 Dec 2012 20:02:58 GMT
Author: lu4242
Date: Wed Dec 12 20:02:51 2012
New Revision: 1420939

URL: http://svn.apache.org/viewvc?rev=1420939&view=rev
Log:
merge revisions 1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589 from trunk

Added:
    myfaces/core/branches/2.1.x-client-window/api/src/main/java/javax/faces/component/_ViewAttributeMap.java
      - copied unchanged from r1417719, myfaces/core/trunk/api/src/main/java/javax/faces/component/_ViewAttributeMap.java
    myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIRDComponent.java
      - copied unchanged from r1417719, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIRDComponent.java
    myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingBean.java
      - copied unchanged from r1417719, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingBean.java
    myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ResourceDependencyBean.java
      - copied unchanged from r1417719, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ResourceDependencyBean.java
    myfaces/core/branches/2.1.x-client-window/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBinding1.xhtml
      - copied unchanged from r1417719, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBinding1.xhtml
    myfaces/core/branches/2.1.x-client-window/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resourceDependency1.xhtml
      - copied unchanged from r1417719, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resourceDependency1.xhtml
    myfaces/core/branches/2.1.x-client-window/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/   (props changed)
      - copied from r1417719, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/
    myfaces/core/branches/2.1.x-client-window/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/custom.css
      - copied unchanged from r1417719, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/custom.css
Removed:
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ReferenceSerializedViewKey.java
    myfaces/core/branches/2.1.x-client-window/implee6/
    myfaces/core/branches/2.1.x-client-window/shaded-impl/
Modified:
    myfaces/core/branches/2.1.x-client-window/   (props changed)
    myfaces/core/branches/2.1.x-client-window/api/src/main/java/javax/faces/component/UIViewRoot.java
    myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
    myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
    myfaces/core/branches/2.1.x-client-window/impl/pom.xml
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheImpl.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterKeyFactory.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/KeyFactory.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomKeyFactory.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SecureRandomKeyFactory.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java   (contents, props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionIdGenerator.java   (contents, props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionViewStorageFactory.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheFactoryImpl.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheUtils.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
    myfaces/core/branches/2.1.x-client-window/impl/src/main/resources/META-INF/faces-config20.vm   (props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheTest.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheTest.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java
    myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java
    myfaces/core/branches/2.1.x-client-window/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/WEB-INF/testcomponent.taglib.xml
    myfaces/core/branches/2.1.x-client-window/parent/pom.xml   (contents, props changed)
    myfaces/core/branches/2.1.x-client-window/parent/src/   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared/   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/pom.xml   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/src/   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/src/main/java/org/apache/myfaces/shared/util/AttachedDeltaWrapper.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/src/main/java/org/apache/myfaces/shared/util/DebugUtils.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/src/main/java/org/apache/myfaces/shared/util/RendererUtils.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/src/main/java/org/apache/myfaces/shared/util/TagUtils.java   (props changed)
    myfaces/core/branches/2.1.x-client-window/shared-public/src/main/java/org/apache/myfaces/shared/util/renderkit/   (props changed)

Propchange: myfaces/core/branches/2.1.x-client-window/
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Modified: myfaces/core/branches/2.1.x-client-window/api/src/main/java/javax/faces/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/api/src/main/java/javax/faces/component/UIViewRoot.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/api/src/main/java/javax/faces/component/UIViewRoot.java (original)
+++ myfaces/core/branches/2.1.x-client-window/api/src/main/java/javax/faces/component/UIViewRoot.java Wed Dec 12 20:02:51 2012
@@ -116,6 +116,9 @@ public class UIViewRoot extends UICompon
     private static final String JAVAX_FACES_LOCATION_BODY = "javax_faces_location_body";
     private static final String JAVAX_FACES_LOCATION_FORM = "javax_faces_location_form";
     
+    private transient boolean _resourceDependencyUniqueId;
+    private transient Map<String,Object> _attributesMap;
+    
     /**
      * Construct an instance of the UIViewRoot.
      */
@@ -343,10 +346,20 @@ public class UIViewRoot extends UICompon
         // UNIQUE_ID_PREFIX, and will be unique within this UIViewRoot.
         if(seed==null)
         {
-            Long uniqueIdCounter = (Long) getStateHelper().get(PropertyKeys.uniqueIdCounter);
-            uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
-            getStateHelper().put(PropertyKeys.uniqueIdCounter, (uniqueIdCounter+1L));
-            return bld.append(UNIQUE_ID_PREFIX).append(uniqueIdCounter).toString();    
+            if (isResourceDependencyUniqueId())
+            {
+                Long uniqueIdCounter = (Long) getStateHelper().get(PropertyKeys.resourceDependencyUniqueIdCounter);
+                uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
+                getStateHelper().put(PropertyKeys.resourceDependencyUniqueIdCounter, (uniqueIdCounter+1L));
+                return bld.append(UNIQUE_ID_PREFIX).append("__rd_").append(uniqueIdCounter).toString();
+            }
+            else
+            {
+                Long uniqueIdCounter = (Long) getStateHelper().get(PropertyKeys.uniqueIdCounter);
+                uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter;
+                getStateHelper().put(PropertyKeys.uniqueIdCounter, (uniqueIdCounter+1L));
+                return bld.append(UNIQUE_ID_PREFIX).append(uniqueIdCounter).toString();
+            }
         }
         // Optionally, a unique seed value can be supplied by component creators which
         // should be included in the generated unique id.
@@ -1234,6 +1247,32 @@ public class UIViewRoot extends UICompon
         getStateHelper().put(PropertyKeys.afterPhaseListener, afterPhaseListener);
     }
     
+    @Override
+    public Map<String, Object> getAttributes()
+    {
+        if (_attributesMap == null)
+        {
+            _attributesMap = new _ViewAttributeMap(this, super.getAttributes());
+        }
+        return _attributesMap;
+    }
+
+    /**
+     * Indicates if the component is created when facelets builds the view and
+     * is caused by the presence of a ResourceDependency annotation.
+     * 
+     * @return the _resourceDependencyUniqueId
+     */
+    boolean isResourceDependencyUniqueId()
+    {
+        return _resourceDependencyUniqueId;
+    }
+
+    void setResourceDependencyUniqueId(boolean resourceDependencyUniqueId)
+    {
+        this._resourceDependencyUniqueId = resourceDependencyUniqueId;
+    }
+    
     enum PropertyKeys
     {
          afterPhaseListener
@@ -1243,6 +1282,7 @@ public class UIViewRoot extends UICompon
         , renderKitId
         , viewId
         , uniqueIdCounter
+        , resourceDependencyUniqueIdCounter
     }
     
     @Override

Modified: myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Wed Dec 12 20:02:51 2012
@@ -373,6 +373,220 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, 
         return ret;
     },
 
+    propertyToAttribute: function(name) {
+        if (name === 'className') {
+            return 'class';
+        } else if (name === 'xmllang') {
+            return 'xml:lang';
+        } else {
+            return name.toLowerCase();
+        }
+    },
+
+    isFunctionNative: function(func) {
+        return /^\s*function[^{]+{\s*\[native code\]\s*}\s*$/.test(String(func));
+    },
+
+    detectAttributes: function(element) {
+        //test if 'hasAttribute' method is present and its native code is intact
+        //for example, Prototype can add its own implementation if missing
+        if (element.hasAttribute && this.isFunctionNative(element.hasAttribute)) {
+            return function(name) {
+                return element.hasAttribute(name);
+            }
+        } else {
+            try {
+                //when accessing .getAttribute method without arguments does not throw an error then the method is not available
+                element.getAttribute;
+
+                var html = element.outerHTML;
+                var startTag = html.match(/^<[^>]*>/)[0];
+                return function(name) {
+                    return startTag.indexOf(name + '=') > -1;
+                }
+            } catch (ex) {
+                return function(name) {
+                    return element.getAttribute(name);
+                }
+            }
+        }
+    },
+
+    /**
+     * copy all attributes from one element to another - except id
+     * @param target element to copy attributes to
+     * @param source element to copy attributes from
+     * @ignore
+     */
+    cloneAttributes: function(target, source) {
+
+        // enumerate core element attributes - without 'dir' as special case
+        var coreElementProperties = ['className', 'title', 'lang', 'xmllang'];
+        // enumerate additional input element attributes
+        var inputElementProperties = [
+            'name', 'value', 'size', 'maxLength', 'src', 'alt', 'useMap', 'tabIndex', 'accessKey', 'accept', 'type'
+        ];
+        // enumerate additional boolean input attributes
+        var inputElementBooleanProperties = [
+            'checked', 'disabled', 'readOnly'
+        ];
+
+        // Enumerate all the names of the event listeners
+        var listenerNames =
+            [ 'onclick', 'ondblclick', 'onmousedown', 'onmousemove', 'onmouseout',
+                'onmouseover', 'onmouseup', 'onkeydown', 'onkeypress', 'onkeyup',
+                'onhelp', 'onblur', 'onfocus', 'onchange', 'onload', 'onunload', 'onabort',
+                'onreset', 'onselect', 'onsubmit'
+            ];
+
+        var sourceAttributeDetector = this.detectAttributes(source);
+        var targetAttributeDetector = this.detectAttributes(target);
+
+        var isInputElement = target.nodeName.toLowerCase() === 'input';
+        var propertyNames = isInputElement ? coreElementProperties.concat(inputElementProperties) : coreElementProperties;
+        var isXML = !source.ownerDocument.contentType || source.ownerDocument.contentType == 'text/xml';
+        for (var iIndex = 0, iLength = propertyNames.length; iIndex < iLength; iIndex++) {
+            var propertyName = propertyNames[iIndex];
+            var attributeName = this.propertyToAttribute(propertyName);
+            if (sourceAttributeDetector(attributeName)) {
+
+                //With IE 7 (quirks or standard mode) and IE 8/9 (quirks mode only),
+                //you cannot get the attribute using 'class'. You must use 'className'
+                //which is the same value you use to get the indexed property. The only
+                //reliable way to detect this (without trying to evaluate the browser
+                //mode and version) is to compare the two return values using 'className'
+                //to see if they exactly the same.  If they are, then use the property
+                //name when using getAttribute.
+                if( attributeName == 'class'){
+                    if( this._RT.browser.isIE && (source.getAttribute(propertyName) === source[propertyName]) ){
+                        attributeName = propertyName;
+                    }
+                }
+
+                var newValue = isXML ? source.getAttribute(attributeName) : source[propertyName];
+                var oldValue = target[propertyName];
+                if (oldValue != newValue) {
+                    target[propertyName] = newValue;
+                }
+            } else {
+                target.removeAttribute(attributeName);
+                if (attributeName == "value") {
+                    target[propertyName] = '';
+                }
+            }
+        }
+
+        var booleanPropertyNames = isInputElement ? inputElementBooleanProperties : [];
+        for (var jIndex = 0, jLength = booleanPropertyNames.length; jIndex < jLength; jIndex++) {
+            var booleanPropertyName = booleanPropertyNames[jIndex];
+            var newBooleanValue = source[booleanPropertyName];
+            var oldBooleanValue = target[booleanPropertyName];
+            if (oldBooleanValue != newBooleanValue) {
+                target[booleanPropertyName] = newBooleanValue;
+            }
+        }
+
+        //'style' attribute special case
+        if (sourceAttributeDetector('style')) {
+            var newStyle;
+            var oldStyle;
+            if (this._RT.browser.isIE) {
+                newStyle = source.style.cssText;
+                oldStyle = target.style.cssText;
+                if (newStyle != oldStyle) {
+                    target.style.cssText = newStyle;
+                }
+            } else {
+                newStyle = source.getAttribute('style');
+                oldStyle = target.getAttribute('style');
+                if (newStyle != oldStyle) {
+                    target.setAttribute('style', newStyle);
+                }
+            }
+        } else if (targetAttributeDetector('style')){
+            target.removeAttribute('style');
+        }
+
+        // Special case for 'dir' attribute
+        if (!this._RT.browser.isIE && source.dir != target.dir) {
+            if (sourceAttributeDetector('dir')) {
+                target.dir = source.dir;
+            } else if (targetAttributeDetector('dir')) {
+                target.dir = '';
+            }
+        }
+
+        for (var lIndex = 0, lLength = listenerNames.length; lIndex < lLength; lIndex++) {
+            var name = listenerNames[lIndex];
+            target[name] = source[name] ? source[name] : null;
+            if (source[name]) {
+                source[name] = null;
+            }
+        }
+
+        //clone HTML5 data-* attributes
+        try{
+            var targetDataset = target.dataset;
+            var sourceDataset = source.dataset;
+            if (targetDataset || sourceDataset) {
+                //cleanup the dataset
+                for (var tp in targetDataset) {
+                    delete targetDataset[tp];
+                }
+                //copy dataset's properties
+                for (var sp in sourceDataset) {
+                    targetDataset[sp] = sourceDataset[sp];
+                }
+            }
+        } catch (ex) {
+            //most probably dataset properties are not supported
+        }
+    },
+    //from
+    // http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/
+    getCaretPosition:function (ctrl) {
+        var caretPos = 0;
+
+        try {
+
+            // other browsers make it simpler by simply having a selection start element
+            if (ctrl.selectionStart || ctrl.selectionStart == '0')
+                caretPos = ctrl.selectionStart;
+            // ie 5 quirks mode as second option because
+            // this option is flakey in conjunction with text areas
+            // TODO move this into the quirks class
+            else if (document.selection) {
+                ctrl.focus();
+                var selection = document.selection.createRange();
+                //the selection now is start zero
+                selection.moveStart('character', -ctrl.value.length);
+                //the caretposition is the selection start
+                caretPos = selection.text.length;
+            }
+        } catch (e) {
+            //now this is ugly, but not supported input types throw errors for selectionStart
+            //this way we are future proof by having not to define every selection enabled
+            //input in an if (which will be a lot in the near future with html5)
+        }
+        return caretPos;
+    },
+
+    setCaretPosition:function (ctrl, pos) {
+
+        if (ctrl.createTextRange) {
+            var range = ctrl.createTextRange();
+            range.collapse(true);
+            range.moveEnd('character', pos);
+            range.moveStart('character', pos);
+            range.select();
+        }
+        //IE quirks mode again, TODO move this into the quirks class
+        else if (ctrl.setSelectionRange) {
+            ctrl.focus();
+            //the selection range is our caret position
+            ctrl.setSelectionRange(pos, pos);
+        }
+    },
 
     /**
      * outerHTML replacement which works cross browserlike
@@ -380,31 +594,62 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, 
      *
      * @param item the item to be replaced
      * @param markup the markup for the replacement
+     * @param preserveFocus, tries to preserve the focus within the outerhtml operation
+     * if set to true a focus preservation algorithm based on document.activeElement is
+     * used to preserve the focus at the exactly same location as it was
+     *
      */
-    outerHTML : function(item, markup) {
+    outerHTML : function(item, markup, preserveFocus) {
         this._assertStdParams(item, markup, "outerHTML");
+        // we can work on a single element in a cross browser fashion
+        // regarding the focus thanks to the
+        // icefaces team for providing the code
+        if (item.nodeName.toLowerCase() === 'input') {
+            var replacingInput = this._buildEvalNodes(item, markup)[0];
+            this.cloneAttributes(item, replacingInput);
+            return item;
+        } else {
+            markup = this._Lang.trim(markup);
+            if (markup !== "") {
+                var ret = null;
+
+                var focusElementId = null;
+                var caretPosition = 0;
+                if (preserveFocus && 'undefined' != typeof document.activeElement) {
+                    focusElementId = (document.activeElement) ? document.activeElement.id : null;
+                    caretPosition = this.getCaretPosition(document.activeElement);
+                }
+                // we try to determine the browsers compatibility
+                // level to standards dom level 2 via various methods
+                if (this.isDomCompliant()) {
+                    ret = this._outerHTMLCompliant(item, markup);
+                } else {
+                    //call into abstract method
+                    ret = this._outerHTMLNonCompliant(item, markup);
+                }
+                if (focusElementId) {
+                    var newFocusElement = this.byId(focusElementId);
+                    if (newFocusElement && newFocusElement.nodeName.toLowerCase() === 'input') {
+                        //just in case the replacement element is not focusable anymore
+                        if ("undefined" != typeof newFocusElement.focus) {
+                            newFocusElement.focus();
+                        }
+                    }
+                    if (caretPosition) {
+                        //zero caret position is set automatically on focus
+                        this.setCaretPosition(newFocusElement, caretPosition);
+                    }
+                }
 
-        markup = this._Lang.trim(markup);
-        if (markup !== "") {
-            var ret = null;
-
-            // we try to determine the browsers compatibility
-            // level to standards dom level 2 via various methods
-            if (this.isDomCompliant()) {
-                ret = this._outerHTMLCompliant(item, markup);
-            } else {
-                //call into abstract method
-                ret = this._outerHTMLNonCompliant(item, markup);
+                // and remove the old item
+                //first we have to save the node newly insert for easier access in our eval part
+                this._eval(ret);
+                return ret;
             }
-
-            // and remove the old item
-            //first we have to save the node newly insert for easier access in our eval part
-            this._eval(ret);
-            return ret;
+            // and remove the old item, in case of an empty newtag and do nothing else
+            this._removeNode(item, false);
+            return null;
         }
-        // and remove the old item, in case of an empty newtag and do nothing else
-        this._removeNode(item, false);
-        return null;
     },
 
     /**

Modified: myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/branches/2.1.x-client-window/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Wed Dec 12 20:02:51 2012
@@ -605,7 +605,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", 
         if (!item) {
             throw this._raiseError(new Error(), _Lang.getMessage("ERR_ITEM_ID_NOTFOUND", null, "_AjaxResponse.replaceHtmlItem", (itemIdToReplace) ? itemIdToReplace.toString() : "undefined"),"replaceHtmlItem");
         }
-        return _Dom.outerHTML(item, markup);
+        return _Dom.outerHTML(item, markup, this._RT.getLocalOrGlobalConfig(context, "preserveFocus", false));
     },
 
     /**

Modified: myfaces/core/branches/2.1.x-client-window/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/pom.xml?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/pom.xml (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/pom.xml Wed Dec 12 20:02:51 2012
@@ -553,25 +553,9 @@
                     <createSourcesJar>true</createSourcesJar>
                     <artifactSet>
                         <includes>
-                            <include>org.apache.myfaces.core.internal:myfaces-impl-ee6</include>
                             <include>org.apache.myfaces.core.internal:myfaces-impl-shared</include>
                         </includes>
                     </artifactSet>
-                    <filters>
-                        <filter>
-                            <artifact>org.apache.myfaces.core.internal:myfaces-impl-ee6</artifact>
-                            <includes>
-                                <include>META-INF/services/**</include>
-                                <include>org/apache/myfaces/**</include>
-                            </includes>
-                            <excludes>
-                                <exclude>META-INF/LICENSE</exclude>
-                                <exclude>META-INF/NOTICE</exclude>
-                                <exclude>META-INF/DEPENDENCIES</exclude>
-                                <exclude>META-INF/MANIFEST.MF</exclude>
-                            </excludes>
-                        </filter>
-                    </filters>
                 </configuration>
             </plugin>
 

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Wed Dec 12 20:02:51 2012
@@ -104,6 +104,7 @@ import org.apache.myfaces.el.unified.res
 import org.apache.myfaces.lifecycle.LifecycleImpl;
 import org.apache.myfaces.shared.config.MyfacesConfig;
 import org.apache.myfaces.shared.util.ClassUtils;
+import org.apache.myfaces.view.facelets.FaceletCompositionContext;
 import org.apache.myfaces.view.facelets.el.ELText;
 
 /**
@@ -157,6 +158,14 @@ public class ApplicationImpl extends App
     private static final boolean LAZY_LOAD_CONFIG_OBJECTS_DEFAULT_VALUE = true;
     private Boolean _lazyLoadConfigObjects = null;
     
+    
+    /**
+     * Key under UIViewRoot to generated unique ids for components added 
+     * by @ResourceDependency effect.
+     */
+    private static final String RESOURCE_DEPENDENCY_UNIQUE_ID_KEY =
+              "oam.view.resourceDependencyUniqueId";
+
     // ~ Instance fields
     // --------------------------------------------------------------------------
     // --
@@ -1798,6 +1807,50 @@ public class ApplicationImpl extends App
             rvc.setClassProcessed(inspectedClass);
         }
     }
+
+    /**
+     * If the ResourceDependency component is created under facelets processing, it should receive
+     * an special unique component id. This method check if there is a FaceletCompositionContext
+     * and if that so, set the id. Components added by the effect of ResourceDependency are special,
+     * because they do not have state, but they depends on the view structure, so with PSS, 
+     * each time the view is built they are "recalculated", so they work as if they were transient
+     * components that needs to be created at each request, but there are some cases were the 
+     * components needs to be saved and restored fully. If a component is created outside facelets 
+     * control (render response phase) it is expected to use the default implementation of 
+     * createUniqueId(), but in that case, note that this happens after markInitialState() is 
+     * called, and the component in this case is saved and restored fully, as expected.
+     * 
+     * This code cannot be called from facelets component tag handler, because in cases where a
+     * component subtree is created using binding property, facelets lost control over component
+     * creation and delegates it to the user, but since the binding code is executed each time the
+     * view is created, the effect over ResourceDependency persists and the binding code takes into
+     * account in the recalculation step, even if later the node related to the binding property
+     * is dropped and recreated from the state fully. 
+     * 
+     * @param facesContext
+     * @param component 
+     */
+    private void setResourceIdOnFaceletsMode(FacesContext facesContext, UIComponent component)
+    {
+        if (component.getId() == null)
+        {
+            FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(facesContext);
+            if (mctx != null)
+            {
+                UIViewRoot root = facesContext.getViewRoot();
+                root.getAttributes().put(RESOURCE_DEPENDENCY_UNIQUE_ID_KEY, Boolean.TRUE);
+                try
+                {
+                    String uid = root.createUniqueId(facesContext, null);
+                    component.setId(uid);
+                }
+                finally
+                {
+                    root.getAttributes().put(RESOURCE_DEPENDENCY_UNIQUE_ID_KEY, Boolean.FALSE);
+                }
+            }
+        }
+    }
     
     private void _handleAttachedResourceDependency(FacesContext context, ResourceDependency annotation)
     {
@@ -1826,6 +1879,10 @@ public class ApplicationImpl extends App
             // Call setRendererType on the UIOutput instance, passing the renderer-type.
             output.setRendererType(rendererType);
             
+            // If the @ResourceDependency was done inside facelets processing,
+            // call setId() and set a proper id from facelets
+            setResourceIdOnFaceletsMode(context, output);
+            
             // Obtain the Map of attributes from the UIOutput component by calling UIComponent.getAttributes().
             Map<String, Object> attributes = output.getAttributes();
             
@@ -2301,6 +2358,10 @@ public class ApplicationImpl extends App
 
             // Call setRendererType on the UIOutput instance, passing the renderer-type.
             output.setRendererType(rendererType);
+            
+            // If the @ResourceDependency was done inside facelets processing,
+            // call setId() and set a proper id from facelets
+            setResourceIdOnFaceletsMode(context, output);
 
             // Obtain the Map of attributes from the UIOutput component by calling UIComponent.getAttributes().
             Map<String, Object> attributes = output.getAttributes();

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java Wed Dec 12 20:02:51 2012
@@ -67,8 +67,6 @@ public class ResourceHandlerImpl extends
     //private static final Log log = LogFactory.getLog(ResourceHandlerImpl.class);
     private static final Logger log = Logger.getLogger(ResourceHandlerImpl.class.getName());
 
-    private static final int _BUFFER_SIZE = 2048;
-    
     /**
      * Allow slash in the library name of a Resource. 
      */
@@ -78,7 +76,17 @@ public class ResourceHandlerImpl extends
             "org.apache.myfaces.STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME";
     public static final boolean INIT_PARAM_STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME_DEFAULT = false;
     
+    /**
+     * Define the default buffer size that is used between Resource.getInputStream() and 
+     * httpServletResponse.getOutputStream() when rendering resources using the default
+     * ResourceHandler.
+     */
+    @JSFWebConfigParam(since="2.1.10, 2.0.16", defaultValue="2048", group="resources")
+    public static final String INIT_PARAM_RESOURCE_BUFFER_SIZE = "org.apache.myfaces.RESOURCE_BUFFER_SIZE";
+    private static final int INIT_PARAM_RESOURCE_BUFFER_SIZE_DEFAULT = 2048;
+    
     private Boolean _allowSlashLibraryName;
+    private int _resourceBufferSize = -1;
 
     @Override
     public Resource createResource(String resourceName)
@@ -305,7 +313,8 @@ public class ResourceHandlerImpl extends
             // ServletResponseWrapper (like ResponseSwitch).
             // Since we are handling a resource, we can expect to get an 
             // HttpServletResponse.
-            Object response = facesContext.getExternalContext().getResponse();
+            ExternalContext extContext = facesContext.getExternalContext();
+            Object response = extContext.getResponse();
             HttpServletResponse httpServletResponse = ExternalContextUtils.getHttpServletResponse(response);
             if (httpServletResponse == null)
             {
@@ -379,12 +388,16 @@ public class ResourceHandlerImpl extends
                 httpServletResponse.setHeader(entry.getKey(), entry.getValue());
             }
     
+            // Sets the preferred buffer size for the body of the response
+            extContext.setResponseBufferSize(this.getResourceBufferSize());
+            
             //serve up the bytes (taken from trinidad ResourceServlet)
             try
             {
                 InputStream in = resource.getInputStream();
                 OutputStream out = httpServletResponse.getOutputStream();
-                byte[] buffer = new byte[_BUFFER_SIZE];
+                //byte[] buffer = new byte[_BUFFER_SIZE];
+                byte[] buffer = new byte[this.getResourceBufferSize()];
     
                 try
                 {
@@ -681,4 +694,16 @@ public class ResourceHandlerImpl extends
         return _allowSlashLibraryName;
     }
 
+    protected int getResourceBufferSize()
+    {
+        if (_resourceBufferSize == -1)
+        {
+            _resourceBufferSize = WebConfigParamUtils.getIntegerInitParameter(
+                FacesContext.getCurrentInstance().getExternalContext(),
+                INIT_PARAM_RESOURCE_BUFFER_SIZE,
+                INIT_PARAM_RESOURCE_BUFFER_SIZE_DEFAULT);
+        }
+        return _resourceBufferSize;
+    }
+
 }

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheImpl.java
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheImpl.java:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterKeyFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterKeyFactory.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterKeyFactory.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterKeyFactory.java Wed Dec 12 20:02:51 2012
@@ -26,7 +26,7 @@ import org.apache.myfaces.shared.renderk
 /**
  *
  */
-class CounterKeyFactory extends KeyFactory<Integer, String>
+class CounterKeyFactory extends KeyFactory<Integer>
 {
 
     /**

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/CounterSessionViewStorageFactory.java Wed Dec 12 20:02:51 2012
@@ -22,13 +22,11 @@ import javax.faces.context.FacesContext;
 
 /**
  *
- * @author lu4242
  */
-class CounterSessionViewStorageFactory extends SessionViewStorageFactory
-    <KeyFactory<Integer, String>, Integer, String>
+class CounterSessionViewStorageFactory extends SessionViewStorageFactory<KeyFactory<Integer>, Integer>
 {
 
-    public CounterSessionViewStorageFactory(KeyFactory<Integer, String> keyFactory)
+    public CounterSessionViewStorageFactory(KeyFactory<Integer> keyFactory)
     {
         super(keyFactory);
     }

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/KeyFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/KeyFactory.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/KeyFactory.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/KeyFactory.java Wed Dec 12 20:02:51 2012
@@ -23,31 +23,22 @@ import javax.faces.context.FacesContext;
 /**
  *
  */
-abstract class KeyFactory<K, V>
+abstract class KeyFactory<K>
 {
 
     /**
      * Generates a unique key per session
-     *
-     * @param facesContext
-     * @return
      */
     public abstract K generateKey(FacesContext facesContext);
 
     /**
      * Encode a Key into a value that will be used as view state session token
-     *
-     * @param key
-     * @return
      */
-    public abstract V encode(K key);
+    public abstract String encode(K key);
 
     /**
      * Decode a view state session token into a key
-     *
-     * @param value
-     * @return
      */
-    public abstract K decode(V value);
+    public abstract K decode(String value);
     
 }

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomKeyFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomKeyFactory.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomKeyFactory.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomKeyFactory.java Wed Dec 12 20:02:51 2012
@@ -30,7 +30,7 @@ import org.apache.myfaces.shared.util.We
 /**
  *
  */
-class RandomKeyFactory extends KeyFactory<byte[], String>
+class RandomKeyFactory extends KeyFactory<byte[]>
 {
     private final Random random;
     private final int length;
@@ -48,7 +48,7 @@ class RandomKeyFactory extends KeyFactor
     {
         ExternalContext externalContext = facesContext.getExternalContext();
         Object sessionObj = externalContext.getSession(true);
-        Integer sequence = null;
+        Integer sequence;
         synchronized (sessionObj) // are handled at the same time for the session
         {
             Map<String, Object> map = externalContext.getSessionMap();
@@ -102,8 +102,6 @@ class RandomKeyFactory extends KeyFactor
         {
             // Cannot decode, ignore silently, later it will be handled as
             // ViewExpiredException
-            // Cannot decode, ignore silently, later it will be handled as
-            // ViewExpiredException
         }
         return null;
     }

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/RandomSessionViewStorageFactory.java Wed Dec 12 20:02:51 2012
@@ -22,13 +22,11 @@ import javax.faces.context.FacesContext;
 
 /**
  *
- * @author lu4242
  */
-class RandomSessionViewStorageFactory extends SessionViewStorageFactory
-    <KeyFactory<byte[], String>, byte[], String>
+class RandomSessionViewStorageFactory extends SessionViewStorageFactory<KeyFactory<byte[]>, byte[]>
 {
 
-    public RandomSessionViewStorageFactory(KeyFactory<byte[], String> keyFactory)
+    public RandomSessionViewStorageFactory(KeyFactory<byte[]> keyFactory)
     {
         super(keyFactory);
     }

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SecureRandomKeyFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SecureRandomKeyFactory.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SecureRandomKeyFactory.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SecureRandomKeyFactory.java Wed Dec 12 20:02:51 2012
@@ -31,7 +31,7 @@ import org.apache.myfaces.shared.util.We
  * counter ensures uniqueness, and the random number prevents guess the next
  * session token.
  */
-class SecureRandomKeyFactory extends KeyFactory<byte[], String>
+class SecureRandomKeyFactory extends KeyFactory<byte[]>
 {
     private final SessionIdGenerator sessionIdGenerator;
     private final int length;
@@ -71,7 +71,7 @@ class SecureRandomKeyFactory extends Key
     {
         ExternalContext externalContext = facesContext.getExternalContext();
         Object sessionObj = externalContext.getSession(true);
-        Integer sequence = null;
+        Integer sequence;
         synchronized (sessionObj) // are handled at the same time for the session
         {
             Map<String, Object> map = externalContext.getSessionMap();
@@ -124,8 +124,6 @@ class SecureRandomKeyFactory extends Key
         {
             // Cannot decode, ignore silently, later it will be handled as
             // ViewExpiredException
-            // Cannot decode, ignore silently, later it will be handled as
-            // ViewExpiredException
         }
         return null;
     }

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java Wed Dec 12 20:02:51 2012
@@ -260,7 +260,7 @@ class ServerSideStateCacheImpl extends S
     {
       if (state != null)
       {
-          return getKeyFactory(facesContext).decode(state);
+          return getKeyFactory(facesContext).decode((String) state);
       }
       return null;
     }
@@ -424,13 +424,9 @@ class ServerSideStateCacheImpl extends S
                     os.write(UNCOMPRESSED_FLAG);
                 }
 
-                //Object[] stateArray = (Object[]) serializedView;
-
                 ObjectOutputStream out = new ObjectOutputStream(os);
                 
                 out.writeObject(serializedView);
-                //out.writeObject(stateArray[0]);
-                //out.writeObject(stateArray[1]);
                 out.close();
                 baos.close();
 

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionIdGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionIdGenerator.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionIdGenerator.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionIdGenerator.java Wed Dec 12 20:02:51 2012
@@ -30,15 +30,12 @@ import java.util.logging.Logger;
  * NOTE: Class taken from tomcat 7 org.apache.catalina.util.SessionIdGenerator
  * and used here as an alternative for server side state token encryption.
  * 
- * @author Leonardo Uribe
  */
 class SessionIdGenerator
 {
 
     private static Logger log = Logger.getLogger(SessionIdGenerator.class.getName());
-    //private static StringManager sm =
-    //        StringManager.getManager("org.apache.catalina.util");
-    
+
     /**
      * Queue of random number generator objects to be used when creating session
      * identifiers. If the queue is empty when a random number generator is

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionIdGenerator.java
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionIdGenerator.java:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionViewStorageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionViewStorageFactory.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionViewStorageFactory.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/SessionViewStorageFactory.java Wed Dec 12 20:02:51 2012
@@ -24,25 +24,23 @@ import javax.faces.context.FacesContext;
  *
  * @param <T>
  * @param <K>
- * @param <V>
  */
-abstract class SessionViewStorageFactory<T extends KeyFactory<K, V>, K, V>
+abstract class SessionViewStorageFactory<T extends KeyFactory<K>, K>
 {
-    private KeyFactory<K, V> keyFactory;
+    private KeyFactory<K> keyFactory;
 
-    public SessionViewStorageFactory(KeyFactory<K, V> keyFactory)
+    public SessionViewStorageFactory(KeyFactory<K> keyFactory)
     {
         this.keyFactory = keyFactory;
     }
 
-    public KeyFactory<K, V> getKeyFactory()
+    public KeyFactory<K> getKeyFactory()
     {
         return keyFactory;
     }
 
     public abstract SerializedViewCollection createSerializedViewCollection(FacesContext context);
 
-    public abstract SerializedViewKey createSerializedViewKey(
-        FacesContext facesContext, String viewId, K key);
+    public abstract SerializedViewKey createSerializedViewKey(FacesContext facesContext, String viewId, K key);
     
 }

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheFactoryImpl.java
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheFactoryImpl.java:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheUtils.java
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/viewstate/StateCacheUtils.java:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java Wed Dec 12 20:02:51 2012
@@ -49,10 +49,8 @@ import org.apache.myfaces.shared.util.We
  */
 public class HtmlResponseStateManager extends MyfacesResponseStateManager
 {
-    //private static final Log log = LogFactory.getLog(HtmlResponseStateManager.class);
     private static final Logger log = Logger.getLogger(HtmlResponseStateManager.class.getName());
 
-    //private static final int TREE_PARAM = 2;
     private static final int STATE_PARAM = 0;
     private static final int VIEWID_PARAM = 1;
 
@@ -102,7 +100,6 @@ public class HtmlResponseStateManager ex
         
         if (isHandlingStateCachingMechanics(facesContext))
         {
-            //token = getStateCache(facesContext).saveSerializedView(facesContext, state);
             savedStateObject = getStateCache(facesContext).encodeSerializedState(facesContext, state);
         }
         else

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java Wed Dec 12 20:02:51 2012
@@ -171,6 +171,9 @@ public class DefaultFaceletsStateManagem
     private static final Set<VisitHint> VISIT_HINTS = Collections.unmodifiableSet( 
             EnumSet.of(VisitHint.SKIP_ITERATION));
     
+    private static final String UNIQUE_ID_COUNTER_KEY =
+              "oam.view.uniqueIdCounter";
+    
     private ViewDeclarationLanguageFactory _vdlFactory;
     
     private RenderKitFactory _renderKitFactory = null;
@@ -259,8 +262,16 @@ public class DefaultFaceletsStateManagem
                     {
                         view.getAttributes().put(ComponentSupport.FACELET_STATE_INSTANCE,  faceletViewState);
                     }
+                    if (state.length == 3)
+                    {
+                        if (view.getId() == null)
+                        {
+                            view.setId(view.createUniqueId(context, null));
+                        }
+                        //Jump to where the count is
+                        view.getAttributes().put(UNIQUE_ID_COUNTER_KEY, state[2]);
+                    }
                 }
-
                 // TODO: Why is necessary enable event processing?
                 // ANS: On RestoreViewExecutor, setProcessingEvents is called first to false
                 // and then to true when postback. Since we need listeners registered to PostAddToViewEvent
@@ -291,7 +302,6 @@ public class DefaultFaceletsStateManagem
             if (state != null && state[1] != null)
             {
                 states = (Map<String, Object>) state[1];
-                
                 // Visit the children and restore their state.
                 boolean emptyState = false;
                 boolean containsFaceletState = states.containsKey(
@@ -334,137 +344,9 @@ public class DefaultFaceletsStateManagem
                 {
                     view.getAttributes().put(ComponentSupport.FACELET_STATE_INSTANCE,  faceletViewState);
                 }
-                
-                // TODO: handle dynamic add/removes as mandated by the spec.  Not sure how to do handle this yet.
-                List<String> clientIdsRemoved = getClientIdsRemoved(view);
-                
-                if (clientIdsRemoved != null)
-                {
-                    Set<String> idsRemovedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsRemoved.size()));
-                    context.getAttributes().put(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD, Boolean.TRUE);
-                    try
-                    {
-                        // perf: clientIds are ArrayList: see method registerOnAddRemoveList(String)
-                        for (int i = 0, size = clientIdsRemoved.size(); i < size; i++)
-                        {
-                            String clientId = clientIdsRemoved.get(i);
-                            if (!idsRemovedSet.contains(clientId))
-                            {
-                                view.invokeOnComponent(context, clientId, new ContextCallback()
-                                    {
-                                        public void invokeContextCallback(FacesContext context,
-                                                UIComponent target)
-                                        {
-                                            if (target.getParent() != null)
-                                            {
-                                                if (!target.getParent().getChildren().remove(target))
-                                                {
-                                                    String key = null;
-                                                    if (target.getParent().getFacetCount() > 0)
-                                                    {
-                                                        for (Map.Entry<String, UIComponent> entry :
-                                                                target.getParent().getFacets().entrySet())
-                                                        {
-                                                            if (entry.getValue()==target)
-                                                            {
-                                                                key = entry.getKey();
-                                                                break;
-                                                            }
-                                                        }
-                                                    }
-                                                    if (key != null)
-                                                    {
-                                                        target.getParent().getFacets().remove(key);
-                                                    }
-                                                }
-                                            }
-                                        }
-                                    });
-                                idsRemovedSet.add(clientId);
-                            }
-                        }
-                        clientIdsRemoved.clear();
-                        clientIdsRemoved.addAll(idsRemovedSet);
-                    }
-                    finally
-                    {
-                        context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
-                    }
-                }
-                
-                List<String> clientIdsAdded = getClientIdsAdded(view);
-                if (clientIdsAdded != null)
-                {
-                    Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
-                    // perf: clientIds are ArrayList: see method setClientsIdsAdded(String)
-                    for (int i = 0, size = clientIdsAdded.size(); i < size; i++)
-                    {
-                        String clientId = clientIdsAdded.get(i);
-                        if (!idsAddedSet.contains(clientId))
-                        {
-                            final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
-                            if (wrapper != null)
-                            {
-                                final Object[] addedState = (Object[]) wrapper.getWrappedStateObject(); 
-                                if (addedState != null)
-                                {
-                                    if (addedState.length == 2)
-                                    {
-                                        view = (UIViewRoot)
-                                                internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
-                                        view.processRestoreState(context, addedState[1]);
-                                        break;
-                                    }
-                                    else
-                                    {
-                                        final String parentClientId = (String) addedState[0];
-                                        view.invokeOnComponent(context, parentClientId, new ContextCallback()
-                                        {
-                                            public void invokeContextCallback(FacesContext context,
-                                                    UIComponent target)
-                                            {
-                                                if (addedState[1] != null)
-                                                {
-                                                    String facetName = (String) addedState[1];
-                                                    UIComponent child
-                                                            = internalRestoreTreeStructure((TreeStructComponent)
-                                                                                           addedState[3]);
-                                                    child.processRestoreState(context, addedState[4]);
-                                                    target.getFacets().put(facetName,child);
-                                                }
-                                                else
-                                                {
-                                                    Integer childIndex = (Integer) addedState[2];
-                                                    UIComponent child
-                                                            = internalRestoreTreeStructure((TreeStructComponent)
-                                                                                           addedState[3]);
-                                                    child.processRestoreState(context, addedState[4]);
-                                                    try
-                                                    {
-                                                        target.getChildren().add(childIndex, child);
-                                                    }
-                                                    catch (IndexOutOfBoundsException e)
-                                                    {
-                                                        // We can't be sure about where should be this 
-                                                        // item, so just add it. 
-                                                        target.getChildren().add(child);
-                                                    }
-                                                }
-                                            }
-                                        });
-                                    }
-                                }
-                            }
-                            idsAddedSet.add(clientId);
-                        }
-                    }
-                    // Reset this list, because it will be calculated later when the view is being saved
-                    // in the right order, preventing duplicates (see COMPONENT_ADDED_AFTER_BUILD_VIEW for details).
-                    clientIdsAdded.clear();
-                }
+                handleDynamicAddedRemovedComponents(context, view, states);
             }
         }
-        
         // Restore binding, because UIViewRoot.processRestoreState() is never called
         //the event processing has to be enabled because of the restore view event triggers
         //TODO ask the EG the this is a spec violation if we do it that way
@@ -487,6 +369,146 @@ public class DefaultFaceletsStateManagem
         return view;
     }
     
+    public void handleDynamicAddedRemovedComponents(FacesContext context, UIViewRoot view, Map<String, Object> states)
+    {
+        List<String> clientIdsRemoved = getClientIdsRemoved(view);
+
+        if (clientIdsRemoved != null)
+        {
+            Set<String> idsRemovedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsRemoved.size()));
+            context.getAttributes().put(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD, Boolean.TRUE);
+            try
+            {
+                // perf: clientIds are ArrayList: see method registerOnAddRemoveList(String)
+                for (int i = 0, size = clientIdsRemoved.size(); i < size; i++)
+                {
+                    String clientId = clientIdsRemoved.get(i);
+                    if (!idsRemovedSet.contains(clientId))
+                    {
+                        view.invokeOnComponent(context, clientId, new RemoveComponentCallback());
+                        idsRemovedSet.add(clientId);
+                    }
+                }
+                clientIdsRemoved.clear();
+                clientIdsRemoved.addAll(idsRemovedSet);
+            }
+            finally
+            {
+                context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
+            }
+        }
+        List<String> clientIdsAdded = getClientIdsAdded(view);
+        if (clientIdsAdded != null)
+        {
+            Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
+            // perf: clientIds are ArrayList: see method setClientsIdsAdded(String)
+            for (int i = 0, size = clientIdsAdded.size(); i < size; i++)
+            {
+                String clientId = clientIdsAdded.get(i);
+                if (!idsAddedSet.contains(clientId))
+                {
+                    final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
+                    if (wrapper != null)
+                    {
+                        final Object[] addedState = (Object[]) wrapper.getWrappedStateObject(); 
+                        if (addedState != null)
+                        {
+                            if (addedState.length == 2)
+                            {
+                                view = (UIViewRoot)
+                                        internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
+                                view.processRestoreState(context, addedState[1]);
+                                break;
+                            }
+                            else
+                            {
+                                final String parentClientId = (String) addedState[0];
+                                view.invokeOnComponent(context, parentClientId, 
+                                    new AddComponentCallback(addedState));
+                            }
+                        }
+                    }
+                    idsAddedSet.add(clientId);
+                }
+            }
+            // Reset this list, because it will be calculated later when the view is being saved
+            // in the right order, preventing duplicates (see COMPONENT_ADDED_AFTER_BUILD_VIEW for details).
+            clientIdsAdded.clear();
+        }
+    }
+
+    public static class RemoveComponentCallback implements ContextCallback
+    {
+        public void invokeContextCallback(FacesContext context,
+                UIComponent target)
+        {
+            if (target.getParent() != null)
+            {
+                if (!target.getParent().getChildren().remove(target))
+                {
+                    String key = null;
+                    if (target.getParent().getFacetCount() > 0)
+                    {
+                        for (Map.Entry<String, UIComponent> entry :
+                                target.getParent().getFacets().entrySet())
+                        {
+                            if (entry.getValue()==target)
+                            {
+                                key = entry.getKey();
+                                break;
+                            }
+                        }
+                    }
+                    if (key != null)
+                    {
+                        target.getParent().getFacets().remove(key);
+                    }
+                }
+            }
+        }
+    }
+
+    public static class AddComponentCallback implements ContextCallback
+    {
+        private final Object[] addedState;
+        
+        public AddComponentCallback(Object[] addedState)
+        {
+            this.addedState = addedState;
+        }
+        
+        public void invokeContextCallback(FacesContext context,
+                UIComponent target)
+        {
+            if (addedState[1] != null)
+            {
+                String facetName = (String) addedState[1];
+                UIComponent child
+                        = internalRestoreTreeStructure((TreeStructComponent)
+                                                       addedState[3]);
+                child.processRestoreState(context, addedState[4]);
+                target.getFacets().put(facetName,child);
+            }
+            else
+            {
+                Integer childIndex = (Integer) addedState[2];
+                UIComponent child
+                        = internalRestoreTreeStructure((TreeStructComponent)
+                                                       addedState[3]);
+                child.processRestoreState(context, addedState[4]);
+                try
+                {
+                    target.getChildren().add(childIndex, child);
+                }
+                catch (IndexOutOfBoundsException e)
+                {
+                    // We can't be sure about where should be this 
+                    // item, so just add it. 
+                    target.getChildren().add(child);
+                }
+            }
+        }
+    }
 
     @Override
     public Object saveView (FacesContext context)
@@ -578,8 +600,12 @@ public class DefaultFaceletsStateManagem
             
             // As required by ResponseStateManager, the return value is an Object array.  First
             // element is the structure object, second is the state map.
-
-            if (states == null)
+            Long uniqueIdCount = (Long) view.getAttributes().get(UNIQUE_ID_COUNTER_KEY);
+            if (uniqueIdCount != null && !uniqueIdCount.equals(1L))
+            {
+                serializedView = new Object[] { null, states, uniqueIdCount };
+            }
+            else if (states == null)
             {
                 serializedView = EMPTY_STATES;
             }
@@ -703,7 +729,7 @@ public class DefaultFaceletsStateManagem
             component.popComponentFromEL(context);
         }
     }
-    
+
     static List<String> getClientIdsAdded(UIViewRoot root)
     {
         return (List<String>) root.getAttributes().get(CLIENTIDS_ADDED);
@@ -1201,7 +1227,7 @@ public class DefaultFaceletsStateManagem
         }
     }
     
-    private TreeStructComponent internalBuildTreeStructureToSave(UIComponent component)
+    private static TreeStructComponent internalBuildTreeStructureToSave(UIComponent component)
     {
         TreeStructComponent structComp = new TreeStructComponent(component.getClass().getName(),
                                                                  component.getId());
@@ -1248,7 +1274,7 @@ public class DefaultFaceletsStateManagem
         return structComp;
     }
     
-    private UIComponent internalRestoreTreeStructure(TreeStructComponent treeStructComp)
+    private static UIComponent internalRestoreTreeStructure(TreeStructComponent treeStructComp)
     {
         String compClass = treeStructComp.getComponentClass();
         String compId = treeStructComp.getComponentId();

Modified: myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java?rev=1420939&r1=1420938&r2=1420939&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java (original)
+++ myfaces/core/branches/2.1.x-client-window/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java Wed Dec 12 20:02:51 2012
@@ -50,6 +50,8 @@ import javax.faces.view.facelets.Validat
 
 import org.apache.myfaces.util.ExternalSpecifications;
 import org.apache.myfaces.view.facelets.AbstractFaceletContext;
+import org.apache.myfaces.view.facelets.ComponentState;
+import org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy;
 import org.apache.myfaces.view.facelets.FaceletCompositionContext;
 import org.apache.myfaces.view.facelets.tag.MetaRulesetImpl;
 import org.apache.myfaces.view.facelets.tag.jsf.core.AjaxHandler;
@@ -435,6 +437,18 @@ public class ComponentTagHandlerDelegate
                     ComponentSupport.getViewRoot(ctx, c).getAttributes().put("oam.CALL_PRE_DISPOSE_VIEW", Boolean.TRUE);
                     c.subscribeToEvent(PreDisposeViewEvent.class, new ClearBindingValueExpressionListener());
                 }
+                
+                if (c.getChildCount() > 0 || c.getFacetCount() > 0)
+                {
+                    // In this case, this component is used to hold a subtree that is generated
+                    // dynamically. In this case, the best is mark this component to be restored
+                    // fully, because this ensures the state is correctly preserved. Note this
+                    // is only necessary when the component has additional children or facets,
+                    // because those components requires an unique id provided by createUniqueId(),
+                    // and this ensures stability of the generated ids.
+                    c.getAttributes().put(DefaultFaceletsStateManagementStrategy.COMPONENT_ADDED_AFTER_BUILD_VIEW,
+                                          ComponentState.REMOVE_ADD);
+                }
             }
         }
         else

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/main/resources/META-INF/faces-config20.vm
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/main/resources/META-INF/faces-config20.vm:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheTest.java
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheTest.java:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589

Propchange: myfaces/core/branches/2.1.x-client-window/impl/src/test/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheTest.java
------------------------------------------------------------------------------
  Merged /myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheTest.java:r1410540,1410553,1410652,1412781,1412831,1412932,1417719,1418586,1418589



Mime
View raw message