View Javadoc
1 package com.mlw.fps.view.taglib; 2 3 import javax.servlet.jsp.JspException; 4 5 import org.apache.struts.util.RequestUtils; 6 import org.apache.struts.util.ResponseUtils; 7 8 import com.mlw.fps.view.form.AdvancedSortInfoForm; 9 import com.mlw.fps.view.form.SortInfoForm; 10 import com.mlw.fps.view.manager.ViewManager; 11 12 /*** 13 * 14 * @author Matthew Wilson 15 * @version $Revision: 1.3 $ 16 */ 17 public class HeaderColumnTag extends javax.servlet.jsp.tagext.TagSupport 18 { 19 private String width; 20 private String colspan; 21 private Integer direction; 22 private String sortable; 23 private String rowspan; 24 private String key; 25 private String property; 26 27 /*** Creates new GridTag 28 */ 29 public HeaderColumnTag() 30 { 31 super(); 32 } 33 34 public void release() 35 { 36 key = null; 37 property = null; 38 sortable = "true"; 39 direction = new Integer(-1); 40 } 41 42 /*** 43 * @throws JspException 44 * @return 45 **/ 46 public int doStartTag() throws JspException 47 { 48 ViewManager manager = (ViewManager)pageContext.getSession().getAttribute("viewManager"); 49 String imageDir = "/fps/images/"+manager.getStyle()+"/columns/"; 50 51 HeaderTag parent = (HeaderTag)getParent(); 52 AdvancedSortInfoForm sortInfo = parent.getSortInfoBean(); 53 StringBuffer sb = new StringBuffer(); 54 55 if( sortInfo.getDirection() == null ) sortInfo.setDirection( direction ); 56 57 sb.append("<th nowrap"); 58 if( colspan!=null ) sb.append(" colspan=\"").append( colspan ).append("\""); 59 if( rowspan!=null ) sb.append(" rowspan=\"").append( rowspan ).append("\""); 60 if( width!=null ) sb.append(" width=\"").append( width ).append("\""); 61 sb.append(">\n"); 62 63 sb.append("<table width=\"100%\" border=\"0\" cellspacing=\"0\"cellpadding=\"0\">"); 64 sb.append(" <tr>"); 65 sb.append(" <th align=\"left\" width=\"7\" valign=\"top\"><img src=\"").append(imageDir).append("left.gif\"/></th>"); 66 67 String title = RequestUtils.message(pageContext, null, null, key+".title", null); 68 sb.append(" <th title=\"").append(title).append("\"align=\"center\" nowrap class=\"column\">"); 69 70 71 if( property!=null ) 72 { 73 if( property!=null && sortInfo!=null && property.equals( sortInfo.getColumn() ) ) 74 { 75 sb.append("<img src=\"/fps/images/arrow("+sortInfo.getDirection()+").gif\" border=\"0\" />\n"); 76 sb.append("<a href=\"/fps").append(parent.getAction()); 77 sb.append("column=").append(property); 78 sb.append("&direction=").append(sortInfo.getDirection().intValue()*-1); 79 if( sortInfo.getKillerPk()!=null ) sb.append("&killerPk=").append(sortInfo.getKillerPk()); 80 if( sortInfo.getWeaponPk()!=null ) sb.append("&weaponPk=").append(sortInfo.getWeaponPk()); 81 sb.append("\">\n"); 82 } 83 else 84 { 85 sb.append("<a href=\"/fps").append(parent.getAction()); 86 sb.append("column=").append(property); 87 sb.append("&direction=").append(direction); 88 if( sortInfo.getKillerPk()!=null ) sb.append("&killerPk=").append(sortInfo.getKillerPk()); 89 if( sortInfo.getWeaponPk()!=null ) sb.append("&weaponPk=").append(sortInfo.getWeaponPk()); 90 sb.append("\">\n"); 91 } 92 } 93 94 if( key != null) 95 { 96 String message = RequestUtils.message(pageContext, null, null, key, null); 97 sb.append(message); 98 } 99 100 if( "true".equals(sortable) ) 101 { 102 sb.append("</a>\n"); 103 } 104 105 sb.append("</th>\n"); 106 sb.append("<th align=right valign=top width=7><img src=\"").append(imageDir).append("right.gif\"/></th>"); 107 sb.append("</tr>"); 108 sb.append("</table>"); 109 sb.append("</th>\n"); 110 111 ResponseUtils.write(pageContext, sb.toString()); 112 113 return EVAL_BODY_AGAIN; 114 } 115 116 public int doEndTag() throws JspException 117 { 118 return SKIP_BODY; 119 } 120 121 /*** Setter for property width. 122 * @param width New value of property width. 123 */ 124 public void setWidth(String width) 125 { 126 this.width = width; 127 } 128 129 /*** Setter for property colspan. 130 * @param colspan New value of property colspan. 131 */ 132 public void setColspan(String colspan) 133 { 134 this.colspan = colspan; 135 } 136 137 /*** Getter for property direction. 138 * @return Value of property direction. 139 */ 140 public String getDirection() 141 { 142 return direction.toString(); 143 } 144 145 /*** Setter for property direction. 146 * @param direction New value of property direction. 147 */ 148 public void setDirection(String direction) 149 { 150 this.direction = "desc".equals(direction)?SortInfoForm.DESCENDING:SortInfoForm.ASCENDING; 151 } 152 153 /*** Setter for property property. 154 * @param direction New value of property property. 155 */ 156 public void setProperty(String property) 157 { 158 this.property = property; 159 } 160 161 /*** Setter for property sortable. 162 * @param sortable New value of property sortable. 163 */ 164 public void setSortable(String sortable) 165 { 166 this.sortable = sortable; 167 } 168 169 /*** Getter for property rowspan. 170 * @return Value of property rowspan. 171 */ 172 public String getRowspan() 173 { 174 return rowspan; 175 } 176 177 /*** Setter for property rowspan. 178 * @param rowspan New value of property rowspan. 179 */ 180 public void setRowspan(String rowspan) 181 { 182 this.rowspan = rowspan; 183 } 184 185 /*** Getter for property key. 186 * @return Value of property key. 187 */ 188 public String getKey() 189 { 190 return this.key; 191 } 192 193 /*** Setter for property key. 194 * @param key New value of property key. 195 */ 196 public void setKey(String key) 197 { 198 this.key = key; 199 } 200 201 }

This page was automatically generated by Maven