Hi,

When developing the AJAX part of MyFaces 2.0 we encountered 2 locations within the jsdoc part of the spec we'd propose for enhancement.

The first is about the hidden inputs for view state: The jsdocs for jsf.ajax.response imply that each hidden input receives the id "javax.faces.ViewState" which would result in multiple hidden inputs with this id in a multi form document. This is how Mojarra is currently working things out, but other implementations should get a chance to use a w3c conformant approach - the hidden inputs don't need ids at all, but only name=javax.faces.ViewState. A comment on this was already posted by Werner Punz.

The second is about replacing the body section of a document if the server sends the id javax.faces.ViewRoot: The jsdocs for jsf.ajax.response say that the impl should >>extract the contents of the <body> element from the <update> element's CDATA content and replace the document's <body> section with this contents<<. According to this the attributes of the body element wouldn't be replaced with the new attributes, which probably isn't the intended behaviour. Preserving the attributes can either be achieved by copying them or by using contextualRagen/adjacentHTML instead of innerHTML.

Here is a proposal for changing the jsdocs for jsf.ajax.response to enable both enhancements mentioned above - please correct the jsdoc for <static> jsf.ajax.response(request, context)
like this:

If an update element is found in the response with the identifier javax.faces.ViewRoot:

<update id="javax.faces.ViewRoot">
   <![CDATA[...]]>
</update>

Update the entire DOM as follows:

* Extract the CDATA content and trim the <html> and </html> from the CDATA content if it is present.

<<<<<<< (remove the following lines)

* If the CDATA content contains a <head> element, and the document has a <head> section, extract the contents of the <head> element from the <update> element's CDATA content and replace the document's <head> section with this contents. * If the CDATA content contains a <body> element, and the document has a <body> section, extract the contents of the <body> element from the <update> element's CDATA content and replace the document's <body> section with this contents.

======= (add the following lines)

* If the CDATA content contains a <head> element, and the document has a <head> section, replace the document's <head> section with the <head> section contained within the CDATA content. * If the CDATA content contains a <body> element, and the document has a <body> section, replace the document's <body> section with the <body> section contained within the CDATA content.

>>>>>>>

* If the CDATA content does not contain a <body> element, replace the document's <body> section with the CDATA contents.

If an update element is found in the response with the identifier
javax.faces.ViewState:

<update id="javax.faces.ViewState">
  <![CDATA[...]]>
</update>

Include this state in the document as follows:

   * Extract this <update> element's CDATA contents from the response.

<<<<<< (remove the following lines)

   * If the document contains an element with the identifier
     javax.faces.ViewState replace its contents with the CDATA
     contents.
   * For each <form> element in the document:
         o If the <form> element contains an <input> element with
           the identifier javax.faces.ViewState, replace the
           <input> element contents with the <update> element's
           CDATA contents.
         o If the <form> element does not contain an element with the
           identifier javax.faces.ViewState, create an <input>
           element of the type hidden, with the identifier
           javax.faces.ViewState, set its contents to the <update>
           element's CDATA contents, and add the <input> element as
           a child to the <form> element.

======= (add the following lines)

   * Set the value of all elements within the document with the name
     javax.faces.ViewState to the CDATA contents
* Perform the following optionally, implementations my omit this to enhance performance, as it enforces a search within the DOM tree. For each <form> element in the document:
         o If the <form> element does not contain an element with the
           name javax.faces.ViewState, create an <input> element of
           the type hidden, with the name javax.faces.ViewState,
           set its value to the <update> element's CDATA contents,
           and add the <input> element as a child to the <form>
           element.



Best Regards,
Ganesh Jung



Reply via email to