Repeat partial requests are treated as postback, because of absent/removed 
client-side ViewState
------------------------------------------------------------------------------------------------

                 Key: TRINIDAD-1685
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1685
             Project: MyFaces Trinidad
          Issue Type: New Feature
          Components: Components
    Affects Versions: 2.0.0.1-core 
         Environment: Windows 7
            Reporter: Pavitra Subramaniam


I noticed a change in JSF 2 related to sending the ViewState to the client and 
wanted to log this issue with my findings and propose possible solutions.

1. In JSF 1.2, the viewstate (either the client token or the full client-side 
state) was always sent as part of every request and this was happening in 2 
places:
  - In FormRenderer, as part of the _renderPostscriptElement method, a <span> 
element with the postscript Id is generated and inside it a placeholder 
('marker') for the JSF state is set.
  - Later at the end of renderView in ViewHandler, 'writeState()' gets called 
which retrieves the real state, replaces the 'marker' with this value. So that 
we get something like (for the token case),

  <fragment>
    <![CDATA[<span id="tr_j_id_jsp_323026082_2_Postscript">
      <input type="hidden" name="javax.faces.ViewState" value="!1bja7345nw">
      <input type="hidden" name="source"></span>]]>
  </fragment>

2. In JSF 2.0, this appears to have changed. One, we have a new 
'MultiViewHandler.java', whose writeState() method does not write any state if 
it's an 'ajax' request. Secondly, since we generate the postscript element for 
all requests (including PPR) in the FormRenderer, we end up sending something 
like this to the client,

<update>
  <![CDATA[<span id="tr_j_id_jsp_323026082_2_Postscript">
  <input type="hidden" name="source"></span>]]>
</update>

The above response (using the jsf.ajax.response handler), wipes out the 
ViewState stored in the client. So subsequent PPR requests end up not being 
treated as postbacks.

REMARKS:
a. It's not clear to me if it's ok for the ViewState (token or full) to not get 
sent for partial requests on the same view.

b. If a. is true, then do we need to revisit how we send ViewState (as part of 
the FormRenderer 'postscript' element)? 

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

Reply via email to