import org.cacert.gigi.Language;
import org.cacert.gigi.output.DataTable.Cell;
-import org.cacert.gigi.output.DataTable.EmptyCell;
public class CertificateTable implements Outputable {
String resultSet;
rs.beforeFirst();
while (rs.next()) {
// out.println(rs.getString("id"));
- cells.add(new EmptyCell());
+ cells.add(new Cell());
cells.add(new Cell("State", false));
cells.add(new Cell(rs.getString("CN"), false));
cells.add(new Cell(rs.getString("serial"), false));
}
@Override
- protected String[] getColumns() {
- return new String[] { "Renew/Revoke/Delete", "Status",
- "Email Address", "SerialNumber", "Revoked",
- "Expires", "Login", "Comment*" };
+ protected Cell[] getColumns() {
+ return new Cell[] { new Cell("Renew/Revoke/Delete", true),
+ new Cell("Status", true),
+ new Cell("Email Address", true),
+ new Cell("SerialNumber", true),
+ new Cell("Revoked", true),
+ new Cell("Expires", true), new Cell("Login", true),
+ new Cell("Comment*", true, "colspan=\"2\"") };
}
};
t.output(out, l, vars);
import org.cacert.gigi.Language;
public abstract class DataTable implements Outputable {
- protected abstract String[] getColumns();
+ protected abstract Cell[] getColumns();
protected abstract LinkedList<Cell> getTableContent();
public void output(PrintWriter out, Language l, Map<String, Object> vars) {
out.println("<table align=\"center\" valign=\"middle\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"wrapper\">");
out.println("<tr>");
- for (String column : getColumns()) {
- out.print("<td class=\"DataTD\">");
- out.print(l.getTranslation(column));
+ for (Cell column : getColumns()) {
+ out.print("<td " + column.getHtmlAttribs() + " class=\"DataTD\">");
+ out.print(column.shouldTranslate() ? l.getTranslation(column
+ .getText()) : column.getText());
out.println("</td>");
}
out.println("</tr>");
for (int i = 0; i < tableContnet.size() / getColumns().length; i++) {
out.println("<tr>");
for (int j = 0; j < getColumns().length; j++) {
- out.println("<td class=\"DataTD\">");
Cell current = tableContnet.get((i * getColumns().length) + j);
+ out.println("<td " + current.getHtmlAttribs()
+ + " class=\"DataTD\">");
out.print(current.shouldTranslate() ? l.getTranslation(current
.getText()) : current.getText());
out.print("</td>");
out.println("</table>");
}
+ /**
+ * <b>Note:</b> All cells have the html attribute class="DataTD"!
+ *
+ * @author janis
+ *
+ */
public static class Cell {
- private String text;
+ private String text, htmlAttribs;
private boolean translate;
- public Cell(String text, boolean translate) {
+ public Cell() {
+ this(" ", false);
+ }
+
+ public Cell(String text, boolean translate, String htmlAttribs) {
this.text = text;
this.translate = translate;
+ this.htmlAttribs = htmlAttribs;
+ }
+
+ public Cell(String text, boolean translate) {
+ this(text, translate, "");
}
public boolean shouldTranslate() {
return text;
}
- }
-
- public static class EmptyCell extends Cell {
-
- public EmptyCell() {
- super(" ", false);
+ public String getHtmlAttribs() {
+ return htmlAttribs;
}
}