5 Replies Latest reply on Oct 23, 2012 12:00 PM by Sanjeev Shrestha

    Insert row in datatable   (JSF 2 + Richfaces 4)

    Deibys Quintero Newbie

      Hello guys,

       

      I am trying to insert a row in a datatable. In fact, What I want to do, It is an "editable"  datatable. Users should be able to see displayed data in table, insert new rows,  or edit rows. All that within the table, I dont wan' t to use pop-up modal forms  or another kind of forms outside the table

       

      Mu backing bean is @SessionScoped

       

      This is the source code pf my JSF page:

       

      <?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:c="http://java.sun.com/jstl/core"

            xmlns:h="http://java.sun.com/jsf/html"

            xmlns:ui="http://java.sun.com/jsf/facelets"

            xmlns:f="http://java.sun.com/jsf/core"

            xmlns:rich="http://richfaces.org/rich"

            xmlns:a4j="http://richfaces.org/a4j"

                  >

       

       

                <h:body>

                          <ui:composition template="/common/templates/template.xhtml">

                                    <ui:define name="title">Cargar Encuesta</ui:define>

                                    <ui:define name="content">

                                              <div style="width:600px;">

                                                        <rich:panel style="background-color: white;">

                                                                  <f:facet name="header">

                                                                            <h:outputText value="Información del Evento" />

                                                                  </f:facet>

                                                                  <table border="0">

                                                                            <tr>

                                                                                      <td><h:outputLabel value="Nombre" /></td>

                                                                                      <td colspan="3"><h:outputText value="#{CargarEncuestaBean.eventoTO.nombre}" style="background-color: #CCCCCC;" /></td>

                                                                            </tr>

                                                                            <tr>

                                                                                      <td><h:outputLabel value="Fecha Inicio" /></td>

                                                                                      <td><h:outputText value="#{CargarEncuestaBean.eventoTO.fechaInicio}" style="background-color: #CCCCCC;" /></td>

                                                                                      <td><h:outputLabel value="Fecha Fin" /></td>

                                                                                      <td><h:outputText value="#{CargarEncuestaBean.eventoTO.fechaFinal}" style="background-color: #CCCCCC;" /></td>

                                                                            </tr>

                                                                  </table>

                                                        </rich:panel>

                                                        <br />

                                                        <a4j:repeat value="#{CargarEncuestaBean.encuestas}" var="encuesta" varStatus="status">

                                                                  <rich:collapsiblePanel header="#{encuesta.encuestaCalificador.nombre}  Población: #{encuesta.poblacion}" expanded="false" switchType="client" style="background-color: white;">

                                                                            <h:form>

                                                                                      <h:messages />

                                                                                      <table border="0">

                                                                                                <tr>

                                                                                                          <td><h:outputLabel value="Enlace de la Encuesta" /></td>

                                                                                                          <td><h:outputText  value="#{encuesta.linkEncuesta}" style="background-color: #CCCCCC;" /></td>

                                                                                                          <td><h:outputLabel value="Estado" /></td>

                                                                                                          <td><h:outputText  value="#{encuesta.estado}" style="background-color: #CCCCCC;" /></td>

                                                                                                </tr>

                                                                                                <tr>

                                                                                                          <td>Archivos Adjuntados</td>

                                                                                                </tr>

                                                                                      </table>

                                                                                      <rich:dataTable value="#{encuesta.listEncuestaConcepto}" var="concepto" >

                                                                                                <f:facet name="noData">

                                                                                                          <h:outputText value="No se han ingresado conceptos para este tipo de encuesta" />

                                                                                                </f:facet>

                                                                                                <rich:column>

                                                                                                          <f:facet name="header">

                                                                                                                    <h:outputText value="Concepto"/>

                                                                                                          </f:facet>

                                                                                                          <h:selectOneMenu value="#{concepto.tipoConcepto.id}">

                                                                                                                    <f:selectItems value="#{SelectListBean.encuestaConceptos}" />

                                                                                                          </h:selectOneMenu>

                                                                                                </rich:column>

                                                                                                <rich:column>

                                                                                                          <f:facet name="header">

                                                                                                                    <h:outputText value="Evaluación"/>

                                                                                                          </f:facet>

                                                                                                          <h:inputText value="#{concepto.calificacion}" />

                                                                                                </rich:column>

                                                                                                <rich:column>

                                                                                                          <f:facet name="header">

                                                                                                                    <h:outputText value="Contestaron"/>

                                                                                                          </f:facet>

                                                                                                          <h:inputText value="#{concepto.respondieron}" >

                                                                                                                    <f:validateRequired />

                                                                                                          </h:inputText>

                                                                                                </rich:column>

                                                                                                <rich:column>

                                                                                                          <f:facet name="header">

                                                                                                                    <a4j:commandLink execute="@this" value="Añadir" action="#{CargarEncuestaBean.adicionarConcepto(encuesta.listEncuestaConcepto)}" render="@form" />

                                                                                                          </f:facet>

                                                                                                          <a4j:commandLink value="Guardar" action="#{CargarEncuestaBean.guardar()}" >

                                                                                                                    <a4j:param value="#{status.index}"  assignTo="#{CargarEncuestaBean.encuestaSeleccionada}" />

                                                                                                          </a4j:commandLink>

                                                                                                          <h:outputText value=" " />

                                                                                                          <a4j:commandLink execute="@this" value="Eliminar" action="#{CargarEncuestaBean.eliminarConcepto(concepto)}" render="@form" >

                                                                                                                    <a4j:param value="#{status.index}"  assignTo="#{CargarEncuestaBean.encuestaSeleccionada}" />

                                                                                                          </a4j:commandLink>

                                                                                                </rich:column>

                                                                                      </rich:dataTable>

                                                                            </h:form>

                                                                  </rich:collapsiblePanel>

                                                        </a4j:repeat>

                                              </div>

                                       </ui:define>

                          </ui:composition>

                </h:body>

      </html>   

       

       

       

      When I click on "Guadar" commandLink I get the following exception:

       

      09:14:27,642 GRAVE [org.richfaces.log.Context] (http-localhost-127.0.0.1-8080-1) javax.el.PropertyNotFoundException: /cargarEncuesta/cargarEncuesta.xhtml @59,64 value="#{concepto.tipoConcepto.id}": Objetivo inalcanzable, 'tipoConcepto' devolvió nulo: javax.faces.FacesException: javax.el.PropertyNotFoundException: /cargarEncuesta/cargarEncuesta.xhtml @59,64 value="#{concepto.tipoConcepto.id}": Objetivo inalcanzable, 'tipoConcepto' devolvió nulo

                at org.richfaces.component.UIDataAdaptor.iterate(UIDataAdaptor.java:772) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor.processValidatesChildren(UIDataAdaptor.java:850) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor.processValidators(UIDataAdaptor.java:822) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at javax.faces.component.UIForm.processValidators(UIForm.java:253) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:55) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:321) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]

                at javax.faces.component.UIForm.visitTree(UIForm.java:381) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at org.richfaces.component.AbstractTogglePanel.visitTree(AbstractTogglePanel.java:743) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor$DataVisitorForVisitTree.process(UIDataAdaptor.java:199) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.ajax4jsf.model.SequenceDataModel.walk(SequenceDataModel.java:65) [richfaces-core-api-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor.walk(UIDataAdaptor.java:796) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor.visitDataChildren(UIDataAdaptor.java:1269) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1347) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at org.richfaces.context.ExtendedPartialViewContextImpl.executeComponents(ExtendedPartialViewContextImpl.java:237) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialExecutePhase(ExtendedPartialViewContextImpl.java:217) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:196) [richfaces-core-impl-4.2.2.Final.jar:4.2.2.Final]

                at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1170) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

                at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_33]

      Caused by: javax.el.PropertyNotFoundException: /cargarEncuesta/cargarEncuesta.xhtml @59,64 value="#{concepto.tipoConcepto.id}": Objetivo inalcanzable, 'tipoConcepto' devolvió nulo

                at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:202) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:319) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIInput.validate(UIInput.java:960) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIInput.executeValidate(UIInput.java:1233) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIInput.processValidators(UIInput.java:698) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at org.richfaces.component.UIDataAdaptor$3.processComponent(UIDataAdaptor.java:123) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor$ComponentVisitor.process(UIDataAdaptor.java:1410) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.ajax4jsf.model.SequenceDataModel.walk(SequenceDataModel.java:65) [richfaces-core-api-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor.walk(UIDataAdaptor.java:796) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                at org.richfaces.component.UIDataAdaptor.iterate(UIDataAdaptor.java:770) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

                ... 39 more

       

       

       

      What is the issue ? I would expect that after clicking on "Guardar" commanLink  , The values in the Collection (List) I am iterating  through would be updated