dev@javaserverfaces.java.net

Re: Let's come back to #3241 now

From: zhijun Ren <ren.zhijun_at_oracle.com>
Date: Thu, 09 Oct 2014 10:17:26 +0800

Hi Ed,

As you approved the solution, I just committed the code to 2.2.9.

All the TCs under ./test against glassfish(glassfish, development, true,
client) can be passed.

Please inform me if it need to be ported to 2.3.

BR,
Zhijun



On 9/28/14, 15:44, zhijun Ren wrote:
>
> Hi Ed and Manfred,
>
> Now it's time back to handle JAVASERVERFACES-3241
> <https://java.net/jira/browse/JAVASERVERFACES-3241> now, after several
> round discussions and tests, I still think the following change is
> safe and reasonable:
>
> https://java.net/jira/secure/attachment/53683/changebundle.txt
>
>
> Only need 1 line change:
>
> Index: jsf-api/src/main/java/javax/faces/component/AttachedObjectListHolder.java
> ===================================================================
> --- jsf-api/src/main/java/javax/faces/component/AttachedObjectListHolder.java (revision 13651)
> +++ jsf-api/src/main/java/javax/faces/component/AttachedObjectListHolder.java (working copy)
> @@ -157,7 +157,7 @@
> for (int i = 0, len = attachedObjects.length; i< len; i++) {
> T restored = (T) ((StateHolderSaver) attachedObjects[i]).restore(context);
> if (restored != null) {
> - this.attachedObjects.add(restored);
> + add(restored);
> }
> }
> } else {
>
> The change is in restoreState() and the AttachedObjectListHolder's
> add() method is as following:
>
> / void add(T attachedObject) {
>
> clearInitialState(); *<=== this will make difference with old
> code*
> attachedObjects.add(attachedObject);
>
> }/
>
> The difference is that the initialState is set to false and it changes
> the logic in the saveState() method:
>
> / if (initialState) {
> Object[] attachedObjects = new
> Object[this.attachedObjects.size()];
> boolean stateWritten = false;
> for (int i = 0, len = attachedObjects.length; i < len; i++) {
> T attachedObject = this.attachedObjects.get(i);
> if (attachedObject instanceof StateHolder) {
> StateHolder sh = (StateHolder) attachedObject;
> if (!sh.isTransient()) {
> attachedObjects[i] = sh.saveState(context);
> }
> if (attachedObjects[i] != null) {
> stateWritten = true;
> }
> }
> }
> return ((stateWritten) ? attachedObjects : null);
> } else { *<====== this part will be called since the
> initialState is false*
>
> Object[] attachedObjects = new
> Object[this.attachedObjects.size()];
> for (int i = 0, len = attachedObjects.length; i < len; i++) {
> attachedObjects[i] =
> UIComponentBase.saveAttachedState(context, this.attachedObjects.get(i));
> }
> return (attachedObjects);
> }/
>
> Please review and feedback, if you agree, I will commit code.
>
>
> BR,
> Zhijun
>
>