<%@ page import="org.apache.commons.lang.StringUtils" %> <%@ page import="br.org.cip.bo.AlbumBO" %> <%@ page import="br.org.cip.models.Album" %> <%@ page import="br.org.cip.models.AlbumItem" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Iterator" %> <% String rootFolder = request.getParameter("root"); if (StringUtils.isEmpty(rootFolder)) rootFolder = ".."; AlbumBO albumBO = new AlbumBO(); Album album = null; long paginaAtual = 0; long porPagina = 6; // conf.getLong("maxlimit") long totalAlbuns = albumBO.getTotalAlbuns(); if (request.getParameter("paginaAtual") != null) paginaAtual = new Long(request.getParameter("paginaAtual")).longValue(); if (paginaAtual < 0) paginaAtual = 0; if (paginaAtual > totalAlbuns/porPagina) paginaAtual = totalAlbuns/porPagina; long inicio = paginaAtual * porPagina; %>

<% ArrayList albums = albumBO.carregarVarias(inicio, porPagina, true); AlbumItem foto = null; String arqImg = null; Iterator it = albums.iterator(); ArrayList fotos = null; while (it.hasNext()) { album = (Album)it.next(); fotos = albumBO.carregarFotos(album.getId()); if (fotos.size() > 0 ) { foto = (AlbumItem)fotos.get(0); arqImg = foto.getArquivo(); } else { arqImg = null; } %> <% } %>
<% if (!StringUtils.isEmpty(arqImg)) { %> <% } %>
<%= album.getTitulo() %>
<% if (!StringUtils.isEmpty(album.getDescricao()) && album.getDescricao().length() > 160 ) { out.println(album.getDescricao().substring(0,160) + " ..."); } else { out.println(album.getDescricao()); } %>

Fotos: <%= album.getNumeroDeFotos() %>
<% if (it.hasNext()) { album = (Album)it.next(); fotos = albumBO.carregarFotos(album.getId()); if (fotos.size() > 0 ) { foto = (AlbumItem)fotos.get(0); arqImg = foto.getArquivo(); } else arqImg = null; %>
<% if (!StringUtils.isEmpty(arqImg)) { %> <% } %>
<%= album.getTitulo() %>
<% if (!StringUtils.isEmpty(album.getDescricao()) && album.getDescricao().length() > 160 ) { out.println(album.getDescricao().substring(0,160) + " ..."); } else { out.println(album.getDescricao()); } %>

Fotos: <%= album.getNumeroDeFotos() %>
<% } %>