Skip to content

Instantly share code, notes, and snippets.

@tapichu
Forked from alonso-contreras/gist:593936
Created September 23, 2010 16:38
Show Gist options
  • Save tapichu/593938 to your computer and use it in GitHub Desktop.
Save tapichu/593938 to your computer and use it in GitHub Desktop.
public List getPromocionesSeleccionadas() {
List promociones = null;
List promoList = getPromociones();
if ( promoList != null && promoList.size() > 0 ) {
promociones = new ArrayList();
Iterator iter = promoList.iterator();
while (iter.hasNext()) {
Integer promoId = (Integer) iter.next();
String promocion = (String) promocionesDisponibles.get(promoId);
promociones.add(promocion);
}
}
return promociones;
}
// ******************
// *** Promociones ***
//
Integer promo1 = new Integer(1);
Promocion p1 = new Promocion();
p1.setDescripcion("25% DE DESCUENTO");
p1.setIdPromocion(promo1);
p1.setTipo(Tipo.MENSUALIDADES);
Integer promo2 = new Integer(2);
Promocion p2 = new Promocion();
p2.setDescripcion("30% DE DESCUENTO");
p2.setIdPromocion(promo2);
p2.setTipo(Tipo.MENSUALIDADES);
List promosSelecionadas1 = new ArrayList();
promosSelecionadas1.add(promo1);
promosSelecionadas1.add(promo2);
List promosSelecionadas2 = new ArrayList();
promosSelecionadas2.add(promo1);
Map promocionesDisponibles = new HashMap();
promocionesDisponibles.put(promo1, p1);
promocionesDisponibles.put(promo2, p2);
// Articulo 3
Integer a3ID = new Integer(3);
Articulo a3 = new Articulo(a3ID, "Samsung", "Cámara Digital 10.2 MP Plata",
"/img/item02.jpg", Articulo.Tipo.TIENDA, new BigDecimal(1999.0),
new BigDecimal(2500.0), new BigDecimal(1999.0 * 2),
new BigDecimal(2500.0 * 2), new Integer(2), new Date());
a3.setPromociones(promocionesSeleccionadas1);
a3.setPromocionesDisponibles(promocionesDisponibles);
// Articulo 4
Integer a4ID = new Integer(4);
Articulo a4 = new Articulo(a4ID, "Leonardo", "Portavela con Base",
"/img/item01.jpg", Articulo.Tipo.TIENDA, new BigDecimal(569.00),
new BigDecimal(569.00 * 3), new Integer(3), new Date());
a4.setPromociones(promocionesSeleccionadas2);
a4.setPromocionesDisponibles(promocionesDisponibles);
<c:if test="${articulo.promocionesSeleccionadas != null}">
<c:forEach items="${articulo.promocionesSeleccionadas" var="promocion">
<c:out value="${promocion}"></c:out>
</c:forEach>
</c:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment