public int doStartTag() throws JspException {
    try {
      JspWriter out = pageContext.getOut();
      HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();

      out.print(
          "<table><tr><td colspan=\"2\" align=\"center\"><select multiple=\"multiple\" name=\"group_ids\" size=\"");
      out.print(multiple ? "10" : "1");
      out.println("\">");

      // ensure that if no group is selected that a blank option is displayed - xhtml compliance
      if (groups == null || groups.length == 0) {
        out.print("<option value=\"\">&nbsp;</option>");
      }

      if (groups != null) {
        for (int i = 0; i < groups.length; i++) {
          out.print("<option value=\"" + groups[i].getID() + "\">");
          out.print(groups[i].getName() + " (" + groups[i].getID() + ")");
          out.println("</option>");
        }
      }

      out.print("</select></td>");

      if (multiple) {
        out.print("</tr><tr><td width=\"50%\" align=\"center\">");
      } else {
        out.print("<td>");
      }

      String p =
          (multiple
              ? LocaleSupport.getLocalizedMessage(
                  pageContext, "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroups")
              : LocaleSupport.getLocalizedMessage(
                  pageContext, "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroup"));
      out.print(
          "<input type=\"button\" value=\""
              + p
              + "\" onclick=\"javascript:popup_window('"
              + req.getContextPath()
              + "/tools/group-select-list?multiple="
              + multiple
              + "', 'group_popup');\" />");

      if (multiple) {
        out.print("</td><td width=\"50%\" align=\"center\">");
        out.print(
            "<input type=\"button\" value=\""
                + LocaleSupport.getLocalizedMessage(
                    pageContext, "org.dspace.app.webui.jsptag.SelectGroupTag.removeSelected")
                + "\" onclick=\"javascript:removeSelected(window.document.epersongroup.group_ids);\"/>");
      }

      out.println("</td></tr></table>");
    } catch (IOException ie) {
      throw new JspException(ie);
    }

    return SKIP_BODY;
  }
Esempio n. 2
0
 /**
  * Returns a i18n string for the supplied key.
  *
  * @param messageKey
  * @param defaultValue
  * @param pageContext
  * @return the i18n string for the supplied key
  */
 public static String getMessage(String messageKey, String defaultValue, PageContext pageContext) {
   // if messageKey isn't defined either, use defaultValue
   String key = (messageKey != null) ? messageKey : defaultValue;
   String message = LocaleSupport.getLocalizedMessage(pageContext, key);
   return message;
 }