pretty faces jsf glassfish doesn`t work for me - url

I am using GlassFishV3, JSF2, pretty faces 3
I have tried a lot of combinations of getting rid of my *.xhtml extension o prettify my URL, but I didn`t manage to do so.
Please if you know another solution give me an EXAMPLE of how to do it or if my solution is plausable please tell me were I gone wrong:
I followed the tutorial at http://ocpsoft.org/prettyfaces/ snd created a trivial app with just one index.xhtml and I have put a link to home.xhtml (both are in WebContent).
I have dwl the jar (I don`t use Maven) and I put it in WEB-INF/lib
according to the tutorial I don`t need to change my web.xml because in using GlassFishv3
my web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>extension</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping></web-app>
my pretty-config.xml
<pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.3
http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd ">
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/home.xhtml"/>
</url-mapping> </pretty-config>
with this configuration I keep getting java.lang.StackOverflowError (with others or my app doesn`t compile or I get a different error) the loop is
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:155)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
my index.xhtml works, but when I click on the link the above error appears
I don`t have any beans (another question would be if I have to put any anotations the the maped beans, if I manage to get pretty faces going)
Thank you very much for your time!
The modifications:
I did a trivial web app to see how the hiding of the extension works.
The index.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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"><ui:composition template="">
<ui:define name="header">
Add your header here or delete to use the default
</ui:define>
<ui:define name="content">
<a id="home" href="home.xhtml">Home</a>
</ui:define>
<ui:define name="footer">
Add your footer here or delete to use the default
</ui:define></ui:composition>
and the home.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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="">
<ui:define name="header">
Add your header here or delete to use the default
</ui:define>
<ui:define name="content">
home#######
</ui:define>
<ui:define name="footer">
Add your footer here or delete to use the default
</ui:define>
</ui:composition>
</html>
now if I start the app 127.0.01:8080/myapp there is an error instantly java.lang.StackOverflowError
but if I simply put in index.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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<a id="home" href="home.xhtml">Home</a>
</h:body>
</html>
and in home.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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
HOME
</h:body>
</html>
it works but the extension is prezent
started with 127.0.0.1:8080/myapp/ and then click on the link and 127.0.0.1:8080/myapp/home.xhtml
I want to do it like the first index and home with the template, because I work on a web app that already has templates.
The id="home" in the "a href" tag I dont know if it is necesary, the id its used by CSS to format it, but I am getting desprate :))
Any help would be appreciated. Thank you!
### MODIFICATIONS
so I started again with a trivial web app to see how pretty faces work
now I dont get any errors but I still cant change my URL
what have I done so far:
I put pretty-faces-jsf-3.3.3.jar in WEB-INF/lib
I put in WEB-INF pretty-config.xml
<?xml version="1.0" encoding="UTF-8"?><pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.3
http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/home.xhtml" />
</url-mapping>
my web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>test</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping></web-app>
in WEB-INF I have index.html, home.xhtml and template.xhtml
index.html
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
HOME
</h:body>
</html>
home.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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/tempate.xhtml">
<ui:define name="header">
Add your header here or delete to use the default
</ui:define>
<ui:define name="content">
########################
</ui:define>
<ui:define name="footer">
Add your footer here or delete to use the default
</ui:define>
</ui:composition>
</html>
template.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">
<head>
<title><ui:insert name="title">Default title</ui:insert></title>
</head>
<body>
<div id="header">
<ui:insert name="header">
Header area. See comments below this line in the source.
<!-- include your header file or uncomment the include below and create header.xhtml in this directory -->
<!-- <ui:include src="header.xhtml"/> -->
</ui:insert>
</div>
<div id="content">
<ui:insert name="content">
<ui:include src="home.xhtml" />
</ui:insert>
</div>
<div id="footer">
<ui:insert name="footer">
Footer area. See comments below this line in the source.
<!-- include your header file or uncomment the include below and create footer.xhtml in this directory -->
<!--<ui:include src="footer.xhtml"/> -->
</ui:insert> </div> </body></html>
I didn`t change my web.xml with
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"><filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping></web-app>
because I use Glassfishv3
As I said it is a trivial web app, just to see how it works.
Please help me understand why I have difficulties...

I don't think this problem has anything to do with PrettyFaces. The stacktrace only shows some Facelets related stuff:
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:155)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
I saw that you are using an empty template attribute:
<ui:composition template="">
You page won't work without referencing a base template. I think this could cause the error you are getting.
BTW: You can test PrettyFaces without using Facelets templates. PrettyFaces doesn't known anything about the templates. So if it works without templates, it will also work with templates. :)

Related

<ui:composition template="/template.xhtml"> Invalid path : /template.xhtml

Resource Library Contracts is not working on Weblogic 12.1.1. Wondering is it the version issue? Encounter the below error when try to access c1/index.xhtml
javax.faces.view.facelets.TagAttributeException: //seamnt/prd101/weblogic12_projects/testdomain/servers/testserver/stage/JavaWeb/JavaWeb/c1/index.xhtml #8,48 Invalid path : /template.xhtml
This is the war structure:
WEB-INF/faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.1"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd">
<application>
<resource-library-contracts>
<contract-mapping>
<url-pattern>/c1/*</url-pattern>
<contracts>c1</contracts>
</contract-mapping>
<contract-mapping>
<url-pattern>/c2/*</url-pattern>
<contracts>c2</contracts>
</contract-mapping>
</resource-library-contracts>
</application>
</faces-config>
contracts/c1/template.xhtml
<?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 lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<h:outputStylesheet name="default.css"/>
<title><ui:insert name="title">c1 Template</ui:insert></title>
</h:head>
<h:body styleClass="body">
<h1><ui:insert name="h1">template.xhtml</ui:insert></h1>
<h:graphicImage url="#{resource['duke.handsOnHips.gif']}"
alt="Duke with hands on hips"/>
<ui:insert name="content"/>
</h:body>
</html>
c1/index.xhtml
<?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 lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/template.xhtml">
<ui:define name="title">c1 Index</ui:define>
<ui:define name="h1">index.xhtml</ui:define>
<ui:define name="content">
<h:form>
<div>Name: #{requestScopedBean.name}</div>
<label>Name:
<h:inputText id="username"
title="Name: "
value="#{requestScopedBean.name}"
required="true"
requiredMessage="Error: A name is required."
maxlength="25" />
</label>
<br/>
<h:commandButton id="submit" value="Submit"
action="index" />
<h:commandButton id="reset" value="Reset" type="reset" />
</h:form>
<div class="messagecolor">
<h:messages showSummary="true"
showDetail="false"
errorStyle="color: #d20005"
infoStyle="color: blue"/>
</div>
</ui:define>
</ui:composition>
</html>
Resource library contracts was introduced in JSF 2.2.
You're using only JSF 2.1. This is not only indicated by the fact that you're using version="2.1" in faces-config.xml, but also the fact that WebLogic 12.1.x has JSF 2.1 built-in.
Logically, you've 2 options:
Upgrade to JSF 2.2 (this means, upgrade to WebLogic 12.2.x).
Drop the idea of using resource library contracts. It's a rather useless feature anyway.
Last but not least, make sure your versions match the learning resources and that you catch up the currently available versions. Make sure you learn JSF the right way. Start here.

PrimeFaces: File Upload View Not Updating

I have setup a JSF project using spring security. I am trying to get the FileUpload PrimeFaces to show the selected file after the user finishes browsing to the file.
I am using:
http://www.primefaces.org/showcase/ui/file/upload/single.xhtml
The problem is that after selection of a file nothing is shown in the view and the upload button will not be highlighted. Any help?
I did try the basic file upload and it does update the file name in the view
For basic view
http://www.primefaces.org/showcase/ui/file/upload/basic.xhtml
Could it be FireFox version I use v31.0?
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<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:b="http://bootsfaces.net/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form enctype="multipart/form-data">
<p:growl id="messages" showDetail="true" />
<p:fileUpload value="#{fileUploadController.file}" mode="simple" skinSimple="true"/>
<p:commandButton value="Submit" ajax="false" actionListener="#{fileUploadController.upload}" disabled="false" />
</h:form>
<h:form enctype="multipart/form-data">
<p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}" mode="advanced" dragDropSupport="false"
update="messages" sizeLimit="100000" fileLimit="3" allowTypes="/(\.|\/)(txt|gif|jpe?g|png)$/" />
<p:growl id="messages" showDetail="true" />
</h:form>
</h:body>
</html>
I do have this as well in my web.xml:
<!-- PrimeFaces Client Side Validation -->
<context-param>
<param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
POM:
<!-- PrimeFaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.2</version>
<scope>compile</scope>
</dependency>
I had a similar problem before.
When you define your file upload component, make sure the fileupload component is unique. Get the id from your javaBeans.
Regarding the file name, it is a CSS issue.
If you open your inspector and dig through layers and layers of <tb> tags, you should see the name of your file. Tweak with your CSS to make the name visible.

"Component Not Found for identifier <id>.getParent()" in facelets composite component

I migrated some of my facelets custom components into proper composite components, but encounters the following error while rendering a view that contains the composite component:
javax.faces.view.facelets.TagException: /WEB-INF/taglib/cctest.xhtml #15,26 <composite:interface> Component Not Found for identifier: bodyId.getParent().
at com.sun.faces.facelets.tag.composite.InterfaceHandler.validateComponent(InterfaceHandler.java:135)
at com.sun.faces.facelets.tag.composite.InterfaceHandler.apply(InterfaceHandler.java:125)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:320)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:379)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:326)
at com.sun.faces.facelets.tag.UserTagHandler.apply(UserTagHandler.java:142)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:187)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:188)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:164)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:906)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.jav
In the error message, the name bodyId refers to the id of <h:body> in the file below, and getParent() is hardcoded during the creation of the exception message. #15,26 refers to the end of <composite:interface> in cctest.xhtml below.
Here is the page that contains the composite component:
<?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:f="http://java.sun.com/jsf/core"
xmlns:bam="http://bam.mycompany.com/jsftaglib"
>
<f:view locale="en" id="viewId">
<h:head id="headId">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Title</title>
</h:head>
<h:body id="bodyId">
<bam:cctest value="hello world."/>
</h:body>
</f:view>
</html>
Here is the file named cctest.xhtml that declares the composite component cctest:
<?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:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
>
<h:head>
<title>not used</title>
</h:head>
<h:body>
<composite:interface>
<composite:attribute name="value" required="true"/>
</composite:interface>
<composite:implementation>
<h:outputText id="text_#{cc.attrs.value}" value="#{cc.attrs.value}"/>
</composite:implementation>
</h:body>
</html>
The composite component is declared in a file named bam.taglib.xml located in /WEB-INF/taglib/, next to cctext.xhtml. Here is the file:
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://bam.mycompany.com/jsftaglib</namespace>
<tag>
<tag-name>cctest</tag-name>
<source>cctest.xhtml</source>
</tag>
</facelet-taglib>
I'm using mojarra 2.1.21 into tomcat 7.0.41. My faces-config.xml file is empty, there's no managed beans or other custom-defined components (validator, etc.). Web.xml only declares a few context param, plus the faces servlet mapped on *.xhtml; here are those context parameters:
javax.faces.FACELETS_REFRESH_PERIOD = 1
javax.faces.FACELETS_SKIP_COMMENTS = false
javax.faces.FACELETS_LIBRARIES = /WEB-INF/taglib/bam.taglib.xml
javax.faces.PROJECT_STAGE = Development
javax.faces.VALIDATE_EMPTY_FIELDS = false
javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL = true
Looking at the component tree that is displayed in the facelets error page, there's no element named bodyId, which might be a hint for my issue. A copy of which is displayed below:
<UIViewRoot id="j_id1" inView="true" locale="en" renderKitId="HTML_BASIC" rendered="true" transient="false" viewId="/pages/composite_component_test.xhtml">
<html xmlns="http://www.w3.org/1999/xhtml">
<UIOutput id="headId" inView="true" rendered="true" transient="false">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Title</title>
</UIOutput>
</UIViewRoot>
Many thanks in advance for looking at this issue.
I have seen this type of error occur in Development mode when referencing a component from another component via an include e.g.
<composite:implementation>
<ui:include src="/resources/mycomponents/component1.xhtml" />
</composite:implementation>
Instead one should use appropriate JSF Component referencing syntax
e.g.
<mycomponents:component1/>
Strangely this error doesn't happen if one switches to Production mode and all works fine.

PrimeFaces doesn't work

I have a problem in my NewFile.xhtml. I use jsf2.2.
When I put the library primefaces-3.5.jar into my web/lib folder and restart tomcat server, the web page does not work anymore. When I remove my PrimeFaces jar file every thing works without showing my PrimeFaces tags.
I put the external jar correctly, but I think there is something wrong:
my web.xml file
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Sample JSF 2 Filter login app</display-name>
<!-- Login filter -->
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>somePackage.LoginFilter</filter-class>
</filter>
<!-- Set the login filter to secure all the pages in the /secured/* path of the application -->
<!-- Staring JSF -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- JSF URL mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- By default go to secured welcome page -->
<welcome-file-list>
<welcome-file>NewFile.xhtml</welcome-file>
</welcome-file-list>
</web-app>
my NewFile.xhtml :
<?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:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h1>Hello World PrimeFaces</h1>
<h:form>
<p:editor value="#{editor.value}" />
</h:form>
</h:body>
</html>
As suggested on this post, Primefaces 3.5 does not support JSF 2.2, starting from 4.0 it has been supported.
You should consider a switch to the latest Primefaces release.
Read the documentation for more details: Primefaces User's Guide 3.5

Trinidad with Facelets cause Stackoverflow

I'm in the middle of learning Java EE with Trinidad but ran into some problem. The Trinidad 2.x examples use JSPX while their old demo site use pure JSF (XHTML). When I try to write the a test page using Facelets in XHTML, I kept getting java.lang.stackoverflowerror. I'm not sure if it's a configuration issue or a syntax error.
I'm using Glassfish V3, MySQL 5.6, JSF 2.1 (Apache MyFace) , Apache Trinidad 2.0. And I follow most of this guide: http://jianmingli.com/wp/?p=3813
Stack Trace I omitted the rest of the log because it's too long
java.lang.StackOverflowError
at java.net.URLStreamHandler.equals(URLStreamHandler.java:331)
at java.net.URL.equals(URL.java:862)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:995)
at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:95)
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>jsf2.myfaces2.trinidad2.one</display-name>
<!-- ================= JSF Settings ================= -->
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mappings -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<!-- resource loader servlet -->
<servlet>
<servlet-name>resources</servlet-name>
<servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
</servlet>
<!-- Important: You must include this adf mapping even though you are not
using ADF features. Without this mapping, JSF navigation will fail! -->
<servlet-mapping>
<servlet-name>resources</servlet-name>
<url-pattern>/adf/*</url-pattern>
</servlet-mapping>
<!-- setting the project stage to be DEVELOPMENT -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Use client-side state saving. In Trinidad, it is an optimized, token-based
mechanism that is almost always a better choice than the standard JSF server-side
state saving. -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
<!--param-value> server</param-value -->
</context-param>
<!-- ================= Trinidad Settings ================= -->
<context-param>
<param-name>org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE</param-name>
<param-value>session</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
<param-value></param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name>
<!-- TrinidadFaceletViewHander must be the alternate view handler if SessionChangeManager
is used -->
<param-value>org.apache.myfaces.trinidadinternal.facelets.TrinidadFaceletViewHandler</param-value>
</context-param>
<context-param>
<!--Unfortunately, Facelets provides no hook for plugging the PageResolver
into the logic handling "facelets.VIEW_MAPPINGS". You should leave "facelets.VIEW_MAPPINGS"
unset and use "org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS" instead. -->
<param-name>org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<filter>
<filter-name>trinidad</filter-name>
<filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>trinidad</filter-name>
<servlet-name>faces</servlet-name>
</filter-mapping>
</web-app>
index.xhtml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:trh="http://myfaces.apache.org/trinidad/html"
xmlns:tr="http://myfaces.apache.org/trinidad">
<ui:composition template="" >
<tr:table value="#{userTable.userList}" var="row">
<tr:column>
<f:facet name="header">
<tr:outputText value="User Name" />
</f:facet>
<tr:outputText value="#{row.username}" />
</tr:column>
<tr:column>
<f:facet name="header">
<tr:outputText value="Password" />
</f:facet>
<tr:outputText value="#{row.password}" />
</tr:column>
</tr:table>
</ui:composition>
</html>
index.jspx This works when I configure the "javax.faces.FACELETS_VIEW_MAPPINGS" to *.jspx and omit the Trinidad Facelets specific configuration in web.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:trh="http://myfaces.apache.org/trinidad/html"
xmlns:tr="http://myfaces.apache.org/trinidad">
<f:view>
<tr:document>
<tr:table value="#{userTable.userList}" var="row">
<tr:column>
<f:facet name="header">
<tr:outputText value="User Name" />
</f:facet>
<tr:outputText value="#{row.username}" />
</tr:column>
<tr:column>
<f:facet name="header">
<tr:outputText value="Password" />
</f:facet>
<tr:outputText value="#{row.password}" />
</tr:column>
</tr:table>
</tr:document>
</f:view>
</jsp:root>
The problem is fixed and I believe the ui:composition template="" was the cause of the StackOverFlowError. Once I removed the template="" bit, it worked. In addition, I came across the following in Apache Trinidad's mail archive regarding configuring web.xml for Trinidad 2.0 and Facelet:
You do not need to have an entry for ALTERNATE_VIEW_HANDLER with Trinidad 2.0.
You are getting the error because Trinidad is not yet compatible with
partial state saving in JSF 2.0.
Since partial state saving is enabled by default when Facelets are used,
you need to explicitly disable it.
Add the following context parameter in web.xml:
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>false</param-value>
</context-param>
Link to Apache Trinidad mail post
Trinidad appears to cause a StackOverflowError when you use a relative path to a template in Faceletes. In your case, removing the extraneous template="" attribute from ui:component fixed the issue. In my case, I was actually using templates in my view, so I could not remove the attribute. Instead, I was able to work around the issue by using the absolute path to the template view.
For example, with the following view structure:
/views/template.xhtml
/view/index.xhtml
In index.xhtml, providing a relative path to template.xhtml causes a StackOverflowError:
<f:view
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:include src="template.xhtml" />
</f:view>
Changing to the absolute path of /views/template.xhtml fixes the StackOverflowError:
<f:view
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:include src="/views/template.xhtml" />
</f:view>

Resources