You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Martin Koci (JIRA)" <de...@myfaces.apache.org> on 2010/03/09 21:50:27 UTC

[jira] Created: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

Facelets state saving doesn't handle well programmatic component manipulation
-----------------------------------------------------------------------------

                 Key: MYFACES-2594
                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
             Project: MyFaces Core
          Issue Type: Bug
          Components: General
    Affects Versions: 2.0.0-beta-3
         Environment: myfaces trunk
            Reporter: Martin Koci
            Priority: Minor


Simple tests (code pasted below) outputs following results: 

1) JSP: switchs colums at every click with no problem

2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch

3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem

Common code from test.jspx and test.xhtml
... jsp: or facelets stuff  here ...
    <h:form id="form">
       <h:commandButton value="Switch columns">
        <f:actionListener binding="#{testBean}" />
      </h:commandButton>

      <h:dataTable id="table">
        <h:column>
          <f:facet name="header">
            <h:outputText value="firstName" />
          </f:facet>
        </h:column>
        <h:column>
          <f:facet name="header">
            <h:outputText value="surname" />
          </f:facet>
        </h:column>
      </h:dataTable>
     </h:form>

@ManagedBean
@RequestScoped
public class TestBean implements ActionListener {
        public void processAction(ActionEvent event) throws AbortProcessingException {
                FacesContext context  = FacesContext.getCurrentInstance();
                UIComponent table = context.getViewRoot().findComponent("form:table");
                UIComponent column1 = table.getChildren().get(0);
                UIComponent column2 = table.getChildren().get(1);
                table.getChildren().clear();
                table.getChildren().add(column2);
                table.getChildren().add(column1);
        }
}

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843544#action_12843544 ] 

Jakob Korherr commented on MYFACES-2594:
----------------------------------------

Thanks for clarifying this, Martin!

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

Posted by "Martin Koci (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843284#action_12843284 ] 

Martin Koci commented on MYFACES-2594:
--------------------------------------

This problem is the same issue I've reported against mojarra: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1414
Please note that myfaces have problem only in case of PARTIAL_STATE_SAVING=false.

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

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

Leonardo Uribe commented on MYFACES-2594:
-----------------------------------------

At first view, I think the case with PARTIAL_STATE_SAVING=false should work (because the whole tree is saved and restored) and the case with PARTIAL_STATE_SAVING=true should not. We should verify these conditions first.

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

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

Leonardo Uribe commented on MYFACES-2594:
-----------------------------------------

After checking this one, the conclusion was this issue should be closed as won't fix.

Both RI and Myfaces are doing what is expected, or in other words, are doing everything from the view point of the EG.

The effect demostrated by the example is a side effect of apply the facelet after before render response. When we have this cases:

- javax.faces.PARTIAL_STATE_SAVING= false
- javax.faces.PARTIAL_STATE_SAVING=true and org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS=true
- javax.faces.PARTIAL_STATE_SAVING=true and org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS=auto and there is a c:if, c:choose, c:forEach, ui:insert with src=valueexpression on the same facelet.

The bad behavior is presented. The reason is in this configurations the current view is "refreshed" or "updated" by facelets algorithm, to allow components to be added/removed on the tree triggered by a value change on invoke application phase (c:if, c:forEach, c:when ......). In fact, that algorithm "detach" and "attach" all components from the tree, so in that case, is facelets code that detach and "resort" the nodes as originally was on the xml markup. The reason why myfaces works with PSS enabled is that this specific code does not happen in this case, but the drawback is we can't use in this case c:if to trigger tree changes when a value changes on invoke application phase.

In theory, users should not change the components created by facelets or bound by a facelet tag handler. But you can create components programatically and add/remove to the tree, so if you create UIColumn instances inside the h:datatable and try this example, it will work.

I don't think fix facelets algorithm could be possible. Since we cannot advance more on this issue I'll close it as won't fix.

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843290#action_12843290 ] 

Jakob Korherr commented on MYFACES-2594:
----------------------------------------

Mhm. This is caused, because the current state saving mechanism relies on rebuilding the view from the VDL page (.xhtml or .jsp). I also had a problem with this once.

It seems that we somehow have to detect those dynamic tree alterations and also store them in the state to be able to restore them in the next postback. The best thing would be to check for the current lifecycle phase when the children of a component are altered, I think.

Unfortunately I guess the spec does not say anything about this...

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

Posted by "Werner Punz (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843459#action_12843459 ] 

Werner Punz commented on MYFACES-2594:
--------------------------------------

Dont get me wrong here since I am more an outsider on this one, but shouldn´t this be fixable by dragging some kind of child meta information into the delta state, if the user changes something.

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

Posted by "Martin Marinschek (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843489#action_12843489 ] 

Martin Marinschek commented on MYFACES-2594:
--------------------------------------------

Hi guys,

the viewpoint of the EG is that all dynamic changes to the component tree need to be tracked by the state-saving algorithm, if partial state saving is enabled.

So if partial state saving is enabled, you need to hook into the add/remove methods of the component and track the occurring changes.

If partial state saving is not enabled, everything should just work as it used the work as the driving force for the state is then the full state-tree, which was completely saved in the JSF1.2 case anyways.

best regards,

Martin

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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


[jira] Commented: (MYFACES-2594) Facelets state saving doesn't handle well programmatic component manipulation

Posted by "Martin Koci (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843322#action_12843322 ] 

Martin Koci commented on MYFACES-2594:
--------------------------------------

PARTIAL_STATE_SAVING=false: the problem is that switched order of components is never saved. VDL.buildView during Render Response reverts it back. The most suspicious are if -conditons in ComponentTagHandlerDelegate: 
if (facetName == null)
{
  parent.getChildren().remove(c);
}

and 

if (facetName == null)
{
  parent.getChildren().add(c);
}

Result of Render Response is UIData with children=[column1,column2] although after Invoke Application it was children=[column2,column1]

> Facelets state saving doesn't handle well programmatic component manipulation
> -----------------------------------------------------------------------------
>
>                 Key: MYFACES-2594
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2594
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.0-beta-3
>         Environment: myfaces trunk
>            Reporter: Martin Koci
>            Priority: Minor
>
> Simple tests (code pasted below) outputs following results: 
> 1) JSP: switchs colums at every click with no problem
> 2) Facelets with javax.faces.PARTIAL_STATE_SAVING=false - no visual switch
> 3) Facelets with javax.faces.PARTIAL_STATE_SAVING=true switchs colums at every click with no problem
> Common code from test.jspx and test.xhtml
> ... jsp: or facelets stuff  here ...
>     <h:form id="form">
>        <h:commandButton value="Switch columns">
>         <f:actionListener binding="#{testBean}" />
>       </h:commandButton>
>       <h:dataTable id="table">
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="firstName" />
>           </f:facet>
>         </h:column>
>         <h:column>
>           <f:facet name="header">
>             <h:outputText value="surname" />
>           </f:facet>
>         </h:column>
>       </h:dataTable>
>      </h:form>
> @ManagedBean
> @RequestScoped
> public class TestBean implements ActionListener {
>         public void processAction(ActionEvent event) throws AbortProcessingException {
>                 FacesContext context  = FacesContext.getCurrentInstance();
>                 UIComponent table = context.getViewRoot().findComponent("form:table");
>                 UIComponent column1 = table.getChildren().get(0);
>                 UIComponent column2 = table.getChildren().get(1);
>                 table.getChildren().clear();
>                 table.getChildren().add(column2);
>                 table.getChildren().add(column1);
>         }
> }

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