Java - cargar los datos en una tabla dependiendo de la cantidad de productos

 
Vista:
sin imagen de perfil

cargar los datos en una tabla dependiendo de la cantidad de productos

Publicado por undertaker (61 intervenciones) el 09/10/2013 05:59:42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
private static void creaDescripcionTabla(Section subCatPart, int idpc) throws BadElementException, IOException, java.lang.ClassNotFoundException,
            java.lang.InstantiationException,
            java.lang.IllegalAccessException,
            java.sql.SQLException, ParseException, MyError, DocumentException {
 
        PdfPTable table = new PdfPTable(2);
 
 
        PdfPCell c6 = new PdfPCell(new Phrase("TITULO", smallBold));
        c6.setVerticalAlignment(Element.ALIGN_CENTER);
        c6.setRowspan(1);
        c6.setPadding(3.0f);
        c6.setBackgroundColor(BaseColor.GRAY);
 
 
        Detalle otr = new Detalle();
        ArrayList r3 = otr.cargarDetalle(id);
        Iterator iterador3 = r3.iterator();
        int index = 0;
        index = r3.size();
 
        if (r3.size() == 1) {
            table.addCell(c6);
            Paragraph a1 = new Paragraph(String.valueOf(otr.getID));
            a1.setAlignment(1);
            table.addCell(a1);
 
        } else {
            while (iterador3.hasNext()) {
                otr = (Detalle) iterador3.next();
                table.addCell(c6);
                table.addCell(String.valueOf(otr.getId()));
                index++;
            }
        }
 
        subCatPart.add(table);
    }


Buenas necesito ayuda en esto
resulta que tengo una tabla detalle
tiene id_prod y id_venta

por cada puedes tener 1 o mas productos, por lo tanto quiero cargar una tabla que cuando alla mas de 2 productos me cargue los datos
y cuando es 1 solo me cargue ese

Lo que estoy haciendo solo me carga cuando es mas de 1 datos



esto es itext

la tabla que quiero es asi

CUANDO SON DOS O MAS PROD EN UNA SOLA VENTA

TITULO 1
TITULO 2


Y CUANDO ES SOLO 1 PROD EN UNA VENTA

TITULO 1
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder