View Javadoc
1 package com.mlw.fps.view.taglib; 2 3 import java.util.Collection; 4 import java.util.Iterator; 5 6 import javax.servlet.jsp.JspException; 7 import javax.servlet.jsp.JspWriter; 8 import javax.servlet.jsp.PageContext; 9 10 import org.apache.struts.taglib.tiles.ComponentConstants; 11 import org.apache.struts.tiles.ComponentContext; 12 import org.apache.struts.tiles.beans.SimpleMenuItem; 13 import org.apache.struts.util.RequestUtils; 14 15 import com.mlw.fps.view.manager.ViewManager; 16 /*** 17 * 18 * @author Matthew Wilson 19 * @version $Revision: 1.3 $ 20 */ 21 public class TabsTag extends javax.servlet.jsp.tagext.BodyTagSupport 22 { 23 private String name; 24 25 /*** Creates new GridTag 26 */ 27 public TabsTag() 28 { 29 super(); 30 } 31 32 /*** 33 * @throws JspException 34 * @return 35 **/ 36 public int doStartTag() throws JspException 37 { 38 try 39 { 40 ViewManager manager = (ViewManager)pageContext.getSession().getAttribute("viewManager"); 41 String imageDir = "/fps/images/"+manager.getStyle()+"/tabs/"; 42 43 ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE); 44 45 Collection collection = (Collection)compContext.findAttribute(getName(), pageContext); 46 String selected = (String)compContext.findAttribute(getName()+".selected", pageContext); 47 48 StringBuffer sb = new StringBuffer(); 49 50 sb.append("\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n"); 51 sb.append(" <tr>\n"); 52 53 int i = 0; 54 boolean previousTabIsOn = false; 55 boolean isOn = false; 56 for(Iterator iter = collection.iterator(); iter.hasNext(); i++) 57 { 58 SimpleMenuItem item = (SimpleMenuItem)iter.next(); 59 isOn = item.getValue().equals(selected); 60 61 if( i == 0 ) 62 { 63 sb.append(" <th><img src=\"").append(imageDir).append("front_").append(isOn?"on":"off").append(".gif\"></th>\n"); 64 } 65 else 66 { 67 if (previousTabIsOn) 68 { 69 sb.append(" <th><img src=\"").append(imageDir).append("mid_").append(previousTabIsOn?"on":"off").append("2.gif\"/></th>\n"); 70 } 71 else 72 { 73 sb.append(" <th><img src=\"").append(imageDir).append("mid_").append(isOn?"on":"off").append("1.gif\"/></th>\n"); 74 } 75 76 } 77 78 sb.append(" <th nowrap class=\"tabs").append(isOn?"On":"Off").append("Line\"><a target=\"_top\" href=\"").append(item.getLink()).append("\">"); 79 sb.append( RequestUtils.message(pageContext, null, null, item.getValue(), null)); 80 sb.append("</a></th>\n"); 81 82 83 previousTabIsOn = isOn; 84 } 85 86 sb.append(" <th><img src=\"").append(imageDir).append("end_").append(isOn?"on":"off").append(".gif\"></th>\n"); 87 sb.append(" </tr>\n"); 88 sb.append("</table>\n"); 89 90 try 91 { 92 JspWriter out = pageContext.getOut(); 93 out.println( sb.toString() ); 94 } 95 catch(Exception e) 96 { 97 e.printStackTrace(); 98 } 99 100 } 101 catch(Exception e) 102 { 103 e.printStackTrace(); 104 } 105 106 return EVAL_BODY_AGAIN; 107 } 108 109 public int doEndTag() throws JspException 110 { 111 return SKIP_BODY; 112 } 113 114 /*** Getter for property name. 115 * @return Value of property name. 116 */ 117 public String getName() 118 { 119 return this.name; 120 } 121 122 /*** Setter for property name. 123 * @param name New value of property name. 124 */ 125 public void setName(String name) 126 { 127 this.name = name; 128 } 129 130 }

This page was automatically generated by Maven