1 40 41 package org.dspace.app.webui.jsptag; 42 43 import java.io.IOException ; 44 45 import javax.servlet.http.HttpServletRequest ; 46 import javax.servlet.jsp.JspException ; 47 import javax.servlet.jsp.JspWriter ; 48 import javax.servlet.jsp.jstl.fmt.LocaleSupport; 49 import javax.servlet.jsp.tagext.TagSupport ; 50 51 import org.dspace.eperson.Group; 52 53 71 public class SelectGroupTag extends TagSupport 72 { 73 74 private boolean multiple; 75 76 77 private Group[] groups; 78 79 80 public SelectGroupTag() 81 { 82 super(); 83 } 84 85 86 91 public void setMultiple(String s) 92 { 93 if (s != null && (s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("true"))) 94 { 95 multiple = true; 96 } 97 else 98 { 99 multiple = false; 100 } 101 } 102 103 108 public void setSelected(Object g) 109 { 110 if (g instanceof Group) 111 { 112 groups = new Group[1]; 113 groups[0] = (Group) g; 114 } 115 else if(g instanceof Group[]) 116 { 117 groups = (Group[]) g; 118 } 119 } 120 121 122 public void release() 123 { 124 multiple = false; 125 groups = null; 126 } 127 128 129 public int doStartTag() 130 throws JspException 131 { 132 try 133 { 134 JspWriter out = pageContext.getOut(); 135 HttpServletRequest req = (HttpServletRequest ) pageContext.getRequest(); 136 137 out.print("<table><tr><td colspan=\"2\" align=\"center\"><select multiple=\"multiple\" name=\"group_ids\" size=\""); 138 out.print(multiple ? "10" : "1"); 139 out.println("\">"); 140 141 if (groups == null || groups.length == 0) 143 { 144 out.print("<option value=\"\"> </option>"); 145 } 146 147 if (groups != null) 148 { 149 for (int i = 0; i < groups.length; i++) 150 { 151 out.print("<option value=\"" + groups[i].getID() + "\">"); 152 out.print(groups[i].getName() + " (" + groups[i].getID() + ")"); 153 out.println("</option>"); 154 } 155 } 156 157 out.print("</select></td>"); 158 159 if (multiple) 160 { 161 out.print("</tr><tr><td width=\"50%\" align=\"center\">"); 162 } 163 else 164 { 165 out.print("<td>"); 166 } 167 168 String p = (multiple ? 169 LocaleSupport.getLocalizedMessage(pageContext, 170 "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroups") 171 : LocaleSupport.getLocalizedMessage(pageContext, 172 "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroup") ); 173 out.print("<input type=\"button\" value=\"" + p 174 + "\" onclick=\"javascript:popup_window('" 175 + req.getContextPath() + "/tools/group-select-list?multiple=" 176 + multiple + "', 'group_popup');\" />"); 177 178 if (multiple) 179 { 180 out.print("</td><td width=\"50%\" align=\"center\">"); 181 out.print("<input type=\"button\" value=\"" 182 + LocaleSupport.getLocalizedMessage(pageContext, 183 "org.dspace.app.webui.jsptag.SelectGroupTag.removeSelected") 184 + "\" onclick=\"javascript:removeSelected(window.document.forms[0].group_ids);\"/>"); 185 } 186 187 out.println("</td></tr></table>"); 188 } 189 catch (IOException ie) 190 { 191 throw new JspException (ie); 192 } 193 194 return SKIP_BODY; 195 } 196 } 197 | Popular Tags |