Foros de discusión

Invalid w3c HTML generated

David López, modificado hace 9 años.

Invalid w3c HTML generated

New Member Mensajes: 13 Fecha de incorporación: 11/08/10 Mensajes recientes
Hi all,
We're developing portlets using liferay-faces 3.1.4 ga5 + Primefaces 5.0. An issue has been raised to us and is the fact that the generated HTML is invalid due to repeated <body> tags in our content.
The reason for the repeated tags is the following:

<f:view xmlns="http://www.w3.org/1999/xhtml"
...
xmlns:bridge="http://liferay.com/faces/bridge"
xmlns:p="http://primefaces.org/ui"
>
<h:head></h:head>
<h:body>
<!-- Our content -->
</h:body>
</f:view>

We use the <h:body> tag in each of the portlets we've got. Removing the tag solves the problem but causes the portlets to failed due to resources not loading (CSS, javascript,etc. ).

Is there any way of generating valid HTML from a JSF portlet and leaving untouched the behavior?

Many Thanks
thumbnail
Kyle Joseph Stiemann, modificado hace 9 años.

RE: Invalid w3c HTML generated (Respuesta)

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi David,
It seems like you are experiencing the effects of FACES-1977. Please add this patch jar to your project and see if it fixes the issue.

- Kyle
David López, modificado hace 9 años.

RE: Invalid w3c HTML generated

New Member Mensajes: 13 Fecha de incorporación: 11/08/10 Mensajes recientes
Thanks Kyle,
I tried the patch and it worked!
However and experiencing a similar issue also making invalid the HTML. Now that the body tag is not written in the response, the next issue to tackle is the fact that primefaces is writting the <link> css resources inside the <h:head>.
Generating the following error in the reports: "Element link is missing required attribute property.". Which basically complains about not having the <link> resources in the page <head>.

Do you know if the bridge would be able to write them to the response header? Is there any other way of avoiding them in the portlet response and adding them to the theme?

Best regards
David
thumbnail
Kyle Joseph Stiemann, modificado hace 9 años.

RE: Invalid w3c HTML generated

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
David López:
Thanks Kyle,
I tried the patch and it worked!

Glad I could help!
David López:
However and experiencing a similar issue also making invalid the HTML. Now that the body tag is not written in the response, the next issue to tackle is the fact that primefaces is writting the <link> css resources inside the <h:head>.
Generating the following error in the reports: "Element link is missing required attribute property.". Which basically complains about not having the <link> resources in the page <head>.

Do you know if the bridge would be able to write them to the response header? Is there any other way of avoiding them in the portlet response and adding them to the theme?

I don't think I understand what the issue is. Is primefaces failing to add <link> resources to the <head> section? Or is primefaces adding resources to the <head> section that should not be there? Finally, is there an issue with way that primefaces renders the <link>s themselves (e.g. the <link>s are missing required attributes)?

- Kyle
David López, modificado hace 9 años.

RE: Invalid w3c HTML generated

New Member Mensajes: 13 Fecha de incorporación: 11/08/10 Mensajes recientes
Sorry Kyle, you are right, my explanation was awful.

What I mean is the following:
Given a porltet with a source like:
<!--?xml version="1.0" encoding="UTF-8"?-->
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:aui="http://liferay.com/faces/aui" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:bridge="http://liferay.com/faces/bridge" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ui="http://java.sun.com/jsf/facelets">
	<h:head></h:head>
         ....

</f:view>

Does result in something like:




<div class="content">
...
<div id="myportlet_WAR_myporlet>
<link type=" text css" rel="stylesheet" media="all" href="[b].../[/b]theme.css&amp;_enrollmentportlet_WAR_frontendExternal_ln=primefaces-aristo"></div>
</div>
...



The <link> css will be include once for each of the JSF portlets included in the page.

Apparently the w3c validator does not like the fact that the <link> element is not under the main <head> tag. So, they would like something like


<link type="text/css" rel="stylesheet" media="all" href="[b].../[/b]theme.css&amp;_enrollmentportlet_WAR_frontendExternal_ln=primefaces-aristo">




I hope I have explained this better this time.

Thanks
David
thumbnail
Kyle Joseph Stiemann, modificado hace 9 años.

RE: Invalid w3c HTML generated

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Thanks for the excellent clarification David! We are currently working on a few issues related to primefaces (FACES-1977, FACES-2056, and FACES-2061). I believe that your issue is related to FACES-2061, so I'd recommend watching that issue because we plan on releasing a patch soon (hopefully this week).

- Kyle
thumbnail
Kyle Joseph Stiemann, modificado hace 9 años.

RE: Invalid w3c HTML generated

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi David,
Are you using a runtime portlet (i.e. a portlet which is added to the page dynamically---perhaps in a theme)? If so, you should use the workarounds in the given link.

If you aren't using a runtime portlet, please let us know because we could not reproduce your issue.

- Kyle
David López, modificado hace 9 años.

RE: Invalid w3c HTML generated

New Member Mensajes: 13 Fecha de incorporación: 11/08/10 Mensajes recientes
Hi Kyle,
You're right again. I have an embedded portlet in the page I was trying to validate. It is not embedded in the theme but it is in the particular layout this page is using.
It turns out it is the landing page and it was the first one I was trying to validate without comparing with other pages results.
I have checked the generated source in the other pages and the resources are rewritten to the main <head>.

I'll try the workarounds in the link you mentioned and let you know.

Many thanks
David
David López, modificado hace 9 años.

RE: Invalid w3c HTML generated

New Member Mensajes: 13 Fecha de incorporación: 11/08/10 Mensajes recientes
Hi again,
After looking the workarounds I have decided to refactor my code in a way I don't need to use the runtime portlet. So the problem is gone.

However I've noticed after applying the patch, that the resources links are rewritten to the <head> but the URLs are not being escaped.

While the original URL (without the patch) was:
<link rel="stylesheet" type="text/css" href="http://localhost:8080/web/guest/home?p_p_auth=hS0x4vUF&amp;p_p_id=myportlet_WAR_mywar&amp;p_p_lifecycle=2&amp;p_p_state=normal&amp;p_p_mode=view&amp;p_p_cacheability=cacheLevelPage&amp;p_p_col_id=&amp;p_p_col_count=0&amp;_myportlet_WAR_mywar_javax.faces.resource=primefaces.css&amp;_myportlet_WAR_mywar_ln=primefaces&amp;v=5.0">


The rewritten URL is:
<link rel="stylesheet" type="text/css" href="http://localhost:8080/web/guest/home?p_p_auth=hS0x4vUF&amp;p_p_id=myportlet_WAR_mywar&amp;p_p_lifecycle=2&amp;p_p_state=normal&amp;p_p_mode=view&amp;p_p_cacheability=cacheLevelPage&amp;p_p_col_id=&amp;p_p_col_count=0&amp;_myportlet_WAR_mywar_javax.faces.resource=primefaces.css&amp;_myportlet_WAR_mywar_ln=primefaces&amp;v=5.0">


- The "&amp;" are rewritten directly as "&" something that the w3c validator doesn't like too much. (That also applies to <script> resources)
- Also the tag ending is rewritten as "..></link>" instead of ".. />". Which the w3c validator doesn't like either.

Is that a know issue?
Regards
David
David López, modificado hace 9 años.

RE: Invalid w3c HTML generated

New Member Mensajes: 13 Fecha de incorporación: 11/08/10 Mensajes recientes
I've managed to sort out the first of the issues.
David López:

- The "&amp;" are rewritten directly as "&" something that the w3c validator doesn't like too much. (That also applies to <script> resources)
- Also the tag ending is rewritten as "..></link>" instead of ".. />". Which the w3c validator doesn't like either.


The issue appears to be related to one of my portlets included in the page without the <h:head></h:head> tag on it. Added the tag and now the problems seems to be sorted.

Although the second one is still happening.

Cheers
David
thumbnail
Neil Griffin, modificado hace 9 años.

RE: Invalid w3c HTML generated

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi David,

Thanks for letting us know about the problem regarding the URLs with non-escaped ampersand characters. We were able to reproduce the issue and determined that it is a bug in Liferay Faces Bridge. For more information, see FACES-2075.

Kind Regards,

Neil
David López, modificado hace 9 años.

RE: Invalid w3c HTML generated

New Member Mensajes: 13 Fecha de incorporación: 11/08/10 Mensajes recientes
Many thanks Neil,
I'll be alert to update my bridge version.

Regards
David
thumbnail
Neil Griffin, modificado hace 9 años.

RE: Invalid w3c HTML generated (Respuesta)

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
David López:
Also the tag ending is rewritten as "..></link>" instead of ".. />". Which the w3c validator doesn't like either.


Thanks for reporting the problem with the closing </link> tag. We were able to reproduce the bug and created FACES-2076 in order to track the issue to closure.