Details
-
Type: Bug
-
Status: Closed
-
Priority: Critical
-
Resolution: Fixed
-
Affects Version/s: 3.0, EE-3.0.0.GA, 3.1
-
Fix Version/s: EE-3.0.0.GA_P01, 3.2
-
Labels:None
-
Environment:ICEfaces
Description
While testing the chat-portlet example, I noticed that chat would work only intermittently. The problem looks to be related to how the ViewState element of certain forms is applied/updated/removed. Further testing reveals that it's not specific to portlets. The chat sample that the chat-portlet is based on shows the same issue.
To replicate:
1) Build and deploy the core/chat app to Tomcat
2) Open 1 browser instance (e.g. Firefox) and navigate to the chat application (e.g. http://localhost:8080/chat/ )
3) Enter a handle and login to the chat
4) Open a second browser instance (e.g. Chrome) and navigate to the chat application
5) Enter a handle and login to the chat. At this point, the chat log should show in both browsers that the 2nd user has joined the chat.
6) Return to the first browser, enter a chat message, and click send. The message never gets sent and the chat log does not show any updates.
To replicate:
1) Build and deploy the core/chat app to Tomcat
2) Open 1 browser instance (e.g. Firefox) and navigate to the chat application (e.g. http://localhost:8080/chat/ )
3) Enter a handle and login to the chat
4) Open a second browser instance (e.g. Chrome) and navigate to the chat application
5) Enter a handle and login to the chat. At this point, the chat log should show in both browsers that the 2nd user has joined the chat.
6) Return to the first browser, enter a chat message, and click send. The message never gets sent and the chat log does not show any updates.
I tested back a couple of versions and the behaviour seems to be there in some form since at least the 3.0.0 release. It's manifests slightly differently in that push may stop working and not recover after a page reload. The basics of the issue on the current trunk are:
When the page first loads, we check the ViewStates on the page using the browser's JavaScript console. It correctly reports the proper ViewState element with the right value for each of the 3 forms on the page:
document.getElementsByName('javax.faces.ViewState');
[
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" autocomplete="off">
,
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" autocomplete="off">
,
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" autocomplete="off">
]
After logging in, we check again. The ViewStates are there with the correct values. However, they have been "fixed" by our code and are now missing the id and autocomplete attributes:
document.getElementsByName('javax.faces.ViewState');
[
<input name="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" type="hidden">
,
<input name="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" type="hidden">
,
<input name="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" type="hidden">
]
After logging in from a second browser, the first push is triggered which results in an update with a message saying that a new user has joined. However, as part of this push related update, the ViewState for the client form (not our own hidden forms) is gone. Either removed or not replaced:
document.getElementsByName('javax.faces.ViewState');
[
<input name="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" type="hidden">
,
<input name="javax.faces.ViewState" value="8786015529719486675:6375718628450418134" type="hidden">
]
Any subsequent request from that form now result in a full ViewRoot or ViewBody update since no ViewState was sent with the request:
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewBody"><![CDATA[<body><span id="_t9">.....