# Renderer.java Sample

This topic inludes the source code for the Renderer.java Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/ExtensionDevKit/TaglibExtDevKit/TldxHandlers/TDK/

## Sample Source Code

`01 package TDK; 02 03 import TDK.BarcodeEncodings.Slice; 04 import TDK.BarcodeEncodings.tokenEncoding; 05 import com.bea.ide.jspdesigner.IHTMLWriter; 06 import com.bea.ide.lang.jsp.IDOMNode; 07 import com.bea.ide.lang.jsp.IDOMTextNode; 08 import com.bea.ide.lang.jsp.IJspAction; 09 import java.util.ArrayList; 10 import java.util.ListIterator; 11 12 public class Renderer extends com.bea.ide.jspdesigner.Renderer 13 { 14 /** 15 * creates the design time html-representation of the barcode tag. 16 */ 17 public void writeTag(IHTMLWriter writer, IDOMNode node) 18 { 19 IJspAction el = (IJspAction) node; 20 Object attr = el.getAttribute("encodingType"); 21 String encodingType = attr != null ? attr.toString() : ""; 22 attr = el.getAttribute("value"); 23 String value = attr != null ? attr.toString() : ""; 24 25 StringBuffer html = new StringBuffer(); 26 html.append("<br /><br />"); 27 28 if(encodingType.equals("code39")) 29 { 30 try 31 { 32 html.append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"); 33 html.append("<tr>\n"); 34 35 ArrayList enc = BarcodeEncodings.generateCode39(value); 36 ListIterator encodingIter = enc.listIterator(); 37 while(encodingIter.hasNext()) 38 { 39 // <!-- begin token TABLE --> 40 html.append("<td>\n"); 41 html.append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"); 42 html.append("<tr>\n"); 43 tokenEncoding tEncoding = (tokenEncoding) encodingIter.next(); 44 ArrayList slices = tEncoding.slices; 45 ListIterator slicesIter = slices.listIterator(); 46 int count = 0; 47 while(slicesIter.hasNext()) 48 { 49 Slice slice = (Slice)slicesIter.next(); 50 count++; 51 52 html.append("<td width=\"" + slice.width + "px\" height=\"" + slice.height + "px\" bgcolor=\"" + slice.color + "\">\n"); 53 html.append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"); 54 html.append("<tr>\n"); 55 html.append("<td width=\"" + slice.width + "px\" height=\"" + slice.height + "px\" bgcolor=\"" + slice.color + "\"></td>\n"); 56 html.append("</tr>\n"); 57 html.append("</table>\n"); 58 html.append("</td>\n"); 59 60 } // end inner while. 61 62 html.append("</tr>\n"); 63 html.append("<tr>\n"); 64 html.append("<td align=\"center\" style=\"font:9px Verdana, sans-serif;\" colspan=\"" + count + "\">\n"); 65 html.append(tEncoding.token + "\n"); 66 html.append("</td>\n"); 67 html.append("</tr>\n"); 68 html.append("</table>\n"); 69 html.append("</td>\n"); 70 // <!-- end token TABLE --> 71 72 } // end outer while. 73 74 html.append("</tr>\n"); 75 html.append("</table>\n"); 76 } 77 catch(Exception e) { e.printStackTrace(); } 78 } 79 80 html.append("<br /><br />"); 81 writer.write(html.toString()); 82 } 83 }`