hi folks, thanks for the suggetion. I am not trying to write a templating system. I am trying to do something different, maybe an example will elaborate. I have a utility function printTable1 that I want to use it to print different tables because the tables in my jsps share a lot of common structures. with this utility function, I can avoid a lot of redundency in my jsp code. This obviously doesn't work if I insert struts taglibs into it. but I also want to use struts taglibs. How do I solve this problem? How do I use tiles to solve this problem?
[code] public static void printTable1(JspWriter writer, Vector header, Vector content, String tableStyle, String tableHeaderStyle, String contentStyle){ StringBuffer s=new StringBuffer("<div id=\"").append(tableStyle).append("\">"); s.append("<table>"); s.append("<tr>"); Object obj=null; String cell=null; for(int i=0;i<header.size();i++){ obj=header.get(i); if(obj!=null){ cell=obj.toString(); } else cell=""; s.append("<td class=\"").append(tableHeaderStyle).append("\">").append(cell).append("</td>"); } s.append("</tr>"); for(int i=0;i<content.size();i++){ Vector row=(Vector)content.get(i); s.append("<tr>"); for(int j=0;j<row.size();j++){ obj=row.get(j); if(obj==null)cell=""; else cell=obj.toString(); if(contentStyle!=null){ s.append("<td class=\"").append(contentStyle).append("\">"); } else s.append("<td>"); s.append(cell).append("</td>"); } s.append("</tr>"); } s.append("</table></div>"); try { writer.println(s); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } [/code] --- Max Cooper <[EMAIL PROTECTED]> wrote: > Don't write your own page templating system. Use > Tiles instead. > > -Max > > On Tue, 2005-03-08 at 16:32 -0800, wo_shi_ni_ba_ba > wrote: > > Hi folks, > > In my webapplications there are many html page > with > > the similar look and structure. I am trying to > factor > > out them. So I created utility functions to print > out > > html code to the jspWriter. But I am not able to > > incorporate struts tags into these functions > because > > they will just be printed without being rendered > > through the struts engine. > > So if I print <struts:radio .../> it will come out > > like <struts:radio.../> without any change. > > On the other hand if I don't incorporate struts > tags > > into my utility functions and use just plain html > > code, I don't get to take the full advantage of > struts > > tags. > > How do I get around this problem? > > thanks > > > > > > > > > > > > __________________________________ > > Celebrate Yahoo!'s 10th Birthday! > > Yahoo! Netrospective: 100 Moments of the Web > > http://birthday.yahoo.com/netrospective/ > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __________________________________ Celebrate Yahoo!'s 10th Birthday! Yahoo! Netrospective: 100 Moments of the Web http://birthday.yahoo.com/netrospective/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]