ICEfaces
  1. ICEfaces
  2. ICE-5808

CLONE -ViewScoped call @PostConstruct method on a partial submit

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0-Alpha2
    • Fix Version/s: 2.0-Beta1, 2.0.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      JBoss 6, Windows XP

      Description

      I have a ViewScoped backing bean that has a partial submit on screen component the @PostConstruct method is called when the partial submit is perform; I don't believe that this functionality is correct.

        Activity

        Simon Fryer created issue -
        Hide
        Simon Fryer added a comment -

        Hi, I have replicated the problem with the following code. There are three files below an xhtml, a java and a js file.
        As you can see I call the iceSubmitPartial function manually.

        The postconstruct method is called if a selectInputDate is placed inside a tooltip and poup calendar button is pressed.
        I've also found if you put a displaylistener on a panelTooltip the postconstruct method is called.

        test.xhtml
        [
        <ice:form id="frmIndex1">
        <ice:panelGrid>
        <ice:panelGroup id="divIntelText" onmouseup="setSelectedText();" style="width: 630px; height: 350px; overflow: auto; border-style: solid; border-width: 1px; border-color: #D9D9D9;">
        <f:verbatim>
        #

        {testBean.bodyText}


        </f:verbatim>
        </ice:panelGroup>
        <ice:inputText id="txtSelected"
        value="#

        {testBean.selectedText}

        "
        onchange="iceSubmitPartial( form, this, event);"
        style="display: none" />
        </ice:panelGrid>
        </ice:form>
        ]

        TestBean.java
        [
        import javax.annotation.PostConstruct;
        import javax.faces.bean.ManagedBean;
        import javax.faces.bean.ViewScoped;

        @ManagedBean
        @ViewScoped
        public class TestBean
        {
        private String selectedText;

        private String bodyText = "Hello there";

        @PostConstruct
        public void init()

        { System.out.println("Init"); }

        public String getBodyText()

        { return bodyText; }

        public void setBodyText(String bodyText)
        {
        }

        public void setSelectedText(String selectedText)

        { System.out.println("Selected text is: " + selectedText); }

        public String getSelectedText()

        { return selectedText; }

        }

        ]

        intel.js
        [
        var selectedText;

        // Sets the selected text in the server code.
        function setSelectedText()
        {
        var txt = '';

        if(window.getSelection)

        { txt = window.getSelection(); }

        else if(document.getSelection)

        { txt = document.getSelection(); }

        else if(document.selection)

        { txt = document.selection.createRange().text; }

        txt = new String(txt);

        if(txt.length > 0)

        { selectedText = document.getElementById("frmIndex1:txtSelected"); selectedText.value = txt; selectedText.onchange(); }

        }
        ]

        Show
        Simon Fryer added a comment - Hi, I have replicated the problem with the following code. There are three files below an xhtml, a java and a js file. As you can see I call the iceSubmitPartial function manually. The postconstruct method is called if a selectInputDate is placed inside a tooltip and poup calendar button is pressed. I've also found if you put a displaylistener on a panelTooltip the postconstruct method is called. test.xhtml [ <ice:form id="frmIndex1"> <ice:panelGrid> <ice:panelGroup id="divIntelText" onmouseup="setSelectedText();" style="width: 630px; height: 350px; overflow: auto; border-style: solid; border-width: 1px; border-color: #D9D9D9;"> <f:verbatim> # {testBean.bodyText} </f:verbatim> </ice:panelGroup> <ice:inputText id="txtSelected" value="# {testBean.selectedText} " onchange="iceSubmitPartial( form, this, event);" style="display: none" /> </ice:panelGrid> </ice:form> ] TestBean.java [ import javax.annotation.PostConstruct; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; @ManagedBean @ViewScoped public class TestBean { private String selectedText; private String bodyText = "Hello there"; @PostConstruct public void init() { System.out.println("Init"); } public String getBodyText() { return bodyText; } public void setBodyText(String bodyText) { } public void setSelectedText(String selectedText) { System.out.println("Selected text is: " + selectedText); } public String getSelectedText() { return selectedText; } } ] intel.js [ var selectedText; // Sets the selected text in the server code. function setSelectedText() { var txt = ''; if(window.getSelection) { txt = window.getSelection(); } else if(document.getSelection) { txt = document.getSelection(); } else if(document.selection) { txt = document.selection.createRange().text; } txt = new String(txt); if(txt.length > 0) { selectedText = document.getElementById("frmIndex1:txtSelected"); selectedText.value = txt; selectedText.onchange(); } } ]
        Simon Fryer made changes -
        Field Original Value New Value
        Comment [ Hi, I have replicated the problem with the following code. There are three files below an xhtml, a java and a js file.
        As you can see I call the iceSubmitPartial function manually.

        The postconstruct method is called if a selectInputDate is placed inside a tooltip and poup calendar button is pressed.
        I've also found if you put a displaylistener on a panelTooltip the postconstruct method is called.

        test.xhtml
        [
        <ice:form id="frmIndex1">
        <ice:panelGrid>
        <ice:panelGroup id="divIntelText" onmouseup="setSelectedText();" style="width: 630px; height: 350px; overflow: auto; border-style: solid; border-width: 1px; border-color: #D9D9D9;">
        <f:verbatim>
        #{testBean.bodyText}
        </f:verbatim>
        </ice:panelGroup>
        <ice:inputText id="txtSelected"
        value="#{testBean.selectedText}"
        onchange="iceSubmitPartial( form, this, event);"
        style="display: none" />
        </ice:panelGrid>
            </ice:form>
        ]

        TestBean.java
        [

        import javax.annotation.PostConstruct;
        import javax.faces.bean.ManagedBean;
        import javax.faces.bean.ViewScoped;

        @ManagedBean
        @ViewScoped
        public class TestBean
        {
            private String selectedText;
             
            private String bodyText = "Hello there";

        @PostConstruct
        public void init()
        {
        System.out.println("Init");
        }

        public String getBodyText()
        {
        return bodyText;
        }

        public void setBodyText(String bodyText)
        {
        }

        public void setSelectedText(String selectedText)
        {
        System.out.println("Selected text is: " + selectedText);
        }

        public String getSelectedText()
        {
        return selectedText;
        }
        }

        ]

        intel.js
        [
        var selectedText;

        // Sets the selected text in the server code.
        function setSelectedText()
        {
        var txt = '';

        if(window.getSelection)
        {
        txt = window.getSelection();
        }
        else if(document.getSelection)
        {
        txt = document.getSelection();
        }
        else if(document.selection)
        {
        txt = document.selection.createRange().text;
        }

        txt = new String(txt);

        if(txt.length > 0)
        {
        selectedText = document.getElementById("frmIndex1:txtSelected");
        selectedText.value = txt;
        selectedText.onchange();
        }
        }
        ] ]
        Ken Fyten made changes -
        Salesforce Case []
        Component/s Framework [ 10013 ]
        Component/s Components [ 10012 ]
        Assignee Priority P1
        Hide
        Deryk Sinotte added a comment -

        I've been looking at this issue and have it narrowed down somewhat creating my own simplified test case in the process. Perhaps the reporter can confirm what I've discovered in his tests.

        I can replicate the bean creation but it doesn't appear to use the new bean instances or put them in the the view attribute map. As I click on the button, I can see new view bean instances created and the PostConstruct method called but the Facelets Debug feature doesn't show them added to the view attribute map (just the original view bean is there) and the page also continues to use the bean that was created first.

        The only item that seems to impact this (and why I couldn't replicate it earlier) is the use of the f:verbatim tag. I created two nearly identical pages that differed in only one aspect. One page uses f:verbatim like this:

        with-verbatim.xhtml
        --------------------------

        <ice:form>

        <h2>ICEfaces Compat Test App</h2>

        <ice:panelGroup>
        <f:verbatim> #

        {basic.time} </f:verbatim>
        </ice:panelGroup>

        <ice:panelGroup>
        <ice:outputText value="#{basic.beanHash}"/>
        </ice:panelGroup>

        <ice:panelGrid columns="1">
        <ice:commandButton id="actionButton"
        value="Trigger action listener"
        actionListener="#{basic.updateTime}"/>
        </ice:panelGrid>
        </ice:form>


        And the other just uses an ice:outputText like this:

        with-output.xhtml
        -----------------------

        <ice:form>

        <h2>ICEfaces Compat Test App</h2>

        <ice:panelGroup>
        <ice:outputText value="#{basic.time}

        "/>
        </ice:panelGroup>

        <ice:panelGroup>
        <ice:outputText value="#

        {basic.beanHash}

        "/>
        </ice:panelGroup>

        <ice:panelGrid columns="1">
        <ice:commandButton id="actionButton"
        value="Trigger action listener"
        actionListener="#

        {basic.updateTime}

        "/>
        </ice:panelGrid>

        </ice:form>

        The issue of the extra bean creation only occurs with the page that uses f:verbatim. I'm still investigating why this is the case but it would be helpful if the reporter could confirm this behaviour as well.

        Show
        Deryk Sinotte added a comment - I've been looking at this issue and have it narrowed down somewhat creating my own simplified test case in the process. Perhaps the reporter can confirm what I've discovered in his tests. I can replicate the bean creation but it doesn't appear to use the new bean instances or put them in the the view attribute map. As I click on the button, I can see new view bean instances created and the PostConstruct method called but the Facelets Debug feature doesn't show them added to the view attribute map (just the original view bean is there) and the page also continues to use the bean that was created first. The only item that seems to impact this (and why I couldn't replicate it earlier) is the use of the f:verbatim tag. I created two nearly identical pages that differed in only one aspect. One page uses f:verbatim like this: with-verbatim.xhtml -------------------------- <ice:form> <h2>ICEfaces Compat Test App</h2> <ice:panelGroup> <f:verbatim> # {basic.time} </f:verbatim> </ice:panelGroup> <ice:panelGroup> <ice:outputText value="#{basic.beanHash}"/> </ice:panelGroup> <ice:panelGrid columns="1"> <ice:commandButton id="actionButton" value="Trigger action listener" actionListener="#{basic.updateTime}"/> </ice:panelGrid> </ice:form> And the other just uses an ice:outputText like this: with-output.xhtml ----------------------- <ice:form> <h2>ICEfaces Compat Test App</h2> <ice:panelGroup> <ice:outputText value="#{basic.time} "/> </ice:panelGroup> <ice:panelGroup> <ice:outputText value="# {basic.beanHash} "/> </ice:panelGroup> <ice:panelGrid columns="1"> <ice:commandButton id="actionButton" value="Trigger action listener" actionListener="# {basic.updateTime} "/> </ice:panelGrid> </ice:form> The issue of the extra bean creation only occurs with the page that uses f:verbatim. I'm still investigating why this is the case but it would be helpful if the reporter could confirm this behaviour as well.
        Hide
        Deryk Sinotte added a comment -

        I converted the test case to a stock JSF 2 application (changed all the ice: tags to h: tags and removed the ICEfaces libraries). Mojarra on it's own appears to exhibit the same behaviour so it's not an ICEfaces issue.

        Show
        Deryk Sinotte added a comment - I converted the test case to a stock JSF 2 application (changed all the ice: tags to h: tags and removed the ICEfaces libraries). Mojarra on it's own appears to exhibit the same behaviour so it's not an ICEfaces issue.
        Hide
        Deryk Sinotte added a comment -

        Attaching a .zip file containing a pre-built .war file for Glassfish 3 running JSF 2 as well as the source code for the backing bean.

        Show
        Deryk Sinotte added a comment - Attaching a .zip file containing a pre-built .war file for Glassfish 3 running JSF 2 as well as the source code for the backing bean.
        Deryk Sinotte made changes -
        Attachment verbatim-beans.zip [ 12406 ]
        Hide
        Deryk Sinotte added a comment -

        Resolving as Won't Fix as it appears to be a behaviour associated with JSF itself.

        Show
        Deryk Sinotte added a comment - Resolving as Won't Fix as it appears to be a behaviour associated with JSF itself.
        Deryk Sinotte made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Hide
        Simon Fryer added a comment -

        Hi, thanks for your work on this. I was wondering if you have raised this bug with Sun?

        I have found a workaround by using <ice:outputText escape="false" />

        Thanks again,

        Simon

        Show
        Simon Fryer added a comment - Hi, thanks for your work on this. I was wondering if you have raised this bug with Sun? I have found a workaround by using <ice:outputText escape="false" /> Thanks again, Simon
        Hide
        Deryk Sinotte added a comment -

        I've open a case in Sun's system and attached the test case there as well:

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

        Show
        Deryk Sinotte added a comment - I've open a case in Sun's system and attached the test case there as well: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1706
        Ken Fyten made changes -
        Fix Version/s 2.0.0 [ 10230 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Priority P1

          People

          • Assignee:
            Deryk Sinotte
            Reporter:
            Simon Fryer
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: