When using MyFaces 2.1, with Eclipse Juno, how do I get rid of a space after the doctype - jsf

I have searched all around for an answer, and tried many things, but no luck. When I use MyFaces 2.1 with Eclipse Juno, and attempt to create an HTML5 page, I get
<!DOCTYTPE html >
Notice the space after the "html". When this page is viewed in FireFox, using HTML Tidy, it throws an error saying its an invalid doctype.
The source xhtml file contains with no space. Does anyone have a solution?
Thanks
Dan

I can reproduce it in at least MyFaces 2.1.9 and 2.1.10 (didn't tried older versions). This problem doesn't manifest in Mojarra. It's undoubtedly a bug in MyFaces. I recommend to report it to MyFaces guys.
For the meantime until they get it fixed, I found a workaround. Replace <!DOCTYPE>
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
...
</html>
by <h:doctype>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:doctype rootElement="html" />
<html lang="en">
...
</html>
</ui:composition>
Its renderer generates the proper space-less doctype.
This problem is in no way related to Eclipse. It's just a tool like Notepad.

Related

ui:include includes wrong file in JSF 2.2

Accorrding to the documentation of ui:include tag
Use this tag—which is very similar to JSP's jsp:include—to encapsulate
and reuse content among multiple XHTML pages. There are three things
this tag can include: plain XHTML, and XHTML pages that have either a
composition tag or a component tag.
You supply a filename, through ui:include's src attribute for JSF to
include. That filename is relative to the XHTML file that was rendered
as a result of the last request. So, for example, if JSF loaded the
view login.xhtml, and that file included pageDecorations/header.xhtml,
and pageDecorations/header.xhtml included companyLogo.xhtml, then
companyLogo.xhtml will not be found if it's in the pageDecorations
directory, because companyLogo.xhtml has to be in the same directory
as login.xhtml.
I created a simple test:
webapp/login.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:body>
<ui:include src="pageDecorations/header.xhtml" />
</h:body>
</html>
webapp/pageDecorations/header.xhtml
<ui:include
src="logo.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
/>
webapp/pageDecorations/logo.xhtml
<h:outputText
value="Logo in /pageDecorations"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
/>
webapp/logo.xhtml
<h:outputText value="Logo in /"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
/>
When I ran this test (loaded login.xhtml page) using JSF 2.2 on WildFly 10.1 , I got Logo in /pageDecorations, while according to the documentation it should be: Logo in /
What is wrong ? Is there a bug in the documentation or Mojarra implementation ? Or my understanding is wrong ?
First, you are inside webapp/ and executing webapp/login.xhtml
inside that you get src="pageDecorations/header.xhtml" and for exectuing that you are in pageDecorations and from header.xhtml you are tring to find src="logo.xhtml" which will you get in the same directory (pageDecorations) so it will print
"Logo in /pageDecorations" .
Document looks wrong in this case.

When I try to use <rich:columns> my data table is not getting rendered

I am not able to use <rich:columns> in my project. Following is my project config.
Dynamic Web module - 3.0
Java - 1.6
JavaScript - 1.0
JavaServer Faces - 2.0
I have the following RichFaces jar files.
richfaces-components-api-4.3.7.jar
richfaces-components-ui-4.3.7.jar
richfaces-core-api-4.3.7.jar
richfaces-core-impl-4.3.7.jar
In my Facelet I have the following code.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
When I try to use <rich:columns> my data table is not getting rendered.
I'm not sure where I am missing.

JSF/ Javascript error

I have developed a JSF 2.0 application in Netbeans IDE which is working correctly in my browser but when I deployed it on client side , it is giving me error: PRIMEFACES IS UNDEFINED
Does anyone have idea about the error? Any help will be highly appreciated. Thanks!
If you didnt have a head tag you will get that error.
You need to add the PrimeFaces namespace at the head tag.
xmlns:p="http://primefaces.org/ui"
Your xhtml page should like this-
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:spinner />
</h:body>
</html>
Please have a look at PrimeFAQ #2 and PrimeStartGuide.

PrimeFaces components don't appear in browser

I'm using JSF 2.2 in my Project (Tomcat 7.42, Mojarra 2.2.1), and i want to use p:calendar from PrimeFaces library. I have included primefaces-4.0.jar into my Project Libraries, and add xmlns:p="http://primefaces.org/ui" namespace, and everything looks ok. Here is my code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:body>
<p:calendar value="#{calendarBean.date2}" id="popupCal" />
</h:body>
</html>
But, in browser, calendar doesn't appear. Standard h: components work great, but from PrimeFaces - nothing works.
I know that PF 4.0 should support JSF 2.2, but i have some issue.
I appreciate any help?
In jsf 2.2 namespaces are changed so you shoud use xmlns.jcp.org instead of java.sun.com
I managed to solve the problem! I am really sorry, but a PrimeFaces' "Getting Started" really confused me. The problem is that I had added PrimeFaces as a library into build path of my project, which is not correct. The right way is to put primefaces-4.0.jar into lib folder under web project. Things are better now. Anyway, thanks people.

IE9 rendering IE8 document standard

I need my application to run in IE9 document standard and I cannot figure out why it automatically renders in IE8 document standard.
I'm using JSF 2.1.17 and Primefaces 3.4, running in Glassfish 3.1.2. My IDE is Netbeans-7.1.2. When I open the developer tools in IE, under the "HTML" tab it shows:
<--!DOCTYPE html-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
However, under the "Script" tab it shows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML lang=en xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<HEAD>
<META content="IE=8.0000" http-equiv="X-UA-Compatible">
I have looked through all my pages and templates and NO WHERE can I find the meta content="IE=8.0000" or the !DOCTYPE that is shown above. It is very odd.
All my pages have:
<!DOCTYPE html>
My main template has this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
Other pages have:
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="/layout/someFile.xhtml" >
Here are the things I have tried:
1) Updated the Glassfish JSF to 2.1.17, since I read that there was a bug with older versions of Mojarra that caused it to ignore the DOCTYPE.
2) I added:
<meta http-equiv="X-UA-Compatible" content="IE=9" >
to every page, hoping it would enforce IE9, but this did not work.
3) I then tried using content="IE=Edge", still no changes.
4) I changed my DOCTYPE to:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
unsure if XHTML needed this strict DOCTYPE to render properly. But this did not work.
Any help would be great. I have done a lot of research trying to sort this out, however I am new to web development, so I my understanding is quite limited.
I added:
<meta http-equiv="X-UA-Compatible" content="IE=9" >
to every page, hoping it would enforce IE9, but this did not work.
According to the MSDN document on this meta tag,
The X-UA-Compatible header isn't case sensitive; however, it must appear in the header of the webpage (the HEAD section) before all other elements except for the title element and other meta elements.
this must appear before all other elements expect for <title> and other <meta> elements. If you investigate the JSF/PrimeFaces-generated HTML closely, you'll see that there's a PrimeFaces specific <link> element before that which would block the X-UA-Compatible header from doing its job.
PrimeFaces supports several facets for the <h:head> so that you can control the ordering of the head resources. The following should do it for you:
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=9" />
</f:facet>
Again, this is specific to PrimeFaces, not to standard JSF.

Resources