Hi guys,
it is not a myfaces question but i'm crazying and i've read your
forums,viewing your ability to solve lots of problem...
i need your help,please,i have this problem from 15 days...
i've developed a datatable for input fields that,depending of number n
inserted by user,creates n columns...
each ROW of datatable is an input form.
My application has to collect data retrieved from each row and put them into
a db...
my question is:
I've created an arraylist for collect rows and each rows is an arraylist of
values..i've passed empty rows to arraylist
public void loadMyList() {
                ArrayList row1=new ArrayList();
                ArrayList row2=new ArrayList();
                ArrayList row3=new ArrayList();
                //Convert rows to List and set the List.
                myList = new ArrayList();
                myList.add(row1);
                myList.add(row2);
                myList.add(row3);
                setMyList(myList);
}

With this method i populate datatable with 5 columns

public void populateMyDataTable() {

                // Any columns?
                if (myList != null && myList.size() > 0) {
                        myDynamicDataTable = new HtmlDataTable();

                        
                        for (int i = 0; i < 5; i++) {

                                
                                // Set output.
                                UIInput output = new UIInput();
                                ValueBinding myItem = 
FacesContext.getCurrentInstance()
                                                
.getApplication().createValueBinding(
                                                                "#{myItem[" + i 
+ "]}");
                                output.setValueBinding("value", myItem);

                                // Set column.
                                
                                
                                UIColumn column = new UIColumn();
                                column.setHeader(header);
                                column.getChildren().add(output);
                                
                                
                                
                                // Add column.
                                myDynamicDataTable.getChildren().add(column);
                                
                        }
                }
        }


this is my edit button for each row

public void editMyData(ActionEvent e) {
                try {
                        
                        myList = (List) getMyDynamicDataTable().getRowData();
                                                
                        for (int i=0;i<myList.size();i++){
                                System.out.println("elemento "+myList.get(i));
                        }
                } catch (Exception g) {
                        g.printStackTrace();
                        System.out.println("errore nell'item
"+getMyDynamicDataTable().getRowIndex());
                }

        }

i've retrieved rowdata into a list,the problem is that THIS LIST HAS ONLY
NULL VALUES!!
The cause is i've passed an empty rows list,but how can i retried values
inserted in a second moment?
I hope you can help,this is my jsp page....i'm waiting for you help...
<h:dataTable  var="myItem" value="#{myBean.myList}"
binding="#{myBean.myDynamicDataTable}">
    
         
          <h:column>
            <f:facet name="header">
              <h:outputText value="ID" />
            </f:facet>
            <h:commandButton actionListener="#{myBean.editMyData}">
             
            </h:commandButton>
          </h:column>
        </h:dataTable>
-- 
View this message in context: 
http://www.nabble.com/a-little-help-about-datatable...-tf2292675.html#a6368243
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to