1 2 Previous Next 18 Replies Latest reply on Mar 19, 2010 11:30 AM by rodmen

    recover values rich:dataTable

    rodmen

      Hi,

       

      How can I recover the values that are in a rich:dataTable

       

      Like this

       

      <r:dataTable id="listaDetalleRegion" var="iteraDetReg" value="#{detallePedidoBean.listaDetalleRegion}" width="100%"

      onRowMouseOver="this.style.backgroundColor='#ffffff'"

                              onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">

      <f:facet name="header">

      <r:columnGroup>

                                  <r:column>

                                      <h:outputText value="Plaza"/>

                                  </r:column>

                                  <r:column>

                                      <h:outputText id="comisionPorcentaje" value="#{detallePedidoBean.comisionPorcentaje}"/>

                                  </r:column>

                                  <r:column>

                                      <h:outputText id="costoPorcentaje" value="#{detallePedidoBean.costoPorcentaje}"/>

                                  </r:column>

                                  <r:column>

                                      <h:outputText value="Pagina"/>

                                  </r:column>

                                  <r:column>

                                     <h:outputText value="Total Paginas"/>

                                  </r:column>

                                  <r:column>

                                      <h:outputText value="Comentario"/>

                                  </r:column>

      </r:columnGroup>

      </f:facet>

      <r:columnGroup style="width: 100px;">

              <r:column width="20%" style="text-align: center;">

          <h:outputText value="#{iteraDetReg.nombreCiudadRegion}"/>

              </r:column>

              <r:column style="text-align: center;">

      <h:inputText id="proporcionComisionPlaza" value="#{iteraDetReg.proporcionPorcentajePlaza}" styleClass="inputTextPropPlaza" onkeypress="return isNumberKey(event);" 

      onchange="return proporcionComision('#{row}', '#{detallePedidoBean.totalPlazas}')" onkeyup="onlyNumberMaxMin(this.value, this.id);" maxlength="5" required="true">

      <f:convertNumber integerOnly="true" maxFractionDigits="2" maxIntegerDigits="3" minFractionDigits="2" minIntegerDigits="0" type="number" />

      </h:inputText>

              </r:column>

              <r:column style="text-align: center;">

      <h:inputText id="proporcionCostoPlaza" value="#{iteraDetReg.proporcionCostoPorcentajePlaza}" styleClass="inputTextPropCosPlaza" onkeypress="return isNumberKeyDec(event);" 

      onchange="return proporcionCosto('#{row}', '#{detallePedidoBean.totalPlazas}')" maxlength="10" required="true">

      <f:convertNumber integerOnly="true" maxFractionDigits="2" maxIntegerDigits="7" minFractionDigits="2" minIntegerDigits="0" type="number" />

      </h:inputText>

              </r:column>

              <r:column width="10%" style="text-align: center;">

      <r:inputNumberSpinner id="numeroPaginaEdicion" value="#{iteraDetReg.numeroPaginaEdicion}" minValue="0" maxValue="#{iteraDetReg.numeroTotalPaginasEdicionRegion}" oninputkeypress="return stopRKey(event);" cycled="true" required="true">

      <f:convertNumber integerOnly="true" maxFractionDigits="0" maxIntegerDigits="3" minFractionDigits="0" minIntegerDigits="0" type="number"/>

      </r:inputNumberSpinner>

              </r:column>

              <r:column width="10%" style="text-align: center;">

          <r:inputNumberSpinner id="numeroTotalPaginaEdicion" value="#{iteraDetReg.numeroTotalPaginasEdicionRegion}" minValue="0"  maxValue="1000" oninputkeypress="return stopRKey(event);" cycled="true" required="true" onchange="maxValue(this);">

      <f:convertNumber integerOnly="true" maxFractionDigits="0" maxIntegerDigits="3" minFractionDigits="0" minIntegerDigits="0" type="number"/>

      </r:inputNumberSpinner>

              </r:column>

              <r:column width="20%" style="text-align: justify;">

          <h:inputTextarea id="comentarioRegionPlaza" value="#{iteraDetReg.comentarioRegionPlaza}"/>

              </r:column>

              </r:columnGroup>

      </r:dataTable>

       

       

      I’m trying this way but I can not get it, I need to extract the values.

       

       

      org.richfaces.component.html.HtmlDataTable listaDetalleRegion = (org.richfaces.component.html.HtmlDataTable)form.findComponent("listaDetalleRegion");

              //DataTable listaDetalleRegion = (DataTable)form.findComponent("listaDetalleRegion");

              try{

              System.out.println("****proporcionCostoPlaza.getChildren() "+listaDetalleRegion.getChildren());

              for(int i=0; i<listaDetalleRegion.getChildren().size(); i++){

              UIComponent columnas = (UIComponent) listaDetalleRegion.getChildren().get(i);

                  System.out.println(i+" columnas****---> "+columnas.getChildren());

                  System.out.println(" columnas.getChildren().size() "+columnas.getChildren().size());

                  for(int j=0; j<columnas.getChildren().size(); j++){

                  UIComponent renglones = (UIComponent)columnas.getChildren().get(j);

                  System.out.println(i+" - "+j+" renglones****---> "+renglones.getChildren());

                  System.out.println(" renglones.getChildren().size() "+renglones.getChildren().size());

                  for(int k=0; k<renglones.getChildren().size(); k++){

                  UIComponent datos = (UIComponent)renglones.getChildren().get(k);

                      System.out.println(i+" - "+j+" - "+k+" datos****---> "+datos.getChildren().toString());

                      System.out.println(" datos.getChildren().size() "+datos.getChildren().size());

                  }

                  }

              }

              }catch(Exception ex){

              System.out.println("## Error: "+ex);

              }

       

      Thank you

        • 1. Re: recover values rich:dataTable
          ilya_shaikovsky
          How can I recover the values that are in a rich:dataTable

          sorry, but i'm not sure that get the point.

          • 2. Re: recover values rich:dataTable
            nbelaevski

            Hi,

             

            You can use walk(...) method.

            • 3. Re: recover values rich:dataTable
              rodmen

              Hello, what I want to know is… how to recover the value of the field, for example the input text value that is in the dataTable cause I’m trying to recover the whole list and get the value of each element, but instead I’m getting the name of each field.

               

              Thank you.

              • 4. Re: recover values rich:dataTable
                nbelaevski
                You can read updated values from "iteraDetReg" - or am I not getting the problem correctly?
                • 5. Re: recover values rich:dataTable
                  rodmen

                  Yes, that’s my problem, and I don’t understand who to use the walk method.

                   

                  thank you

                  • 6. Re: recover values rich:dataTable
                    harut

                    If your problem is how to get updated values of the input elements in the datatable, then why are you trying to get HtmlDataTable object and try to find values from there ???

                    You have set the value of inputText to value="#{iteraDetReg.proporcionPorcentajePlaza}" where iteraDetReg is an element of the listaDetalleRegion Collection. This means that after any action, properties of elements of the listaDetalleRegion will update their values by the

                    new ones -- proporcionPorcentajePlaza will contain the new value of the <h:inputText id="proporcionComisionPlaza"....

                    So you have to iterate through the listaDetalleRegion Collection (which is the value of your rich:dataTable), and find the updated values of it's elements properties...

                    • 7. Re: recover values rich:dataTable
                      rodmen

                      Hello Harut, I try but the detallePedidoBean.listaDetalleRegion is null

                       

                      I did this...

                       

                      DetallePedidoBBean detallePedidoBean = (DetallePedidoBBean) request.getAttribute("detallePedidoBean");

                      listaDetalleRegion = (ArrayList<DetallePedidoBBean>) detallePedidoBean.getListaDetalleRegion();

                       

                      System.out.println("************listaDetalleRegion "+listaDetalleRegion);

                       

                      and the result...

                       

                      ************listaDetalleRegion null

                       

                      What am I doing wrong?

                       

                      thank you very much

                      • 8. Re: recover values rich:dataTable
                        nbelaevski

                        Hi,

                         

                        Maybe it's the problem with beans configuration? Please check it.

                        • 9. Re: recover values rich:dataTable
                          harut

                          Hi Rodrigo, it is not so prefferable way to get the property of the Bean object (in your case collection for dataTable) by the functionality you have mentioned -- (DetallePedidoBBean) request.getAttribute("detallePedidoBean"); .....

                          It is better to have Bean objects as properties in your "Controller" Bean class(where your Action/ActionListener methods are defined), and simply call getter method of needed property of the Bean object -- in your case

                          public class AnyControllerBean {

                               private DetallePedidoBBean detallePedidoBean;

                              ......

                              

                               public void recoverTableValuesAction(ActionEvent event) {

                                     Collection listaDetalleRegion = detallePedidoBean.getListaDetalleRegion();

                                     ............

                               }

                          }

                           

                          About the null of your collection -- it is strange in my opinion, and I agree with the Nick's opinion.

                          But I can suggest to add "a4j:keepalive" declaration for your bean (detallePedidoBean, or if you will go with my suggested way above -- AnyControllerBean) in the top of the page.

                          After it the problem might be solved.

                           

                          Regards, Harut.

                          • 10. Re: recover values rich:dataTable
                            rodmen

                            Hi everybody

                             

                            Thank you all, I’m checking the configuration as Nick's suggest, something most be wrong, any idea where to start?

                             

                            Regards Rodrigo

                            • 11. Re: recover values rich:dataTable
                              nbelaevski
                              What type of beans configuration are you using: JSF managed beans, Seam, something other?
                              • 12. Re: recover values rich:dataTable
                                rodmen
                                Hi Nick, I'm using managed beans
                                • 13. Re: recover values rich:dataTable
                                  nbelaevski

                                  Hi Rodrigo,

                                   

                                  Please post managed beans sections from faces-config.xml + beans code.

                                  • 14. Re: recover values rich:dataTable
                                    rodmen
                                    Hi, Nick

                                    This is in my faces-config, and the bean is to big so ill attach it

                                     

                                    <managed-bean>
                                    <managed-bean-name>pedidoBBean</managed-bean-name>
                                    <managed-bean-class>com.notmusa.comercial.backingBeans.PedidoBBean</managed-bean-class>
                                    <managed-bean-scope>request</managed-bean-scope>
                                    </managed-bean>
                                    <managed-bean>
                                    <managed-bean-name>detallePedidoBean</managed-bean-name>
                                    <managed-bean-class>com.notmusa.comercial.backingBeans.DetallePedidoBBean</managed-bean-class>
                                    <managed-bean-scope>request</managed-bean-scope>
                                    </managed-bean>
                                    <managed-bean>
                                    <managed-bean-name>pedidoMBean</managed-bean-name>
                                    <managed-bean-class>com.notmusa.comercial.managedBeans.PedidoMBean</managed-bean-class>
                                    <managed-bean-scope>request</managed-bean-scope>
                                    </managed-bean>
                                    thank you
                                    1 2 Previous Next