I'm using PF6.0 and Wildfly 10 and my web app in some point needs to build some quite big grid of p:inplace objects on single page. Sounds easy.
The problem: when my grid is too big any ajax request ends with error.
To reproduce this problem I have working example:
The page test.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:p="http://primefaces.org/ui">
<h:head>
<title>Test</title>
</h:head>
<h:body>
<h:form>
<!--it's a part of something bigger so this part is in outputPanel-->
<p:outputPanel id="details">
<h:outputText value="Size: #{backBean.size}" />
<p:panelGrid>
<!--btw. why it forces me to set all of this variables at p.repeat?-->
<p:repeat value="#{backBean.content}"
var="_row"
offset="0"
step="1"
size="#{backBean.content.size()}"
varStatus="_rowStatus" >
<p:row>
<p:repeat value="#{_row}"
var="_cell"
offset="0"
step="1"
size="#{_row.size()}"
varStatus="_rowStatus" >
<p:column>
<p:inplace editor="true">
<f:facet name="output">
<h:outputText value="#{_cell.output}" />
</f:facet>
<f:facet name="input">
<!--in real example it will be more complex with checkboxes, selectonemenu etc-->
<h:outputText value="First:" />
<p:inputText value="#{_cell.something}" />
<br />
<h:outputText value="Second:" />
<p:inputText value="#{_cell.another}" />
</f:facet>
</p:inplace>
</p:column>
</p:repeat>
</p:row>
</p:repeat>
</p:panelGrid>
</p:outputPanel>
<p:commandButton value="more" update="details" actionListener="#{backBean.weNeedMore}" />
</h:form>
</h:body>
</html>
Backing bean:
package com.test;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
@Named(value = "backBean")
@SessionScoped
public class BackBean implements Serializable {
private List<List<CellContent>> content;
private int size;
/**
* Creates a new instance of BackBean
*/
public BackBean() {
}
private void build() {
content = new ArrayList<>();
for(int i=0;i<size;i++) {
List<CellContent> row = new ArrayList<>();
for(int j=0;j<size;j++) {
CellContent cell = new CellContent();
row.add(cell);
}
content.add(row);
}
}
@PostConstruct
public void init() {
size = 10;
//create first content
build();
}
public void weNeedMore() {
//increase until we get error after click.
size = size + 10;
build();
}
//plain getters & setters
public List<List<CellContent>> getContent() {
return content;
}
public void setContent(List<List<CellContent>> content) {
this.content = content;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
}
and one class that holds my objects:
package com.test;
public class CellContent {
private String something = "";
private String another = "";
private String output = "click_me";
public CellContent() {
}
//some dummy update based on inputs
private void update() {
if(!something.equals(""))
output = something;
if(!another.equals(""))
output = "another: " + another;
}
//those two setters update the object
public void setSomething(String something) {
this.something = something;
update();
}
public void setAnother(String another) {
this.another = another;
update();
}
//rest are plain get&seters
public String getSomething() {
return something;
}
public String getAnother() {
return another;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}
When grid of my objects are "small" like 10x10 or 20x20 it works - I can click and update any cell.
But increasing size up to 30 (by hitting more button) leads to this error when I click anything:
09:47:13,602 ERROR [io.undertow.request] (default task-89) UT005023: Exception handling request to /myapp/test.xhtml: javax.servlet.ServletException at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at org.primefaces.util.ResourceUtils.getComponentResources(ResourceUtils.java:66) at org.primefaces.context.PrimePartialResponseWriter.startMetadataIfNecessary(PrimePartialResponseWriter.java:280) at org.primefaces.context.PrimePartialResponseWriter.startError(PrimePartialResponseWriter.java:107) at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:203) at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:127) at javax.faces.context.ExceptionHandlerWrapper.handle(ExceptionHandlerWrapper.java:100) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658) ... 34 more
Any idea what's happen? Is there any parameter I could adjust to avoid this error? Or any other solution (my current workaround is using datagrid with pagination).