public Iterator<Course> iterator(int first, int count) {
    List<Course> newList = new ArrayList<Course>();
    newList.addAll(list.subList(first, first + count));

    final String sortColumn = this.getSort().getProperty();
    final boolean ascending = this.getSort().isAscending();

    Collections.sort(
        newList,
        new Comparator<Object>() {

          public int compare(Object obj1, Object obj2) {
            PropertyModel model1 = new PropertyModel(obj1, sortColumn);
            PropertyModel model2 = new PropertyModel(obj2, sortColumn);

            Object modelObject1 = model1.getObject();
            Object modelObject2 = model2.getObject();

            int compare = ((Comparable<Object>) modelObject1).compareTo(modelObject2);

            if (!ascending) compare *= -1;

            return compare;
          }
        });

    for (final Course course : list) {

      strlen = course.getName().length();
      if (strlen > 20) {
        strlen = 20;
        course.setName(course.getName().substring(0, strlen) + "...");
      }
      if ((filter.getName() != null)
          && !course.getName().toLowerCase().contains(filter.getName().toLowerCase())) {
        newList.remove(course);
      }

      if ((filter.getOwner() != null)
          && (filter.getOwner() != null)
          && (filter.getOwner().getLogin() != null)
          && !course
              .getOwner()
              .getName()
              .toLowerCase()
              .contains(filter.getOwner().getName().toLowerCase())) {
        newList.remove(course);
      }

      if ((filter.getPrice() != 0) && (filter.getPrice() > course.getPrice())) {
        newList.remove(course);
      }

      if ((filter.getTown() != null)
          && !course.getTown().toLowerCase().contains(filter.getTown().toLowerCase())) {
        newList.remove(course);
      }

      if ((filter.getCourseType() != null)
          && !course
              .getCourseType()
              .getName()
              .toLowerCase()
              .contains(filter.getCourseType().getName().toLowerCase())) {
        newList.remove(course);
      }

      if ((filter.getCounty() != null)
          && !course
              .getCounty()
              .getName()
              .toLowerCase()
              .contains(filter.getCounty().getName().toLowerCase())) {
        newList.remove(course);
      }

      /// preferencia mesta
      if (prefer && !course.getCounty().getName().equals(preferredTown.getName()))
        newList.remove(course);

      // ak je deaktivovany prispevok userom, moze ho vidiet iba dotycny user
      if (CourseOwner == null) {
        if (!course.isActive() && course.getOwner() != CourseOwner) newList.remove(course);
      }

      if ((CourseOwner == null && !course.isActive())) {
        newList.remove(course);
      }

      if ((CourseOwner == null && !course.isActive()) && course.getOwner() != CourseOwner) {
        newList.remove(course);
      }
    }

    return newList.iterator();
  }
    public UserDetailForm(final String id) {
      super(id);

      name = new TextField("name", new PropertyModel(properties, "name"));
      name.setRequired(true);
      name.setModelValue(user.getName());
      add(name);
      //	add(nameFeedback = new ComponentFeedbackPanel("nameFeedback",
      //			name));
      add(new Label("nameLabel", "Meno"));
      add(new FormComponentFeedbackBorder("border").add(name));

      surname = new TextField("surname", new PropertyModel(properties, "surname"));
      surname.setRequired(true);
      surname.setModelValue(user.getSurname());
      add(surname);
      //	add(surnameFeedback = new ComponentFeedbackPanel("surnameFeedback",
      //		surname));
      add(new Label("surnameLabel", "Priezvisko"));

      email = new TextField("email", new PropertyModel(properties, "email"));
      email.setRequired(true);
      email.setModelValue(user.getEmail());
      email.setEnabled(false);
      add(email);
      //	 			add(addressFeedback = new ComponentFeedbackPanel("addressFeedback",
      //	 					address));
      add(new Label("emailLabel", "Email"));

      login = new TextField("login", new PropertyModel(properties, "login"));
      login.setRequired(true);
      login.setModelValue(user.getLogin());
      login.setEnabled(false);
      add(login);
      //	 			add(loginNameFeedback = new ComponentFeedbackPanel("loginNameFeedback",
      //	 					loginName));
      add(new Label("loginLabel", "Login"));

      //	 			region= new TextField("region", new PropertyModel(properties,
      //	 					"region"));
      //	 			region.setRequired(false);
      //	 			region.setModelValue(user.getRegion());
      //	 			add(region);
      //	 			add(new Label("regionLabel","Region"));

      County mesto = new County();
      town = new DropDownChoice("town", new PropertyModel(mesto, "name"), TOWN_LIST);
      town.setRequired(false);
      if (user.getTown() != null) mesto.setName(user.getTown().getName());
      add(town);
      add(new Label("townLabel", "Town"));

      HandicapType postihnutie = new HandicapType();
      handicapType =
          new DropDownChoice(
              "handicapType", new PropertyModel(postihnutie, "name"), HANDICAPTYPE_LIST);
      handicapType.setRequired(false);
      if (user.getHandicapType() != null) postihnutie.setName(user.getHandicapType().getName());
      add(handicapType);
      add(new Label("handicapTypeLabel", "Handicap"));

      preferRegion = new CheckBox("preferRegion", new PropertyModel(properties, "preferRegion"));

      add(preferRegion);
      add(new Label("preferRegionLabel", "Preferujem"));

      add(new Label("registrationDateLabel", "Dátum registrácie:"));
      add(new Label("userRegistrationDateLabel", dateFormat.format(user.getRegistrationDate())));

      password = new PasswordTextField("password", new PropertyModel(properties, "password"));
      add(password);
      password.setRequired(false);
      //	 			add(passwordFeedback = new ComponentFeedbackPanel(
      //	 					"passwordFeedback", password));
      add(new Label("passwordLabel", "Heslo:"));

      passwordAgain =
          new PasswordTextField("passwordAgain", new PropertyModel(properties, "passwordAgain"));
      add(passwordAgain);
      passwordAgain.setRequired(false);
      //	 			add(passwordAgainFeedback = new ComponentFeedbackPanel("passwordAgainFeedback",
      //	 					passwordAgain));
      add(new Label("passwordAgainLabel", "Heslo znova"));

      add(submit = new Button("submit", new ResourceModel("button.submit")));
      //	 			add(submitFeedback = new ComponentFeedbackPanel("submitFeedback",
      //	 					submit));
    }