1 40 package org.dspace.app.webui.jsptag; 41 42 import java.io.IOException ; 43 44 import javax.servlet.http.HttpServletRequest ; 45 import javax.servlet.jsp.JspException ; 46 import javax.servlet.jsp.JspWriter ; 47 import javax.servlet.jsp.jstl.fmt.LocaleSupport; 48 import javax.servlet.jsp.tagext.TagSupport ; 49 50 import org.dspace.content.Community; 51 52 58 public class CommunityListTag extends TagSupport 59 { 60 61 private Community[] communities; 62 63 public CommunityListTag() 64 { 65 super(); 66 } 67 68 public int doStartTag() throws JspException 69 { 70 JspWriter out = pageContext.getOut(); 71 72 try 73 { 74 out.println("<table align=\"center\" class=\"miscTable\" title=\"Community List\">"); 75 76 out.print("<tr><th id=\"t5\" class=\"oddRowOddCol\">" 78 + LocaleSupport.getLocalizedMessage(pageContext, 79 "org.dspace.app.webui.jsptag.CommunityListTag.communityName") 80 + "</th></tr>"); 81 82 String row = "even"; 84 85 for (int i = 0; i < communities.length; i++) 86 { 87 String name = communities[i].getMetadata("name"); 89 90 out.print("<tr><td headers=\"t5\" class=\"" + row + "RowEvenCol\">"); 92 out.print("<a HREF=\""); 93 94 HttpServletRequest hrq = (HttpServletRequest ) pageContext 95 .getRequest(); 96 out.print(hrq.getContextPath() + "/handle/"); 97 out.print(communities[i].getHandle()); 98 out.print("\">"); 99 out.print(name); 100 out.print("</a>"); 101 102 out.println("</td></tr>"); 103 104 row = (row.equals("odd") ? "even" : "odd"); 105 } 106 107 out.println("</table>"); 108 } 109 catch (IOException ie) 110 { 111 throw new JspException (ie); 112 } 113 114 return SKIP_BODY; 115 } 116 117 122 public Community[] getCommunities() 123 { 124 return communities; 125 } 126 127 133 public void setCommunities(Community[] communitiesIn) 134 { 135 communities = communitiesIn; 136 } 137 138 public void release() 139 { 140 communities = null; 141 } 142 } 143 | Popular Tags |