Beispiel #1
0
  @Override
  protected String getEditXHTMLCode(ContentContext ctx) throws Exception {
    StringWriter writer = new StringWriter();
    PrintWriter out = new PrintWriter(writer);

    GlobalContext globalContext = GlobalContext.getInstance(ctx.getRequest());

    List<String> selectedUser = getUserIds();

    IUserFactory userFact =
        AdminUserFactory.createUserFactory(globalContext, ctx.getRequest().getSession());
    List<IUserInfo> users = userFact.getUserInfoList();
    for (IUserInfo user : users) {
      String userName = user.getLogin();
      out.println("<span class=\"line-inline\">");
      String checked = "";
      String inputName = getId(userName);
      if (selectedUser.contains(user.getLogin())) {
        checked = " checked=\"checked\"";
      }
      out.println(
          "<input type=\"checkbox\" name=\""
              + inputName
              + "\" id=\""
              + getId(userName)
              + "\""
              + checked
              + " />");
      out.println("<label for=\"" + getId(userName) + "\">" + userName + "</label>");
      out.println("</span>");
    }

    out.close();
    return writer.toString();
  }
Beispiel #2
0
  @Override
  public void performEdit(ContentContext ctx) throws Exception {
    RequestService requestService = RequestService.getInstance(ctx.getRequest());

    GlobalContext globalContext = GlobalContext.getInstance(ctx.getRequest());

    IUserFactory userFact =
        AdminUserFactory.createUserFactory(globalContext, ctx.getRequest().getSession());
    List<IUserInfo> users = userFact.getUserInfoList();
    List<String> selectedUserName = new LinkedList<String>();
    for (IUserInfo userInfo : users) {
      String userParamName = getId(userInfo.getLogin());
      if (requestService.getParameter(userParamName, null) != null) {
        selectedUserName.add(userInfo.getLogin());
      }
    }

    String value = StringHelper.collectionToString(selectedUserName);
    if (!value.equals(getValue())) {
      setValue(value);
      setModify();
    }
  }
Beispiel #3
0
  @Override
  public void prepareView(ContentContext ctx) throws Exception {
    StringWriter writer = new StringWriter();
    PrintWriter out = new PrintWriter(writer);

    GlobalContext globalContext = GlobalContext.getInstance(ctx.getRequest());

    List<String> selectedUser = getUserIds();

    IUserFactory userFact =
        AdminUserFactory.createUserFactory(globalContext, ctx.getRequest().getSession());
    List<IUserInfo> users = userFact.getUserInfoList();
    List<IUserInfo> finalUsers = new LinkedList<IUserInfo>();
    for (IUserInfo user : users) {
      String userName = user.getLogin();
      out.println("<span class=\"line-inline\">");
      String checked = "";
      String inputName = getId(userName);
      if (selectedUser.contains(user.getLogin())) {
        finalUsers.add(user);
      }
      out.println(
          "<input type=\"checkbox\" name=\""
              + inputName
              + "\" id=\""
              + getId(userName)
              + "\""
              + checked
              + " />");
      out.println("<label for=\"" + getId(userName) + "\">" + userName + "</label>");
      out.println("</span>");
    }

    ctx.getRequest().setAttribute("users", finalUsers);

    out.close();
  }