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.eperson.EPerson; 51 52 75 public class SelectEPersonTag extends TagSupport 76 { 77 78 private boolean multiple; 79 80 81 private EPerson[] epeople; 82 83 public SelectEPersonTag() 84 { 85 super(); 86 } 87 88 94 public void setMultiple(String s) 95 { 96 if ((s != null) 97 && (s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("true"))) 98 { 99 multiple = true; 100 } 101 else 102 { 103 multiple = false; 104 } 105 } 106 107 113 public void setSelected(Object e) 114 { 115 if (e instanceof EPerson) 116 { 117 epeople = new EPerson[1]; 118 epeople[0] = (EPerson) e; 119 } 120 else if (e instanceof EPerson[]) 121 { 122 epeople = (EPerson[]) e; 123 } 124 } 125 126 public void release() 127 { 128 multiple = false; 129 epeople = null; 130 } 131 132 public int doStartTag() throws JspException 133 { 134 try 135 { 136 JspWriter out = pageContext.getOut(); 137 HttpServletRequest req = (HttpServletRequest ) pageContext 138 .getRequest(); 139 140 out.print("<table><tr><td colspan=\"2\" align=\"center\"><select multiple=\"multiple\" name=\"eperson_id\" size=\""); 141 out.print(multiple ? "10" : "1"); 142 out.println("\">"); 143 if (epeople == null || epeople.length == 0) 145 { 146 out.print("<option value=\"\"> </option>"); 147 } 148 149 if (epeople != null) 150 { 151 for (int i = 0; i < epeople.length; i++) 152 { 153 out.print("<option value=\"" + epeople[i].getID() + "\">"); 154 out.print(epeople[i].getFullName() + " (" 155 + epeople[i].getEmail() + ")"); 156 out.println("</option>"); 157 } 158 } 159 out.print("</select></td>"); 162 163 if (multiple) 164 { 165 out.print("</tr><tr><td width=\"50%\" align=\"center\">"); 166 } 167 else 168 { 169 out.print("<td>"); 170 } 171 172 String p = (multiple ? 173 LocaleSupport.getLocalizedMessage(pageContext, 174 "org.dspace.app.webui.jsptag.SelectEPersonTag.selectPeople") 175 : LocaleSupport.getLocalizedMessage(pageContext, 176 "org.dspace.app.webui.jsptag.SelectEPersonTag.selectPerson") ); 177 out.print("<input type=\"button\" value=\"" + p 178 + "\" onclick=\"javascript:popup_window('" 179 + req.getContextPath() + "/tools/eperson-list?multiple=" 180 + multiple + "', 'eperson_popup');\" />"); 181 182 if (multiple) 183 { 184 out.print("</td><td width=\"50%\" align=\"center\">"); 185 out.print("<input type=\"button\" value=\"" 186 + LocaleSupport.getLocalizedMessage(pageContext, 187 "org.dspace.app.webui.jsptag.SelectEPersonTag.removeSelected") 188 + "\" onclick=\"javascript:removeSelected(window.document.forms[0].eperson_id);\"/>"); 189 } 190 191 out.println("</td></tr></table>"); 192 } 193 catch (IOException ie) 194 { 195 throw new JspException (ie); 196 } 197 198 return SKIP_BODY; 199 } 200 } 201 | Popular Tags |