package to.etc.domui.dom.html;

/**
 * A THEAD node.
 *
 * @author <a href="mailto:jal@etc.to">Frits Jalvingh</a>
 * Created on Jun 2, 2008
 */
public class THead extends NodeContainer {
	public THead() {
		super("thead");
	}

	@Override
	public void visit(INodeVisitor v) throws Exception {
		v.visitTHead(this);
	}

	public void setHeaders(String... labels) {
		forceRebuild();
		TR row = new TR();
		add(row);
		for(String s : labels) {
			TH th = new TH();
			row.add(th);
			th.setText(s);
		}
	}

	private TR getRow() {
		for(int i = getChildCount(); --i >= 0;) {
			NodeBase b = getChild(i);
			if(b instanceof TR)
				return (TR) b;
		}
		TR tr = new TR();
		add(tr);
		return tr;
	}

	public TH addHeader(String text) {
		TR tr = getRow();
		TH th = new TH();
		tr.add(th);
		th.setText(text);
		return th;
	}
}

@@ -25,16 +25,45 @@
 .html;%0A%0A
+import to.etc.webapp.nls.*;%0A%0A
 /**%0A * A
@@ -525,16 +525,223 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09public void setHeaders(BundleRef b, String... keys) %7B%0A%09%09forceRebuild();%0A%09%09TR row = new TR();%0A%09%09add(row);%0A%09%09for(String s : keys) %7B%0A%09%09%09TH th = new TH();%0A%09%09%09row.add(th);%0A%09%09%09th.setText(b.getString(s));%0A%09%09%7D%0A%09%7D%0A%0A
 %09private

Add setHeadings using a bundle to THead