View Javadoc
1 package com.mlw.fps.view.taglib; 2 3 import java.io.IOException; 4 import java.util.List; 5 6 import javax.servlet.jsp.JspException; 7 import javax.servlet.jsp.JspWriter; 8 import javax.servlet.jsp.PageContext; 9 import javax.servlet.jsp.tagext.BodyTagSupport; 10 11 import org.apache.struts.taglib.tiles.ComponentConstants; 12 import org.apache.struts.tiles.ComponentContext; 13 import org.apache.struts.tiles.beans.MenuItem; 14 import org.apache.struts.util.RequestUtils; 15 16 public class NavigationTag extends BodyTagSupport 17 { 18 protected String delim = " | "; 19 protected String name; 20 protected String selected; 21 22 public NavigationTag() 23 { 24 super(); 25 } 26 27 public int doStartTag() throws JspException 28 { 29 return EVAL_BODY_AGAIN; 30 } 31 32 public int doEndTag() throws JspException 33 { 34 ComponentContext compContext = (ComponentContext)pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE); 35 36 List list = (List)compContext.findAttribute(name, pageContext); 37 String mode = (String)compContext.findAttribute(name+".mode", pageContext); 38 String selectedNavi = (String)compContext.findAttribute(selected, pageContext); 39 40 StringBuffer sb = new StringBuffer(); 41 boolean doLinks = true; 42 43 44 if( list == null ) 45 { 46 sb.append(" <!--no "+name+" found.-->"); 47 return SKIP_BODY; 48 } 49 50 for( int i=0, size=list.size(); i<size; i++) 51 { 52 MenuItem item = (MenuItem)list.get(i); 53 String message = RequestUtils.message(pageContext, null, null, item.getValue(), null); 54 55 if("workflow".equals( mode ) ) 56 { 57 sb.append(" <td class=\"WorkflowText\" align=\"center\">"); 58 if( doLinks ) sb.append("<a href=\"").append(item.getLink()).append("\">"); 59 sb.append(message); 60 if( doLinks ) sb.append("</a>"); 61 sb.append("</td>\n"); 62 if( i+1 < size ) 63 { 64 sb.append(" <td> ").append("<img src=\"/cprim/images/buttons/cm_arrow.gif\" border=\"0\">").append(" </td>\n"); 65 } 66 67 if( item.getValue().equals(selectedNavi) ) 68 { 69 doLinks = false; 70 } 71 72 } 73 else 74 { 75 if( !item.getValue().equals(selectedNavi) ) 76 { 77 sb.append( "<a href=\"/cprim/"+item.getLink()+"\">"); 78 } 79 80 sb.append(message); 81 82 if( !item.getValue().equals(selectedNavi) ) 83 { 84 sb.append("</a>"); 85 } 86 87 if( i+1 < size ) 88 { 89 sb.append(delim); 90 } 91 } 92 } 93 94 if("workflow".equals( mode ) ) 95 { 96 sb.insert(0,"\n<table width=\"1\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tr>\n"); 97 sb.append("</tr>\n</table>\n"); 98 } 99 100 try 101 { 102 JspWriter out = pageContext.getOut(); 103 out.print(sb.toString()); 104 } 105 catch(IOException e) 106 { 107 } 108 109 return SKIP_BODY; 110 } 111 112 /*** Setter for property delim. 113 * @param delim New value of property delim. 114 */ 115 public void setDelim(String delim) 116 { 117 this.delim = delim; 118 } 119 120 /*** Setter for property name. 121 * @param name New value of property name. 122 */ 123 public void setName(String name) 124 { 125 this.name = name; 126 } 127 128 public void release() 129 { 130 selected = null; 131 name = null; 132 delim = " | "; 133 } 134 135 /*** Setter for property selected. 136 * @param selected New value of property selected. 137 */ 138 public void setSelected(String selected) 139 { 140 this.selected = selected; 141 } 142 143 }

This page was automatically generated by Maven