${ /* * Return a string of table headers of the form : * '<th><a href="...">header 1</a></th><th><a href="...">header 2</a></th>...' * * columns - A pipe delimited list of column headers * sbcolumns - A pipe delimited list of column ids correspondent to column headers * that may be sorted by. If a certain column can't be sorted by than pass '-' for * that sbcolumn * sortby - The column id currently being sorted by * * The linked headers pass the variable <tablename>_sortb, the value of this variable * can be tacked on to a ORDER BY at the end of a sql query. */ String tableHeader(String columns,String sbcolumns,String sortby,String tablename) { StringBuffer buf = new StringBuffer(); String curtok, cursbtok; Tokenizer tok= new Tokenizer(columns,'|'); Tokenizer sbtok = new Tokenizer(sbcolumns,'|'); while((curtok = tok.next())!=null) { cursbtok = sbtok.next(); if(cursbtok eq sortby) buf.append("<th height=18 class=\"selected\" nowrap> "); else buf.append("<th height=18 nowrap> "); if(cursbtok ne sortby && cursbtok ne "-"){ buf.append( "<a href=\""); buf.append( getRequest().getURI().substring(getRequest().getURI().lastIndexOf('/')+1)); buf.append( "?sid="+state.getSID()+"&"+tablename+"_sortby="+urlEncode(cursbtok)); buf.append( "\">"); } buf.append(curtok); if(cursbtok ne sortby && cursbtok ne "-") buf.append("</a>"); buf.append(" </th>"); } return buf.toString(); } }$
| |
Copyright © 2000 - 2003 David Hakim