Переведено:
Я видел много таких вопросов, как у меня, но они были бесполезны: самое большое отличие в том, что моя строка пуста, и я не могу найти, в каком компоненте отсутствуют данные.
Контекст: я использую теги <h:form>
и <p:commandbutton>
для проверки простой функции, которая печатает что-то с помощью System.out.println()
.
Ошибка возникает, когда я нажимаю кнопку команды внутри одной из кнопок. rowexpansions. System.out.print не отображается в приглашении tomcat. Я везде искал эту пустую строку.
Что происходит? Как я могу отладить это? Как это исправить?
O Стек ошибок:
START PHASE RESTORE_VIEW 1
END PHASE RESTORE_VIEW 1
START PHASE APPLY_REQUEST_VALUES 2
Conexao Bem sucedida! END PHASE APPLY_REQUEST_VALUES 2
START PHASE PROCESS_VALIDATIONS 3
END PHASE PROCESS_VALIDATIONS 3
START PHASE UPDATE_MODEL_VALUES 4
END PHASE UPDATE_MODEL_VALUES 4
START PHASE INVOKE_APPLICATION 5
################ BEAN METHOD RUNNING!################
END PHASE INVOKE_APPLICATION 5
START PHASE RENDER_RESPONSE 6
END PHASE RENDER_RESPONSE 6
START PHASE RESTORE_VIEW 1
END PHASE RESTORE_VIEW 1
START PHASE APPLY_REQUEST_VALUES 2
END PHASE APPLY_REQUEST_VALUES 2
START PHASE PROCESS_VALIDATIONS 3
END PHASE PROCESS_VALIDATIONS 3
START PHASE UPDATE_MODEL_VALUES 4
Conexao Bem sucedida! END PHASE UPDATE_MODEL_VALUES 4
START PHASE INVOKE_APPLICATION 5
END PHASE INVOKE_APPLICATION 5
START PHASE RENDER_RESPONSE 6
31-Jan-2020 16:29:24.342 SEVERE [http-nio-8084-exec-35] com.sun.faces.application.view.FaceletViewHandlingStrategy.handleRenderException Error Rendering View[/index.xhtml]
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at org.primefaces.component.datatable.feature.RowExpandFeature.encode(RowExpandFeature.java:48)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:88)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:582)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at org.primefaces.component.api.UIData.visitTree(UIData.java:910)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:322)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:65)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:432)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:651)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
END PHASE RENDER_RESPONSE 6
31-Jan-2020 16:29:24.378 SEVERE [http-nio-8084-exec-35] com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at org.primefaces.component.datatable.feature.RowExpandFeature.encode(RowExpandFeature.java:48)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:88)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:582)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at org.primefaces.component.api.UIData.visitTree(UIData.java:910)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:322)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:65)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:432)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:651)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
O index.x html:
<?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://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<h:head>
<title>Portal Inova</title>
<h:outputStylesheet library="css" name="bootstrap.css"></h:outputStylesheet>
<h:outputStylesheet library="css" name="index.css"></h:outputStylesheet>
</h:head>
<h:body style="background-color: #1f1f1f;">
<ui:include src="menu.xhtml"/>
<h:form id="form">
<div class="container">
<ui:debug rendered="true" hotkey="q" />
<p:panel>
<p:dataTable id="indexAcao" var="aGestor" value="#{beanGestao.acaoVisaoIndex}"
widgetVar="tableIndex" globalFilterFunction="#{beanGestao.globalFilterFunction}"
selectionMode="single" selection="#{beanGestao.acaoSelecionada}" rowKey="#{aGestor.idAcao}"
reflow="true">
SOME CODE HERE
<p:column class="hiddenToggler" style="width:1em">
<p:rowToggler />
</p:column>
<p:rowExpansion>
<h:form id="acao_edicao_form">
<p:panelGrid layout="flex" columns="2">
<p:column styleClass="ui-g-10" >
<div class="ui-g-12">
<label>Nome da Ação</label>
<p:inputText id="nomeAcao" value="#{aGestor.nmAcao}" class="ui-g-12" />
</div>
<div class="ui-g-12">
<label>Idéia InovaCrédito</label>
<p:inputTextarea id="descricaoAcao" value="#{aGestor.descricao}" class="ui-g-12"/>
</div>
<p:panelGrid columns="3" layout='tabular'>
<p:column>
<p:outputLabel value="Tema" />
<p:selectOneMenu id="nomeTema" class="ui-g-12" value="#{beanGestao.tema}" >
<f:selectItems value="#{beanGestao.tema}" />
</p:selectOneMenu>
</p:column>
<p:column>
<label>Data de Início</label>
<p:calendar id="dataIni" value="#{aGestor.dtIni}" class="ui-g-12" inputStyleClass="ui-g-10" showOn="button" />
</p:column>
<p:column>
<label>Data de Entrega</label>
<p:calendar id="dataFim" value="#{aGestor.dtFim}" class="ui-g-12" inputStyleClass="ui-g-10" showOn="button" />
</p:column>
<p:column>
<p:outputLabel value="Status" />
<p:selectOneMenu class="ui-g-12" value="#{beanGestao.statusT}">
<f:selectItems value="#{beanGestao.statusT}" />
</p:selectOneMenu>
</p:column>
<p:column>
<p:outputLabel value="Gestor" />
<p:selectOneMenu id="nomeGestor" class="ui-g-12" value="#{beanGestao.gestor}" dynamic="true" >
<f:selectItems value="#{beanGestao.gestor}" />
</p:selectOneMenu>
</p:column>
<p:column>
<label>Percentual:</label>
<p:inputText id="percentualAcao" value="#{aGestor.percentual}" placeholder="99,9%" class="ui-g-12" />
</p:column>
</p:panelGrid>
<div class="ui-g-12">
<label>Viabilidade/Descrição do Andamento</label>
<p:inputTextarea id="andamentoAcao" value="#{aGestor.andamento}" class="ui-g-12" />
</div>
</p:column>
<p:column styleClass="ui-g-2" colspan="1">
<p:commandButton value="Editar" update="@this" action="#{beanGestao.debug()}"
icon="pi pi-check" />
</p:column>
</p:panelGrid>
</h:form>
</p:rowExpansion>
</p:dataTable>
</p:panel>
</div>
</h:form>
<!-- js depois do body, carregamento + rapido -->
<h:outputScript name="dataTogglerHide.js" library="js"></h:outputScript>
</h:body>
</html>
ManagedBean BeanGestao:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bean;
import dao.GestaoDAO;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Locale;
import modelos.Acao;
import modelos.Gestor;
import modelos.StatusT;
import modelos.Tema;
/**
*
* @author F3797739
*
*/
@ViewScoped
//Tinha um named, foi tirado. Ele bugava coisas
public class BeanGestao implements Serializable{
private final static long serialVersionUID=1l;
private List<Tema> tema;
private List<StatusT> statusT;
private List<Acao> acaoVisaoIndex;
private List<Gestor> gestor;
private List<Acao> acaoGestor;
private List<Acao> acaoTema;
private Tema te;
private Gestor ges;
private StatusT sta;
private String filtroGlobal;
// Variavel auxiliar de acao selecionada
private Acao acaoSelecionada;
private GestaoDAO gestaoDAO = new GestaoDAO();
@PostConstruct
void init(){
this.alimentaListas();
}
private void alimentaListas(){
try {
this.setTema();
this.setStatusT();
this.setGestor();
this.setAcaoGestor();
this.setAcaoTema();
this.setAcaoVisaoIndex();
} catch (SQLException ex) {
Logger.getLogger(BeanGestao.class.getName()).log(Level.SEVERE, null, ex);
}
}
//FUNCAO GENERICA DE FILTRO, concatene os parametros no RETURN para incluir mais colunas
public boolean globalFilterFunction(Object value, Object filter,Locale local) {
String filterText = (filter == null) ? null : filter.toString().trim().toLowerCase();
if (filterText == null || filterText.equals("")) {
return true;
}
Acao acao = (Acao) value;
return String.valueOf(acao.getId()).toLowerCase().contains(filterText)
|| String.valueOf(acao.getGestor().getNmGestor()).toLowerCase().contains(filterText)
|| String.valueOf(acao.getTema().getNmTema()).toLowerCase().contains(filterText)
|| String.valueOf(acao.getNmAcao()).toLowerCase().contains(filterText)
|| String.valueOf(acao.getDtFim()).toLowerCase().contains(filterText)
|| String.valueOf(acao.getStatus().getNmStatusP()).toLowerCase().contains(filterText);
}
public void debug(){
System.out.println("############# BEAN METHOD RUNNING! ##############");
}
// GETTERS E SETTERS
public Acao getAcaoSelecionada() {
return acaoSelecionada;
}
public void setAcaoSelecionada(Acao acaoSelecionada) {
this.acaoSelecionada = acaoSelecionada;
}
public List<Acao> getAcaoVisaoIndex() {
if(this.acaoVisaoIndex == null)
try{this.setAcaoVisaoIndex();}catch(SQLException e){}
return acaoVisaoIndex;
}
public void setAcaoVisaoIndex() throws SQLException {
if(this.acaoVisaoIndex == null){
acaoVisaoIndex = gestaoDAO.AcoesIndex();
this.acaoVisaoIndex = gestaoDAO.AcoesIndex();
}
}
public GestaoDAO getGestaoDAO() {
return gestaoDAO;
}
public void setGestaoDAO(GestaoDAO gestaoDAO) {
this.gestaoDAO = gestaoDAO;
}
public List<Tema> getTema() {
return tema;
}
public void setTema()throws SQLException {
if(this.tema == null){
tema = new ArrayList<>();
tema = gestaoDAO.BuscaTema();
}
}
public List<StatusT> getStatusT() {
return statusT;
}
public void setStatusT()throws SQLException {
if(this.statusT == null){
statusT = new ArrayList<>();
statusT = gestaoDAO.BuscaStatus();
}
}
public List<Gestor> getGestor() {
return gestor;
}
public void setGestor()throws SQLException {
if(this.gestor == null){
gestor = new ArrayList<>();
gestor = gestaoDAO.BuscaGestor();
}
}
public List<Acao> getAcaoGestor() {
return acaoGestor;
}
public void setAcaoGestor()throws SQLException {
if(this.acaoGestor == null){
acaoGestor = new ArrayList<>();
acaoGestor = gestaoDAO.AcoesPorDivisao();
}
}
public List<Acao> getAcaoTema() {
return acaoTema;
}
public void setAcaoTema()throws SQLException {
if(this.acaoTema == null){
acaoTema = new ArrayList<>();
acaoTema = gestaoDAO.AcoesPorTema();
}
}
public Tema getTe() {
return te;
}
public void setTe(Tema te) {
this.te = te;
}
public Gestor getGes() {
return ges;
}
public void setGes(Gestor ges) {
this.ges = ges;
}
public StatusT getSta() {
return sta;
}
public void setSta(StatusT sta) {
this.sta = sta;
}
public String getFiltroGlobal() {
return filtroGlobal;
}
public void setFiltroGlobal(String filtroGlobal) {
this.filtroGlobal = filtroGlobal;
}
//Metodo estatico para alterar a ordem no sortby componente
static public class ColumnModel implements Serializable {
private String header;
private String property;
public ColumnModel(String header, String property) {
this.header = header;
this.property = property;
}
public String getHeader() {
return header;
}
public String getProperty() {
return property;
}
}
}
РЕДАКТИРОВАТЬ:
На основании некоторых ответов я попытался изменить компоненты: Структура basi c выглядит следующим образом: Основываясь на вашем ответе, я ' мы попытались сделать один <h:form>
в следующей упрощенной структуре:
<h:form>
<p:datatable>
<p:rowExpansion>
SOME INPUTS HERE
<p:commandButton action="PRINTSOMETHING()">
</p:rowExpansion>
<p:dataTable>
</h:form>
Он все еще не работал, исключение то же самое. Я думаю, что теперь я не выполнил форматы, правильно?
РЕДАКТИРОВАТЬ НОМЕР 2
Я добавил класс LifeCycleListener, трассировка стека изменилась. он изменил стек ошибок, похоже, он запускает метод bean. Ошибка срабатывает после запуска метода компонента. Я отредактировал стек ошибок.