You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jorge Quiroga <jq...@pctltda.com> on 2006/02/09 15:38:40 UTC

contrib:Table only show headers but no rows

Hi all:

It's the first time that I use a contrib:Table component, and I
apologize if the question is stupid or obvious, but I cannot find a
solution for it. The problem is that the Table only shows the column
header but not data. The data is into a List and is plenty of
information, I can verify it with the debugger that execute the setter 
of information, the result List is on a @Persist ("session"). I try the
same as the thread titled "contrib:Table  advices requested" that
bridgemind's latest response suggest (The getter is the procedure that
fills the data not the abstract), but nothing, I change the result from
arrayList[] to List and the same result. I had been reading the
TapestryTables demo but I didn't find a solution. I'm missing something
but I don't know what yet.

this is the related code:

.html

           <table class="mytable" jwcid="tblResult@contrib:Table"
             source="ognl:resultDatos"
             columns="ognl:listCamposUser">
...
</table>

.java

this is the listener that performs the search depending of some parameters

     public void onSearch(IRequestCycle cycle){
         User usr=getUser();
         List camposTabla = getCamposUser();
         List result = new ArrayList(camposTabla.size());
         int i;

         try{
             usr.getConsulta().execSQL(usr.getConsulta().getVigencia(), "");
             List resultado = getUser().getConsulta().getResultado();
             for (i=0;i<camposTabla.size();i++){
                 if (((TCampo)camposTabla.get(i)).isForUser() &&
((TCampo)camposTabla.get(i)).isVisible())
                     result.add(resultado.get(i));
             }
             setResultDatos(result);
         }
         catch (IOException e)

... // catching other exceptions
     }

     @Persist("session")
     public abstract List getResultDatos();
     public abstract void setResultDatos(List Result);

//This is setted when the page is charged and returns a list of field
names separated by commas

     @Persist("session")
     public abstract void setListCamposUser(String strCampos);
     public abstract String getListCamposUser();


The List is formed by a set of ArrayList[], where each ArrayList has the
information of each column of the query. The Query is dynamically
generated and isn´t possible in design-time to determine how many
columns will have, and the idea is that the final user selects which
columns will be showed. I try with only one column and hard-coded column 
title in the .HTML but the same result (selecting only the first subarray).


The second version shows these results and the paging doesn't work.

Número de documento Rubro Valor transacción Transacción Fecha documento
Fecha operación
[12483, 12484, 12487, 25, 15, 20, 34, 2, 45, 116, 115, 120, 117, 128,
121, 123, 109, 108, 90, 114, 53, 54, 129, 110, 124, 105, 106, 107, 97,
96, 95, 98, 102, 93, 94, 126, 72, 75, 77, 104, 180, 178, 183, 179, 182,
190, 158, 162, 153, 155, 154, 159, 156, 157, 161, 160, 196, 197, 198,
200, 215, 216, 205, 212, 210, 211, 213, 733, 6647, 11940, 12196, 12244,
12483, 12484, 12487, 1800, 2200, 487, 488, 556, 557, 598,

And the data changes for other values bellow but it doesn´t organize it,
as I expect. The problem AFAIK is because the data isn't "row-oriented"
(as in the TapestryTables example where you know the number of columns)
but "column-oriented" and each value is took as an array and not as the
one value on each Array in the same position.

the .java is

         User usr=getUser();
         List camposTabla = new ArrayList();
         ArrayList result = new ArrayList();
         SimpleTableColumnModel resultColumnModel;
         int i;

         try{
             usr.getConsulta().execSQL(usr.getConsulta().getVigencia(), "");
             List resultado = getUser().getConsulta().getResultado();
             for (i=0;i<getCamposUser().size();i++){
                 if (((TCampo)getCamposUser().get(i)).isForUser() &&
((TCampo)getCamposUser().get(i)).isVisible())
                     camposTabla.add(new
SimpleTableColumn(((TCampo)getCamposUser().get(i)).getNomCampo(),
((TCampo)getCamposUser().get(i)).getDisplayName(), true));
                     result.add(resultado.get(i));
             }
             resultColumnModel = new SimpleTableColumnModel(camposTabla);
             setResultDatos(new SimpleTableModel(result.toArray(),
resultColumnModel));
         }
         catch (IOException e)
... //Other catches
}

and the HTML

           <table class="mytable" jwcid="tblResult@contrib:Table"
             tableModel="ognl:resultDatos">

Of course I adjust the resultDatos getter and setter.

the result Array is build in this way, and I believe that is the problem:

                 try
                 {
                     rs = pstmt.executeQuery();
                     NumColumns = 0;
                     rsMeta = rs.getMetaData();
                     NumColumns = rsMeta.getColumnCount();
                 }
                 catch (SQLException ex){
                     throw (ex);
                 }
                 lstResultado = new ArrayList[NumColumns];
                 for (i=0;i<NumColumns;i++){
                     lstResultado[i] = new ArrayList();
                 }
                 rs.next();
                 while (!rs.isAfterLast()){
                     for (c=1; c<=NumColumns; c++){
                         lstResultado[c-1].add(rs.getObject(c));
                     }
                     rs.next();
                 }

Another try was row-oriented, but because the number of columns is 
unknown then each row is an array object who is retrieved with 
[@Ljava.lang.Object;@d826 ... and hide or show columns will be quite 
inefficient.

Can someone give me some suggestions about why this table doesn´t show
the information? or to show it correctly with the assumption of unknown 
number of columns?


Thanks in advance.

JQ


PD: I working on Tap4 with tomcat 5.5.12



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org