Why doesn't PrimeFaces contentFlow tag work? - jsf

I tried to use primeFaces contentFlow in jsf 2.3 but it doesn't load any images, just it shows me "loading"
the xhtml code is:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
</h:head>
<h:body>
<p:contentFlow value="#{imagesView.images}" var="image">
<p:graphicImage name="demo/images/nature/#{image}" styleClass="content"/>
<div class="caption">#{image}</div>
</p:contentFlow>
...
and after render it appears so:
i tested it on primefaces versions 6.2 to 10. what can be the problem? does it need other libraries or extensions?

Related

ui:insert is not rendering in the main template

After a year gap i have again started working in JSF and facing problem in the facelets usage Below is the maintemplate.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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title><ui:insert name="title" /></title>
</h:head>
<ui:insert name="header" />
<body>
content
</body>
</html>
Below is the ui:composition of the other xhtml file
enter code here
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition 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:p="http://primefaces.org/ui"
template="/index.xhtml">
<ui:define name="title"><h:outputText value="Please Sign In" /></ui:define>
<ui:define name="header"><h:outputText value="Please Sign In" /></ui:define>
</ui:composition>
the same content works with the ui:include but doesn't work with the ui:defin and ui:insert combination
I was using the tags in the wrong way need to include include tag inside the insert to get the correct template functionality

tag calendar in primefaces not display in navigator

i am beginner in jsf and when i use tag calendar it's not display in Navigator and any error appear ; i use eclipce , jsf 2 , primefaces 4
here my code view :
<?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:p="http://primefaces.org/ui">
<h:body>
<h:form>
<p:calendar value="#{ticket.dateCreation}" mode="inline" />
</h:form>
</h:body>
</html>
Since JSF 2.2 you should use the new namespaces:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
You should also include
<h:head>
</h:head>
just below the namespaces so Primefaces can include Javascript/CSS resources.
I hope you're not referring to Netscape Navigator :-)

Page title does not change between pages in JSF

I am using page templates in my application so I am using <ui:composition>, <ui:insert> and <ui:define>. For the title of the pages, I am following the same thing mentioned by BalusC here; but the title remains the same on each page. When I see the page source, the actual title is there. How can it happen that the title bar shows the same title on each page but the page source has the correct page title?
The template page MainTemplate.xhtml:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
<h:head>
<title><ui:insert name="title">Place holder for title</ui:insert>
</title>
</h:head>
<h:body>
</h:body>
</html>
Second template which is using MainTemplate.xhtml -
Template1.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" template="MainTemplate.xhtml">
<ui:define name="body">
<h:outputScript library="script" name="processcript.js" target="head" />
<h:form id="baseForm">
</h:form>
*some layout is defined here*
</ui:define>
</ui:composition>
The page where above template is being used:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
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:pe="http://primefaces.org/ui/extensions"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<head></head>
<h:body>
<ui:composition template="/WEB-INF/templates/Template1.xhtml">
<ui:define name="title">
<h:outputText value="#{myBean.title}"></h:outputText>
</ui:define>
</ui:composition>
</h:body>
</html>

JSF Javascript failure - myfaces not defined

I'm working on a web solution using myfaces and primefaces. We have several pages in our solution, and some of the get this mystical error myfaces not defined because there is a javascript file that is not included on the page, namely the jsf.js file:
<script type="text/javascript" src="/driwkraft-hig/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&stage=Development">
The error occurs when clicking on certain commandlinks on the page, where the generated javascript has been set to onClick="myfaces.oam.submitForm...
Now, I understand that this is something that the JSF framework adds to the page based on some mystical criteria which I fail to understand. There are pages that appear to be equal with regards to what elements are used, and it succeeds on one and fails on the other.
I have tried to create a test-file where I copied content of one of the failing pages and then removed parts until it would work to figure out what was the source of the problem, but this did not give me anything. My next hunch is that it might be some configuration-error somewhere. But I am completely and utterly blank as to where to start.
I understand I should probable add some code or xml in to this question, but I cannot post the entire solution so I think it is best to do so upon request. Would the web.xml be useful? How about the faces-config.xml?
Any guidance and thoughts are much appreciated!
Edit - adding template
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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">
<ui:insert name="metadata" />
<h:head>
....
<title>
<ui:insert name="title">
....
</ui:insert>
</title>
</h:head>
<h:body>
....
<ui:insert name="content">
....
</ui:insert>
...
</h:body>
</html>
Edit - adding template client
<!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:p="http://primefaces.org/ui"
xmlns:dp="http://java.sun.com/jsf/composite/dapsys">
<ui:composition template="/templates/default.xhtml">
<ui:define name="title">TITLE</ui:define>
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="customerId" value="#{CustomerController.customerId}">
</f:viewParam>
<f:viewParam name="edit" value="#{CustomerController.edit}">
</f:viewParam>
<f:viewParam name="activeTab" value="#{CustomerController.activeTab}">
</f:viewParam>
</f:metadata>
</ui:define>
<ui:define name="content">
...
</ui:define>
</ui:composition>
</html>
It's auto-included if there's a <h:head> in the template which automatically renders CSS/JS dependencies from UIViewRoot#getComponentResources() which are added via #ResourceDependency annotation on the JSF component.
Those problem symptoms suggests that there's no <h:head> in the template, but a plain <head>. Therefore JSF is unable to auto-include CSS/JS resource dependencies which in turn causes this JS error.
To fix this problem, just make sure that there's a <h:head> instead of <head> in the template.
<!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">
<h:head> <!-- Look here. -->
<title>Blah</title>
</h:head>
<h:body>
<h1>Blah</h1>
<p>Blah blah.</p>
</h:body>
</html>

Ajax update dataTable from commandButton located in included file

I have such situation situation:
in file form.xhtml i have form used for filter some tables, i gave button "filter" defined here.
in file tableOne.xhtml, tableTwo.html, .. i have dataTable with id "filterTable", i've also included form.xhtml into this page. all pages with dataTables includes form.xhtml and all dataTables on them have the same id "filterTable"
what i want to do is to update dataTable[#filterTable] on after filter button is pressed using ajax. button is created by <p:commandButton>. if form and datatable are defined in the same file, all i need is simply add update="filterTable" to my command bytton. but if i add it to button defined in form.xhtml i get "Cannot find component with identifier" error.
is it possible to dynamic update dataTables from outside xhtml files included on page? if it is, how can i do it?
Example:
test.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"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form id="dtForm">
<p:dataTable id="dataTable" />
</h:form>
<ui:include src="/include.xhtml" />
</h:body>
</html>
include.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"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form>
<p:commandButton value="button" update=":dtForm" />
</h:form>
</h:body>
</html>

Resources