I'm trying to use the Primefaces JSF component called contentFlow, which is demonstrated here: http://www.primefaces.org/showcase/ui/multimedia/contentFlow.xhtml
I added two images to the backing bean. They both can be displayed without using contentFlow, so they are available and at the right place. The problem is, that the contentFlow only shows the currently selected image. The expected behaviour is, that it displays all other images, too.
I googled alot and also found the documentation of Primefaces components to verify my XHTML. I also changed the JSF log level to see all debug messages, but JSF keeps telling me that everything is fine.
I've done nothing more than the showcase says, except for the configuration of the project. Here is a summary of my setting:
I'm using Apache Tomcat 8.0.39 on Windows x64
Firefox 50.0.2 and Chrome Version 55.0.2883.75 m (64-bit) are showing the same results (only the currently selected image is visible)
I'm using Java 8
And these are the project's dependencies
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0.RC4</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.14</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.14</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
This is my backing bean:
package de.schuettec.jsfquestion.contentFlow;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
#ManagedBean
public class Images {
private List<String> images;
#PostConstruct
public void init() {
images = new ArrayList<String>();
images.add("img-01.png");
images.add("img-02.png");
}
public List<String> getImages() {
return images;
}
}
This is my XHTML page:
<!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:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<p:contentFlow value="#{images.images}" var="image">
<p:graphicImage name="/images/#{image}" styleClass="content" />
<div class="caption">#{image}</div>
</p:contentFlow>
</h:form>
</h:body>
</html>
I've created a minimal reproducing example, which is available via GitHub here https://github.com/schuettec/jsf-question. This is a full Maven project that reproduces this issue.
I would appreciate if someone of the JSF/Primefaces experts can have a look at this issue. I like JSF and the Primefaces components and really want to understand whats wrong here.
Thank you in advance!
Your code is right. I think it's a bug or a feature.
add 2 pics -> shows 1 pic
add 3 pcis -> shows 3 pics
add 4 pics -> shows 3 pics
add 5 pics -> shows 5 pics
And you can use the final version from primefaces.
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0</version>
</dependency>
Related
Am using Java 1.8, Primefaces 10.0.0 on Tomcat 8.5.55... Am fairly new to JSF UI programming. Have a custom date JSTL tag where I need to dynamically set the maxdate to be 10 years from now when using the calendar widget (p:datePicker) - this is generic so that's why I can't place it inside a custom bean. It needs to be set declaratively inside my input.xhtml file (see below):
pom.xml:
<properties>
<primefaces-version>10.0.0</primefaces-version>
<primefaces-extension-version>10.0.1</primefaces-extension-version>
</properties>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces-version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>${primefaces-extension-version}</version>
</dependency>
input.xhtml (custom taglib located inside ..src/main/webapp/WEB-INF/tags/input.xhtml):
<ui:composition xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:d="http://www.mycompany.com/jsf/facelets"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:datePicker id="#{id}" value="#{bean[property]}" rendered="#{rendered}"
disabled="#{disabled}"
pattern="MM/dd/yyyy"
required="#{required}" requiredMessage="#{requiredMessage}" timeZone="#{timeZone}"
mindate="1/1/2011"
maxdate="#{LocalDate.now().plusYears(10)}"
mask="99/99/9999">
<c:if test="#{not empty event}">
<p:ajax event="#{event}" update="#{update}"/>
<p:ajax event="dateSelect" update="#{update}" oncomplete="#{oncomplete}"/>
</c:if>
</p:datePicker>
</ui:composition>
My mindate works - I can not go before 1/1/2011 in my calendar widget.
But I can go well past 2031 inside my calendar widget.
How can I set the maxdate to 10 years from now only in the input.xhtml file?
I´m having a Problem with the Input Switch of Primefaces and the ajax change event for it. My Setup is following
<p:inputSwitch id="idOfTheSwitch"
style="width: 40px"
value="#{form.booleanWhichGetsChanged}">
<p:ajax listener="#{form.methodWhichShouldGetCalled()}"/>
</p:inputSwitch>
The Problem here is the listener executes the Method in the Beans just once.
public void methodWhichShouldGetCalled() {
// Should do something every time the Input Switch is getting switched.
// Loads filtered Data
}
Versions:
<!-- JSF -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<!-- Primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2.18</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>6.2.10</version>
</dependency>
The Standard event for ajax ist change, isn´t it?
The Name of the Beans and the Method is changed for Stackoverflow.
I am using primefaces 4.0 and I am having problems with p:outputLabel.
When It is mixed with any other primefaces component it behaves like escape="false"
This field is not processed even if I specify escape="true"
Example:
I have the following html code:
<h:form>
<p:outputLabel value="<b>TEXT</b>" escape="true"></p:outputLabel>
<h:outputLabel value="<b>TEXT</b> " escape="true"></h:outputLabel>
</h:form>
And for the Output I have this
<b>TEXT</b> <b>TEXT</b>
Which is expected behavior. (I am willing to see HTML tags as text).
But when I will add any other primefaces tag like in example:
<h:form>
<p:outputLabel value="<b>TEXT</b>" escape="true"></p:outputLabel>
<h:outputLabel value="<b>TEXT</b> " escape="true"></h:outputLabel>
<p:commandButton value="button"></p:commandButton>
</h:form>
Now even I have escape="true" I get
TEXT TEXT and then the button.
Does any one have experience with this how should I fix this.
Any suggestion.
I solved this issue.
I had this into my pom
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.12</version>
</dependency>
I just downgraded to 2.1.11 and everything works fine.
I have seen this bug described in many places but always the causes are different. Post like this one states that the problem of re-instantiation only occurs, when you include a tag handler library on your page. However, I have an empty project with a page like the following
<?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">
<head>
<title></title>
</head>
<body >
<h:form>
<f:view >
<h:commandButton id="otxMainPanelTextBt" value="click"
action="#{otherController.doSome}"/>
</f:view>
</h:form>
</body>
</html>
With the backing bean like this
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
#ManagedBean(name = "otherController")
#ViewScoped
public class Other implements Serializable {
private static final long serialVersionUID = -6493758917750576706L;
public String doSome() {
System.out.println(this);
return "";
}
}
And the following dependences
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.0.2</version>
</dependency>
and every time I click on the button a different object is created. Apparently this page is as simple as possible and I have not triggered any of the possible causes of the bugs, so It always happen or am I missing something?
I tested changing the dependencies to 2.2.0 and it works as expected but unfortunately due to project restrictions, I need to keep the version 2.0.2 of JSF.
Any help would be highly appreciated.
Thanks!!
Actually, I have found that the instance remain the same. The problems was that when clicking the button I always saw different hashCodes printed in the toString of the method like this.
constructing the instance
de.controller.Other#118ea91
de.controller.Other#1e8f930
de.controller.Other#1a38f3c
and this led me to think there were different instances.
Although is the same instance, i believe this behaviour is incorrect because the hashCode of an object is not supposed to change during its lifetime.
My <!DOCTYPE html> declaration is getting removed from my JSF pages, and it's messing things up.
This same question has been asked a bunch of times:
HTML doctype declaration in JSF
DocType is not showing in the rendered output from JSF
JSF template: rendered page missing DOCTYPE
Trouble is, this Jira entry says the bug has been fixed. Apparently not. I'm using the most recent version:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.0-m07</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.0-m07</version>
</dependency>
For reference, here are my pages:
test_layout.xhtml:
<!DOCTYPE html>
<html xmlns:ui="http://java.sun.com/jsf/facelets">
<body>
<ui:insert name="content"/>
</body>
</html>
test_content.xhtml:
<ui:composition
xmlns:ui="http://java.sun.com/jsf/facelets"
template="test_layout.xhtml">
<ui:define name="content">
bunch 'o content
</ui:define>
</ui:composition>
Anybody got a workaround?
I upgraded to 2.2.0-m08 and the problem went away.