0

Translated:

I have seen a lot of questions like I have, but those were no good: the biggest difference is my string is empty, and I can't find which component lacks data.

Context: I'm using the tags <h:form> and <p:commandbutton> to test a simple function which prints something with System.out.println().

The error happens when I click the commandbutton inside one of the rowexpansions. The system.out.print doesn't show up in the tomcat prompt. I've searched everywhere for that empty string.

What is happening? How can I debug this? How can I fix it?

O Error Stack :

    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.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://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>

The 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;
        }
    }
}

EDIT :

Based on some of the answer given, I tried altering the components: The basic structure is like this: Based on your answer, I've tryed to make a single <h:form> in the following simplified structure:

<h:form>
      <p:datatable>
          <p:rowExpansion>
                SOME INPUTS HERE
                <p:commandButton action="PRINTSOMETHING()">
            </p:rowExpansion>
       <p:dataTable>
</h:form>

It still hasn't worked, the exception is the same. I think I unnested forms now, am I correct?

EDIT NUMBER 2

I've added the LifeCycleListener Class, the stack trace changed. it changed the Error Stack, it seems it does run the bean method. The error is triggered after the bean method runs. I've editted the error stack.

Caju
  • 9
  • 6
  • 1
    You can config stdout output in tomcat, see here https://stackoverflow.com/questions/19787279/where-to-configure-internal-tomcat7-stdout-stderr-log-files, or better use log4j from the application more info here https://www.baeldung.com/java-system-out-println-vs-loggers. If you need to set default value to empty fields in JSF, check the balusC post http://balusc.omnifaces.org/2015/10/the-empty-string-madness.html. Maybe you need add `-Dorg.apache.el.parser.COERCE_TO_ZERO=false` o `javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL=true` – JuanMoreno Jan 30 '20 at 17:19
  • Thanks I'll try to use Logs, but my bigger problem is not the printing. In this case it's just a way to test if the commandButton is working or not. Thanks! – Caju Jan 30 '20 at 17:26
  • For the log I understand that the `commandButton` is working, however, some of the integer fields are empty so throws `NumberFormatException` in the conversion phase. Could you try again with a simple POJO, with fewer fields, for example only strings? – JuanMoreno Jan 30 '20 at 17:30
  • Will do, i'll be right back. – Caju Jan 30 '20 at 17:47
  • With a simple POJO and just one field it worked. What does that mean? How can i find out which one is wrong on the original case? – Caju Jan 30 '20 at 17:54
  • Try adding an integer field, if the `NumberFormatException` is thrown it, configure the properties from the BalusC post. Maybe some of the original fields don't have data. – JuanMoreno Jan 30 '20 at 18:07
  • Integer field added, it worked again. I'm trying to commentate every field separately and trying again, I still haven't found it. Is there a better way to do this? – Caju Jan 30 '20 at 18:17
  • There are some alternatives. Write unit tests to verify the assignment. Add validation to `inputText` to check ranges, maybe better use `inputNumber` instead for numeric values. It's a good idea to combine with primefaces client side validation too. – JuanMoreno Jan 30 '20 at 18:34
  • Still no luck. I've added validation for all Entities. On each set method I checked if it was null and throw an exception if it is. Any othe ideas? – Caju Jan 30 '20 at 20:40
  • [mcve] please... that is what helps you pinpoint the issue – Kukeltje Jan 30 '20 at 21:12
  • Your _"//Tinha um named, foi tirado. Ele bugava coisas"_ is cause by https://stackoverflow.com/questions/14384369/how-to-replace-managedbean-viewscope-by-cdi-in-jsf-2-0-2-1 Your imports are a wrong mixup – Kukeltje Jan 30 '20 at 21:44
  • The `NumberFormatException` seems to happen just before the `set` methods invocation. Thus the validation in these methods doesn't work, you need to add the validation in the client-side or set default values int the server-side (pre init your POJOs or adding the flags that I mentioned before). You could debug the JSF lifecycle to check the process. BalusC has a post related to, check here http://balusc.omnifaces.org/2006/09/debug-jsf-lifecycle.html – JuanMoreno Jan 31 '20 at 01:19
  • Does this answer your question? [How to use in JSF page? Single form? Multiple forms? Nested forms?](https://stackoverflow.com/questions/7371903/how-to-use-hform-in-jsf-page-single-form-multiple-forms-nested-forms) – Selaron Jan 31 '20 at 07:03
  • I'm sorry, I'll check your answers now, i didn't had time yet. – Caju Jan 31 '20 at 11:56
  • I see no reason to be sorry for anything. :) – Selaron Jan 31 '20 at 12:04
  • Yes the last example would be with no nested forms. Too bad this didn't solve your issue. What's your exact PF and JSF impl. versions? – Selaron Jan 31 '20 at 14:00
  • Regarding the nesting form problem. Do you include this page in another one? – JuanMoreno Jan 31 '20 at 14:44
  • JSF 2.2.8-16 PF 8.0. If you have any idea, I'm still all ears – Caju Jan 31 '20 at 16:10
  • I include another xhtml file, called menu.xhtml It has but they seem closed . EDIT: commented the include, it did not work, still the same Exception – Caju Jan 31 '20 at 16:40
  • Why does it run two full life cycles on button click? It's the second one that fails. Which component is triggering this? – Selaron Feb 03 '20 at 11:40
  • The components that triggers this exceptions are: The submit button inside the form="acao_edicao_form" when you click on it. All inputs from form id="acao_edicao_form" when you click on the fields to input them. I don't know why it does that. – Caju Feb 03 '20 at 12:06

2 Answers2

3

The exception is not related to your input fields nor domain model or validation, it happens in PrimeFaces RowExpandFeature:

public void encode(FacesContext context, DataTableRenderer renderer, DataTable table) throws IOException {
    Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    int expandedRowIndex = Integer.parseInt(params.get(table.getClientId(context) + "_expandedRowIndex"));

The top of your exception stack trace directly points you there:

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)

The component is unable to determine their own clientId correctly and thus does not find the _expandedRowIndex POST value. The most likely root cause is you are nesting forms.

JuanMoreno
  • 2,498
  • 1
  • 25
  • 34
Selaron
  • 6,105
  • 4
  • 31
  • 39
  • Update the question based on your answer. Sadly it still gives me the same Exception when i try to click the – Caju Jan 31 '20 at 13:51
0

After many tries, i found some fundamental problem. My managed bean, "BeanGestao" was configured in faces-config.xml as:

RequestScoped.

So the @ViewScoped annotation was being ignored. That's why my managed bean was being restarted a lot.

I guess the configuration in faces-config.xml is stronger than the annotation.

Thanks for the help! It wasn't easy to help me and my confusing problem.

Caju
  • 9
  • 6