/* * Copyright (C) 2007 Jonathan Craven * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package fr.craven.test.jsf; import java.io.IOException; import java.util.List; import javax.faces.component.UIOutput; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; /** * UI class for the Tableau JSF component. * * @author Jonathan Craven */ public class UITableau extends UIOutput { public UITableau() { super(); return; } public void encodeBegin(FacesContext context) throws IOException { ResponseWriter writer = context.getResponseWriter(); String id = getClientId(context); List rangees = (List) getAttributes().get("contenu"); String style = (String) getAttributes().get("styleClass"); writer.startElement("table", this); writer.writeAttribute("class", style, null); int rowCtr = 0; for (Object[] cellules : rangees) { int cellCtr = 0; writer.startElement("tr", this); writer.writeAttribute("class", style, null); for (Object cellule : cellules) { writer.startElement("td", this); writer.writeAttribute("class", style, null); writer.writeAttribute("name", id + rowCtr + "@" + cellCtr, null); writer.writeText(cellule, null); writer.endElement("td"); cellCtr++; } writer.endElement("tr"); rowCtr++; } writer.endElement("table"); return; } public void encodeEnd(FacesContext context) throws IOException { return; } public void decode(FacesContext context) { return; } public String getFamily() { return "fr.craven.test.jsf.Tableau"; } }