package to.etc.domui.dom.html;

import to.etc.webapp.nls.*;

/**
 * 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);
		}
	}

	public void setHeaders(BundleRef b, String... keys) {
		forceRebuild();
		TR row = new TR();
		add(row);
		for(String s : keys) {
			TH th = new TH();
			row.add(th);
			th.setText(b.getString(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;
	}
}

@@ -340,36 +340,36 @@
 s);%0A%09%7D%0A%0A%09public 
-void
+TH%5B%5D
  setHeaders(Stri
@@ -427,32 +427,82 @@
 ();%0A%09%09add(row);%0A
+%09%09TH%5B%5D res = new TH%5Blabels.length%5D;%0A%09%09int ix = 0;%0A
 %09%09for(String s :
@@ -565,25 +565,58 @@
 tText(s);%0A%09%09
-%7D
+%09res%5Bix++%5D = th;%0A%09%09%7D%0A%09%09return res;
 %0A%09%7D%0A%0A%09public
@@ -616,20 +616,20 @@
 %09public 
-void
+TH%5B%5D
  setHead
@@ -714,16 +714,64 @@
 d(row);%0A
+%09%09TH%5B%5D res = new TH%5Bkeys.length%5D;%0A%09%09int ix = 0;%0A
 %09%09for(St
@@ -857,17 +857,162 @@
 (s));%0A%09%09
-%7D
+%09res%5Bix++%5D = th;%0A%09%09%7D%0A%09%09return res;%0A%09%7D%0A%0A%09public void setHeaderCssClasses(String cls) %7B%0A%09%09for(TH th : getChildren(TH.class))%0A%09%09%09th.setCssClass(cls);
 %0A%09%7D%0A%0A%09pr

Fix code so that headers are returned, and allow bulk setting of header styles