PrimeFaces LazyDataModel#load() method not invoked anymore after adding OmniFaces - jsf

PrimeFaces LazyDataModel worked before adding OmniFaces jar into pom.xml.
It invokes load() method of LazyDataModel.
LazyPostDataModel.java
public class LazyPostDataModel extends LazyDataModel<Post> {
private PostService postService;
private PostCriteria postCriteria;
public LazyPostDataModel(PostService postService, PostCriteria postCriteria) {
this.postCriteria = postCriteria;
this.postService = postService;
}
#Override
public List<Post> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,Object> filters) {
//other process
}
}
I just add the following dependency into pom.xml for OmniFaces. It does not invoke load() method .
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.2</version>
</dependency>
post.xhtml
<h:form id="postTableForm">
<p:inputText value="#{ManagePostActionBean.postCriteria.name}"/>
<p:commandButton value="Search" action="#{ManagePostActionBean.search}" update="postTable"/>
<p:outputPanel id="listPanel">
<p:dataTable var="post" value="#{ManagePostActionBean.postDataModel}" id="postTable"
paginator="true" style="width:100%;" lazy="true"
rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10, 20, 30, 40, 50, 100" rowIndexVar="index">
<p:column headerText="No" style="width:50px;">
<h:outputText value="#{index + 1}" />
</p:column>
<p:column headerText="Name">
<h:outputText value="#{post.name}" />
</p:column>
<p:column headerText="Description">
<h:outputText value="#{post.description}" />
</p:column>
</p:dataTable>
</p:outputPanel>
</h:form>
ManagePostActionBean.java
#Named(value = "ManagePostActionBean")
#ViewScoped
public class ManagePostActionBean {
#Inject
private PostService postService;
private LazyDataModel<Post> postDataModel;
private PostCriteria postCriteria;
public void onLoad() {
System.out.println("ManagePostActionBean Init....");
postCriteria = new PostCriteria();
postDataModel = new LazyPostDataModel(postService, postCriteria);
}
public LazyDataModel<Post> getPostDataModel() {
return postDataModel;
}
public PostCriteria getPostCriteria() {
return postCriteria;
}
public void setPostCriteria(PostCriteria postCriteria) {
this.postCriteria = postCriteria;
}
public void search() {
resetPagination();
postDataModel = new LazyPostDataModel(postService, postCriteria);
}
}
my environment is
JSF 2.2
Primefaces 5.0
JDK 1.7
apache-tomee-webprofile-1.7.3 (TomEE)
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mutu</groupId>
<artifactId>spring-primefaces</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.8-02</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.8-02</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.10</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>green-cool</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.8</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>

You're using TomEE 1.x, which ships with JSF 2.1 (Apache MyFaces).
OmniFaces 2.2 requires JSF 2.2.
You have 2 options:
Downgrade to OmniFaces 2.1. Even though OmniFaces 2.x officially requires JSF 2.2, OmniFaces versions 2.0 and 2.1 do not have deploy time JSF 2.2 dependencies. OmniFaces version 2.2 was with <o:viewAction> tag the first version to require JSF 2.2 during deploy time.
Upgrade to TomEE 7.x, the first version to implement Java EE 7 and thus inherently JSF 2.2. It's currently only available as M1 release. Final release is expected within months.

Related

TextEditor component is marked secure='true' but the HTML Sanitizer was not found on the classpath

Error message:
TextEditor component is marked secure='true' but the HTML Sanitizer was not found on the classpath. Either add the HTML sanitizer to the classpath per the documentation or mark secure='false' if you would like to use the component without the sanitizer.
This is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jsf</groupId>
<artifactId>showcase</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>showcase</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>8.0.RC3</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-shaded</artifactId>
<version>3.1.3.Final</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>8.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.faces</artifactId>
<version>2.3.14</version>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
</plugins>
</build>
</project>
textEditor.xhtml:
<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">
<h:head>
<h:outputStylesheet name="primeicons/primeicons.css" library="primefaces"/>
</h:head>
<h:body>
<h:form>
<h3 style="margin-top:0">Basic</h3>
<p:textEditor widgetVar="editor1" value="#{editorView.text}" height="300" style="margin-bottom:10px"/>
<p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()" icon="pi pi-save" />
<p:commandButton value="Clear" type="button" onclick="PF('editor1').clear();" icon="pi pi-times" />
<h3 class="first">Custom Toolbar</h3>
<p:textEditor widgetVar="editor2" value="#{editorView.text2}" height="300" style="margin-bottom:10px" placeholder="Enter your content">
<f:facet name="toolbar">
<span class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-strike"></button>
</span>
<span class="ql-formats">
<select class="ql-font"></select>
<select class="ql-size"></select>
</span>
</f:facet>
</p:textEditor>
<p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()" icon="pi pi-save" />
<p:commandButton value="Clear" type="button" onclick="PF('editor2').clear();" icon="pi pi-times" />
<p:dialog header="Content" widgetVar="dlg" showEffect="fade" hideEffect="fade">
<p:outputPanel id="display">
<h3 style="margin-top:0">Basic</h3>
<h:outputText value="#{editorView.text}" escape="false" />
<h3>Custom</h3>
<h:outputText value="#{editorView.text2}" escape="false" />
</p:outputPanel>
</p:dialog>
</h:form>
</h:body>
</html>
EditorView.java
package com.jsf.showcase.view.input;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import lombok.Getter;
import lombok.Setter;
#Getter #Setter
#Named
#RequestScoped
public class EditorView {
private String text;
private String text2;
}
PrimeFaces version: 8
I have solved with this dependency. Thanks Kukeltje.
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>owasp-java-html-sanitizer</artifactId>
<version>20191001.1</version>
</dependency>
Related to Mario's answer, that dependency is not available today. I used the following dependency and it also works fine:
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>html-types</artifactId>
<version>20200713.1</version>
</dependency>
According to the documentation the textEditor element has the secure attribute on true by default. This is because we need the text editor to be protected against XSS attacks (you wouldn't want an attacker to write malicious code in your editor, that can then be executed in other user's browsers)
https://owasp.org/www-community/attacks/xss/
Hence why you need to not only use the dependency owasp-java-html-sanitizer but to keep it up to date in case vulnerabilities in it appear.
https://search.maven.org/artifact/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer

Method Not Found ? This not made sense [duplicate]

This question already has answers here:
How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null / throws an error / not usable
(11 answers)
Closed 5 years ago.
I'm trying to implement a FileUpload feature in a simple JSF/CDI project, with correct dependencies(i think) and the same code that i found in the primefaces showcase.
But for some reason, the FileUpload event does not found the listener in my ManagedBean.
I hope i can see something that i'm missing here, i already inspected the code a lot of times but i dont find anything that could be causing the problem.
My Xhtml page:
<html>
<h:head>
</h:head>
<body>
<h:form>
<p:fileUpload fileUploadListener="#{file.uploadHandler()}"
mode="advanced" dragDropSupport="false" update="messages"
sizeLimit="100000" fileLimit="3"
allowTypes="/(\.|\/)(gif|jpe?g|txt)$/" />
<p:growl id="messages" showDetail="true" />
</h:form>
</body>
</html>
My ManagedBean:
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.primefaces.event.FileUploadEvent;
#Named
#ViewScoped
public class File implements Serializable {
private static final long serialVersionUID = -6644472075906217176L;
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public void uploadHandler(FileUploadEvent event) {
System.out.println("Nome do Arquivo: " + event.getFile().getFileName());
}
}
My pom.file :
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.14</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Console:
15:59:36,935 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-27) /index.xhtml #16,45 fileUploadListener="#{file.uploadHandler()}": Method not found: class timesheet.business.bean.File.uploadHandler(): javax.el.MethodNotFoundException: /index.xhtml #16,45 fileUploadListener="#{file.uploadHandler()}": Method not found: class timesheet.business.bean.File.uploadHandler()
You should specify the method reference in fileUpload component
<p:fileUpload fileUploadListener="#{file.uploadHandler}"
Please note that there should be no () after the method name.

EventBusFactory JSF1073

I'm trying to implement logic in JSF that accepts parameters and then updates some output on the xhtml page. The following is all borrowed from the primefaces pushdata showcase
XHTML:
<f:view>
<h:form id="form">
<f:metadata>
<f:viewParam name="data" value="#{viewParamPush.data}" />
<f:event type="preRenderView" listener="#{viewParamPush.prerender}" />
</f:metadata>
<h:outputText id="out" value="#{viewParamPush.data}" style="font-size:16px" />
<p:socket onMessage="handleMessage" channel="/QR" />
<script type="text/javascript">
function handleMessage(data) {
$('#out').text(data);
}
</script>
</h:form>
</f:view>
ViewParamPush:
ManagedBean
#RequestScoped
public class ViewParamPush implements Serializable{
private String data;
public String getData() {
return data;
}
public void setData(String data) {
util.sysprint("setData " + data, true);
this.data = data;
}
public void prerender() {
util.sysprint("prerender", true);
EventBus eventBus = EventBusFactory.getDefault().eventBus();
util.sysprint("prerender2", true);
even
tBus.publish("/QR", data);
util.sysprint("prerender3", true);
}
}
ViewParamResource:
#PushEndpoint("/QR")
public class ViewParamResource {
#OnMessage(encoders = {JSONEncoder.class})
public String onMessage(String data) {
util.sysprint("ViewParamResource onMessage", true);
return StringEscapeUtils.escapeHtml4(data);
}
}
I get the following exception when eventBus.publish("/QR", data); is called. I understand what a null pointer is however I don't understand why publish("/QR", data); in this case is causing one. Is there something wrong with my syntax?
FATAL: JSF1073: javax.el.ELException caught during processing of RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=/QR.xhtml #21,95 listener="#{viewParamPush.prerender}": java.lang.NullPointerException
FATAL: /QR.xhtml #21,95 listener="#{viewParamPush.prerender}": java.lang.NullPointerException
javax.el.ELException: /QR.xhtml #21,95 listener="#{viewParamPush.prerender}": java.lang.NullPointerException
I added *.xhtml to the url patterns in order to be able to call the script QR.xhtml?data=some data.. I assume that required in order to pass parameters to the script although I wonder if that affects the publish method
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
**<url-pattern>*.xhtml</url-pattern>**
</servlet-mapping>
Dependencies:
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>appserv-rt</artifactId>
<version>3.1.1</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.atmosphere/atmosphere-runtime -->
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.marklogic</groupId>
<artifactId>java-client-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>cupertino</artifactId>
<version>1.0.10</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.helger</groupId>
<artifactId>ph-schematron</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<exclusions>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcmail-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bctsp-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-light</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId> <!-- QR code support -->
<version>1.4</version>
</dependency>
</dependencies>
I've previously encountered this error. The reason for this failure is due to the Atmosphere version.
Then use it as below :
pom.xml
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime-native</artifactId>
<version>2.4.3</version>
</dependency>
web.xml
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
This way you can try. It works this for me.

Strange display behavior for p:dataTable in combination with ui:repeat or p:dataList [duplicate]

This question already has answers here:
ui: repeat + p: datatable question
(2 answers)
Closed 7 years ago.
When I use a primefaces p:displayTable in a ui:repeat or a p:dataList, the resulting display is buggy. Buggy means, the first table defines the columns of the following tables and not the DynamicDataTableCatalog-columns-count as expected.
My reputation isn't enough to post a image... (output png on an other website...) So i write the output in simple html:
<div>
<table id="firstTableWhichDefinesTheColum">
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
</table>
<table id="secondTableWithOnlyOneColumn">
<tr>
<td>d</td>
<td>random content or empty, because no data is available</td>
<td>random content or empty, because no data is available</td>
</tr>
</table>
</div>
This is the erroneous code:
<p:dataList value="#{evaluateEntriesMBean.dataTables}"
var="qC" type="definition">
<p:panel header="Übersicht #{qC.catalog.name}"
styleClass="defaultPanelClass subGradient">
<p:dataTable value="#{qC.userAnswers}" var="userAnswer"
tableStyle="margin: auto; width: auto;">
<p:column headerText="Mitarbeiter"
style="text-align: right; width: auto">
<h:outputText value="#{userAnswer.user.geteMail()}" />
</p:column>
<p:columns value="#{qC.columns}" var="column"
columnIndexVar="index"
style="#{evaluateEntriesMBean.getStyleOfAnswer(userAnswer,index)}" >
<f:facet name="header">
<div title="#{column.tooltipText}">
<h:outputText value="#{column.name}" />
</div>
</f:facet>
<div title="#{evaluateEntriesMBean.getTextOfAnswer(userAnswer,index)}" >
<p:graphicImage url="/resources/img/green-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Green'}" />
<p:graphicImage url="/resources/img/yellow-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Yellow'}" />
<p:graphicImage url="/resources/img/red-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Red'}" />
<p:graphicImage url="/resources/img/grey-trafficlight.png"
width="24"
rendered="#{evaluateEntriesMBean.getTrafficLightOfAnswer(userAnswer,index) == 'Unknown'}" />
</div>
</p:columns>
</p:dataTable>
</p:panel>
</p:dataList>
The datamodels which are used in the view:
public class DynamicDataTableCatalog {
private QuestionCatalogHistory catalog;
private List<ColumnHeader> columns;
private List<UserAnswers> userAnswers;
//...
}
public class UserAnswers {
private User user;
private List<Answer> answers;
//...
}
public class ColumnHeader {
String name;
String tooltipText;
//...
}
When i replace the p:dataList with a ui:repeat, the output is the same. Only the c:forEach works but doesn't support ajax updates...
My dependencies (All used libs including the version):
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
I hope someone can tell me if this is a bug or a wrong implementation I've made... Thank you in advance!
It's a Bug in Primefaces which is not fixed at the moment...
Thanks to Kukeltje I know that this is a Primefaces-Bug which isn't fixed at the moment...
https://github.com/primefaces/primefaces/issues/88

How to connect command button to action handler in PrimeFaces mobile rendering mode?

I have a PrimeFaces page with following form:
<!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"
xmlns:pm="http://primefaces.org/mobile">
<f:view renderKitId="PRIMEFACES_MOBILE"/>
<h:head>
</h:head>
<h:body>
<pm:page>
<pm:header title="Test"></pm:header>
<pm:content>
<p:panel header="Login">
<h:form>
<pm:field>
<p:outputLabel for="basic" value="User:"/>
<p:inputText id="basic"/>
</pm:field>
<pm:field>
<p:outputLabel for="password" value="Password:"/>
<p:password id="password"/>
</pm:field>
<p:commandButton value="Login" type="button"
actionListener="#{index.loginButtonAction}"/>
</h:form>
</p:panel>
</pm:content>
</pm:page>
</h:body>
</html>
And I have the class IndexView defined as follows.
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
#ManagedBean(name = "index")
#RequestScoped
public class IndexView {
public void loginButtonAction(ActionEvent actionEvent)
{
System.out.println("loginButtonAction");
addMessage("loginButtonAction");
}
public void registerButtonAction(ActionEvent actionEvent)
{
System.out.println("registerButtonAction");
addMessage("registerButtonAction");
}
public void addMessage(String summary) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, null);
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
When I press the Login button, nothing happens. I don't even see the message in the logs.
What do I need to change in order for loginButtonAction action to be called, when the button has been pressed?
The dependencies from my pom.xml file look are these:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
<!-- PrimeFaces (start) -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.1</version>
</dependency>
<!-- PrimeFaces (end) -->
<!-- JSF 2 (start) -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<!-- JSF 2 (end) -->
</dependencies>
Try removing
type="button"
From your commandButton. As long as its type is button it would only be clickable and won't send form data to the server.

Resources