You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2010/01/12 18:51:54 UTC

[jira] Created: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Find a way to allow c:if work with partial state saving enabled
---------------------------------------------------------------

                 Key: MYFACES-2483
                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
             Project: MyFaces Core
          Issue Type: Task
          Components: JSR-314
            Reporter: Leonardo Uribe


This one is difficult to solve but I still think it is possible.

It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408

and

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313

One strategy to solve this one is this:

1. Mark the parent component containing c:if to not save it partially.
2. Do not execute c:if on postback and partial state saving enabled.

In theory, the parent component should be restored fully from saved state.

Note that things like:

<c:if>....
   <p>Some markup</p>
<c:if>

is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801662#action_12801662 ] 

Leonardo Uribe commented on MYFACES-2483:
-----------------------------------------

Provided first prototype for this issue. It works but still is pending solve interaction of c:if and cc:insertFacet, and do some more tests and cleanup to commit it.

The strategy proposed to solve this issue works, but it has some details to be addressed.

We have to put again the code removed on MYFACES-2389 clean up the UIComponentBase.setParent() (PostBuildComponentTreeOnRestoreViewEvent), because we need to relocate transient components filled on render response phase components.

If we use PostAddToViewEvent for trigger it, some components are not removed correctly from tree and cause duplicate id exception, because facelets detach and attach all components from tree.

We have to test ComponentHandler.isNew() method. This method has sense only if we solve this issue, and we have to deal with composite components correctly.

Use transient listeners for cc:insertChildren and cc:insertFacet are a bad idea. The reason is if partial state saving is not used, the refresh algorithm will not work, because after first request the listener is lost.

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>         Attachments: fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe updated MYFACES-2483:
------------------------------------

    Status: Open  (was: Patch Available)

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>         Attachments: fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved MYFACES-2483.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0-beta-2

That one was hard to solve!

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.0-beta-2
>
>         Attachments: fixPSSIf2009JAN-10.patch, fixPSSIf2009JAN-11.patch, fixPSSIf2009JAN-14.patch, fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806767#action_12806767 ] 

Leonardo Uribe commented on MYFACES-2483:
-----------------------------------------

Attached the final patch for this feature (fixPSSIf2009JAN-14.patch). I removed the listener used to register components to be restored fully, and it was replaced by doing that when the component is saved. Other minor updates to the algorithm has been done.

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>         Attachments: fixPSSIf2009JAN-10.patch, fixPSSIf2009JAN-11.patch, fixPSSIf2009JAN-14.patch, fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801677#action_12801677 ] 

Leonardo Uribe commented on MYFACES-2483:
-----------------------------------------

The change committed on MYFACES-2488 requires change the way it is detected when we are "updating" a view.

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>         Attachments: fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe updated MYFACES-2483:
------------------------------------

    Status: Patch Available  (was: Open)

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>         Attachments: fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved MYFACES-2483.
-------------------------------------

    Resolution: Fixed

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.0-beta-2
>
>         Attachments: fixPSSIf2009JAN-10.patch, fixPSSIf2009JAN-11.patch, fixPSSIf2009JAN-14.patch, fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806226#action_12806226 ] 

Leonardo Uribe commented on MYFACES-2483:
-----------------------------------------

Provided another prototype. It works but still is pending how to deal with c:if inside UIViewRoot directly and how to remove PostBuildComponentTreeOnRestoreViewEvent, to enhance compatibility.

The strategy applied is:

1. Mark the parent component containing c:if or any tag that causes component addition based on the application model to not save it partially. 
2. Handle the changes for composite:insertChildren/composite:insertFacet using the algorithm on MYFACES-2502
3. At the end of apply the facelet in vdl.buildView, do not force publish PreRemoveFromViewEvent - PostAddToViewEvent, instead use PostBuildComponentTreeOnRestoreViewEvent (Maybe we have to change this name to something more descriptive). This is necessary because otherwise the listener DefaultFaceletsStateManagementStrategy.PostAddPreRemoveFromViewListener register all components to be saved and restored.

The idea is create a param called org.apache.myfaces.PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS.

This param only works when partial state saving is enabled. If we do the example proposed in MYFACES-2502, the algorithm when this param is true will be:
 
 First Request:

 - There is a call to ViewDeclarationLanguage.buildView from RenderResponseExecutor.execute that cause the UIViewRoot instance to be filled for first time calling to f.apply().
 - The view is rendered.
 - Save the state for all non transient components found on the view that has delta or was added after build. This does not include the structure, because all state is just saved on a big Map<String,Object> where the keys are the clientId for each component.

 Postback (The user send his name and do a submit):

 - StateManagementStrategy.restoreView calls ViewDeclarationLanguage.buildView passing an empty UIViewRoot to be filled for first time calling to f.apply().
 - Restore the component state for all saved components. Note the tree structure now is already provided.
 - All lifecycle phases continues until before renderView
 - On RenderResponseExecutor.execute there is a call to buildView, and this one causes all transient components like facelets UIInstructions to be added to the tree. ComponentHandler first try to detect if the component is on the view before create it, and if that is true do not create it, instead it takes this instance and continue apply the taghandles and it remove and add it from tree, to give the chance to other transient components to be created and added correctly.
 - The view is rendered.
 - Save the state for all non transient components found on the view that has delta or was added after build. This does not include the structure, because all state is just saved on a big Map<String,Object> where the keys are the clientId for each component. 



> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>         Attachments: fixPSSIf2009JAN-10.patch, fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe reopened MYFACES-2483:
-------------------------------------


Just as a reference note, I moved and renamed the param org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS to MyfacesConfig class on shared.

Playing a little with partial state saving algorithm, and re-reading the arguments about this problem, it was found that in most cases (c:if toogle) it is not necessary to restore the tree exactly like it was on the latest request, or in other words should remain stable between requests. The advantage is this is faster and state is smaller.

Anyway, it is possible to find cases where the state should be preserved, so I'll introduce another param called org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE by default false. If this is set as true, parent components containing  c:if, c:forEach, c:choose and ui:insert with src=ELExpression are marked to be restored fully.

It is still pending how to prevent addition / removal of h:outputScript / h:outputStylesheet. Right now, on every request, duplicate instances of h:outputScript / h:outputStylesheet are silently removed by UIViewRoot.addComponentResource(FacesContext, UIComponent, String). Maybe we should try use an interface for tag handlers called RelocatableComponent and update ComponentTagHandlerDelegate to "redirect" ComponentSupport.findChildByTagId and try to found instances on UIViewRoot facets "head" and "body", but resource instances are "inmutable", in other words, there is no use case where a resource instance changes its inner state after added to the tree.

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.0-beta-2
>
>         Attachments: fixPSSIf2009JAN-10.patch, fixPSSIf2009JAN-11.patch, fixPSSIf2009JAN-14.patch, fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2483) Find a way to allow c:if work with partial state saving enabled

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806589#action_12806589 ] 

Leonardo Uribe commented on MYFACES-2483:
-----------------------------------------

Attached another patch ( fixPSSIf2009JAN-11.patch ) It has solved the two previous goals:

1. how to remove PostBuildComponentTreeOnRestoreViewEvent (Disabling register listener)
2. how to deal with c:if inside UIViewRoot directly (Save the view fully)

It was notice before save an added/removed branch it is necessary to call clearInitialState on all children. After multiple attempts, it was clear the only way to ensure this condition is before save view.

Thinking about this stuff, it could be good to have this states for org.apache.myfaces.PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS  for:

- true: Refresh transient view on partial state saving enabled for all views
- auto: If in a view the user uses c:if, c:forEach, c:choose, or ui:include with src using ValueExpression (maybe this is a good moment to think other conditions), the view is marked to be refreshed later, to prevent the call to setFilledView in buildView later and force refreshView on render response phase.
- false: No view is refreshed.

I have to check other conditions that could trigger component addition/removal and makes pss fail before commit, but I hope do it soon.

> Find a way to allow c:if work with partial state saving enabled
> ---------------------------------------------------------------
>
>                 Key: MYFACES-2483
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2483
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: JSR-314
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>         Attachments: fixPSSIf2009JAN-10.patch, fixPSSIf2009JAN-11.patch, fixPSSIf2009JAN-7.patch
>
>
> This one is difficult to solve but I still think it is possible.
> It was explored trying to solve MYFACES-2428, and it seems ri is trying to do something about it too on:
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1408
> and
> https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1313
> One strategy to solve this one is this:
> 1. Mark the parent component containing c:if to not save it partially.
> 2. Do not execute c:if on postback and partial state saving enabled.
> In theory, the parent component should be restored fully from saved state.
> Note that things like:
> <c:if>....
>    <p>Some markup</p>
> <c:if>
> is just invalid. It is expected that c:if only contains components with state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.