protected String getAttributeValue(IWContext iwc, User user, String alias, String type) {
    if (OpenIDConstants.ATTRIBUTE_ALIAS_EMAIL.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_EMAIL.equals(type)) {
      Email email = null;
      try {
        email = getUserBusiness(iwc).getUsersMainEmail(user);
      } catch (NoEmailFoundException e) {
        /*No action...*/
      } catch (RemoteException e) {
        e.printStackTrace();
      }

      return (email != null ? email.getEmailAddress() : "");
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_PERSONAL_ID.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_PERSONAL_ID.equals(type)) {
      return (user.getPersonalID() != null ? user.getPersonalID() : "");
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_FULL_NAME.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_FULL_NAME.equals(type)) {
      return user.getName();
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_DATE_OF_BIRTH.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_DATE_OF_BIRTH.equals(type)) {
      return (user.getDateOfBirth() != null
          ? new IWTimestamp(user.getDateOfBirth()).toSQLDateString()
          : "");
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_GENDER.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_GENDER.equals(type)) {
      return (user.getGender() != null ? (user.getGender().isMaleGender() ? "M" : "F") : "");
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_NICKNAME.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_FRIENDLY_NAME.equals(type)) {
      return LoginDBHandler.getUserLogin(user).getUserLogin();
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_POSTCODE.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_POSTAL_CODE.equals(type)) {
      try {
        Address address = getUserBusiness(iwc).getUsersMainAddress(user);
        if (address != null) {
          PostalCode postal = address.getPostalCode();
          return postal != null ? postal.getPostalCode() : "";
        }
      } catch (RemoteException re) {
        re.printStackTrace();
      }
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_COUNTRY.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_COUNTRY.equals(type)) {
      try {
        Address address = getUserBusiness(iwc).getUsersMainAddress(user);
        if (address != null) {
          return address.getCountry().getIsoAbbreviation();
        }
      } catch (RemoteException re) {
        re.printStackTrace();
      }
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_LANGUAGE.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_LANGUAGE.equals(type)) {
      if (user.getPreferredLocale() != null) {
        Locale locale = LocaleUtil.getLocale(user.getPreferredLocale());
        return locale.getLanguage() + "-" + locale.getCountry();
      } else {
        try {
          Address address = getUserBusiness(iwc).getUsersMainAddress(user);
          if (address != null) {
            Country country = address.getCountry();
            return country.getIsoAbbreviation().toLowerCase() + "-" + country.getIsoAbbreviation();
          }
        } catch (RemoteException re) {
          re.printStackTrace();
        }
      }
    } else if (OpenIDConstants.ATTRIBUTE_ALIAS_TIMEZONE.equals(alias)
        || OpenIDConstants.ATTRIBUTE_TYPE_TIMEZONE.equals(type)) {
      try {
        Address address = getUserBusiness(iwc).getUsersMainAddress(user);
        if (address != null) {
          Country country = address.getCountry();
          Locale locale =
              new Locale(country.getIsoAbbreviation().toLowerCase(), country.getIsoAbbreviation());
          Calendar calendar = new GregorianCalendar(locale);

          return calendar.getTimeZone().getDisplayName(Locale.ENGLISH);
        }
      } catch (RemoteException re) {
        re.printStackTrace();
      }
    }

    return "";
  }
  private MemoryFileBuffer writeXls(IWContext iwc) throws IOException {
    MemoryFileBuffer buffer = new MemoryFileBuffer();
    MemoryOutputStream mos = new MemoryOutputStream(buffer);

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Rejected students list");

    int rowNum = 0;

    HSSFRow row = sheet.createRow((short) rowNum++);
    fillHeaderRow(wb, sheet, row);

    // retrieve data
    Collection schoolChoices = getSchoolChoices(iwc);

    // fill data into rows
    if (!schoolChoices.isEmpty()) {
      User applicant;
      School school;
      Address address;
      Phone phone;
      SchoolChoice choice;
      String name = null;

      for (Iterator iter = schoolChoices.iterator(); iter.hasNext(); ) {
        choice = (SchoolChoice) iter.next();
        row = sheet.createRow((short) rowNum++);
        try {
          applicant = getUserBusiness(iwc).getUser(choice.getChildId());
          school =
              getSchoolCommuneBusiness(iwc)
                  .getSchoolBusiness()
                  .getSchool(new Integer(choice.getCurrentSchoolId()));
          address = getUserBusiness(iwc).getUsersMainAddress(applicant);

          name = getSchoolCommuneBusiness(iwc).getUserBusiness().getNameLastFirst(applicant, true);

          row.createCell((short) 0).setCellValue(name);

          if (applicant.getPersonalID() != null) {
            row.createCell((short) 1)
                .setCellValue(PersonalIDFormatter.format(applicant.getPersonalID(), this.locale));
          }

          String emails = this.getParentsEmails(iwc, applicant);
          if (emails != null) {
            row.createCell((short) 2).setCellValue(emails);
          }

          if (address != null) {
            row.createCell((short) 3).setCellValue(address.getStreetAddress());
            row.createCell((short) 4).setCellValue(address.getPostalCode().getPostalCode());
            row.createCell((short) 5).setCellValue(address.getCity());
          }

          try {
            phone = getUserBusiness(iwc).getUsersHomePhone(applicant);

            // getUserBusiness(iwc).getUsers
            if (phone != null && phone.getNumber() != null) {
              row.createCell((short) 6).setCellValue(phone.getNumber());
            }
          } catch (NoPhoneFoundException npfe) {
            npfe.printStackTrace();
          }

          String genderString = null;
          if (PIDChecker.getInstance().isFemale(applicant.getPersonalID())) {
            genderString = this.iwrb.getLocalizedString("school.girl", "Girl");
          } else {
            genderString = this.iwrb.getLocalizedString("school.boy", "Boy");
          }
          row.createCell((short) 7).setCellValue(genderString);

          if (school != null) {
            String schoolName = school.getName();
            row.createCell((short) 8).setCellValue(schoolName);
          }

          String rejectionDateString =
              getLocalizedTimestamp(iwc, getRejectionTimestamp(iwc, choice));
          if (rejectionDateString != null) {
            row.createCell((short) 9).setCellValue(rejectionDateString);
          }

        } catch (Exception e) {
          e.printStackTrace(System.err);
        }
      }
    }

    wb.write(mos);

    buffer.setMimeType("application/x-msexcel");
    return buffer;
  }
  public Table getPupilTable(IWContext iwc, User pupil) {
    // *** Search Table *** START - the uppermost table
    Table table = new Table();
    table.setWidth("100%");
    table.setBorder(0);
    table.setCellpadding(2);
    table.setCellspacing(0);
    this.transGIF.setHeight("1");
    this.transGIF.setWidth("1");

    int row = 1;
    int col = 1;
    // add empty space row
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    // Set COLUMN WIDTH for column 1 to 5
    table.setWidth(1, row, "100");
    // table.setWidth(2, row, "70");
    // table.setWidth(3, row, "70");
    // table.setWidth(4, row, "70");
    // table.setWidth(5, row, "104");

    row++;
    col = 1;

    // *** HEADING Pupil ***
    Text pupilTxt = new Text(localize(KEY_PUPIL_HEADING, "Pupil"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "20");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    row++;
    col = 1;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "5");
    col = 1;
    row++;

    // Personal Id Number
    table.add(getSmallHeader(localize(KEY_PERSONAL_ID_LABEL, "Personal id: ")), col++, row);
    if (pupil != null) {
      table.add(getSmallText(pupil.getPersonalID()), col++, row);
    }
    row++;
    col = 1;
    // Last Name
    table.add(getSmallHeader(localize(KEY_LAST_NAME_LABEL, "Last name: ")), col++, row);

    Table nameTable = new Table();
    col = 1;
    nameTable.setCellpadding(0);
    nameTable.setCellspacing(0);
    if (pupil != null) {
      nameTable.add(getSmallText(pupil.getLastName()), col++, 1);
    }
    // First Name
    nameTable.add(getSmallHeader(localize(KEY_FIRST_NAME_LABEL, "First name: ")), col++, 1);
    if (pupil != null) {
      nameTable.add(getSmallText(pupil.getFirstName()), col++, 1);
    }
    nameTable.setWidth(1, 1, "100");
    nameTable.setWidth(2, 1, "100");
    nameTable.setWidth(3, 1, "100");
    table.add(nameTable, 2, row);
    table.mergeCells(2, row, 5, row);
    row++;
    col = 1;

    // Address and Phone
    table.add(getSmallHeader(localize(KEY_ADDRESS_LABEL, "Address: ")), col++, row);
    row++;
    col = 1;
    table.add(getSmallHeader(localize(KEY_PHONE_LABEL, "Phone: ")), col++, row);
    if (pupil != null) {
      try {
        // pupil address
        Address address = getUserBusiness(iwc).getUsersMainAddress(pupil);
        StringBuffer aBuf = new StringBuffer(address.getStreetAddress());
        aBuf.append(", ");
        aBuf.append(address.getPostalCode().getPostalAddress());
        row--;
        table.add(getSmallText(aBuf.toString()), col, row);
        row++;
        // Get pupil phones
        Collection phones = pupil.getPhones();
        int i = 0;
        int phonesSize = phones.size();
        StringBuffer pBuf = new StringBuffer();
        for (Iterator iter = phones.iterator(); iter.hasNext(); i++) {
          Phone phone = (Phone) iter.next();
          pBuf.append(phone.getNumber());
          if (i < phonesSize - 1) {
            pBuf.append(", ");
          }
        }
        pBuf.append("&nbsp;");
        table.add(getSmallText(pBuf.toString()), col, row);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    row++;
    col = 1;

    return table;
  }