form.maintainParameter(PARAMETER_PERSONAL_ID);
if (isIcelandic) { form.maintainParameter(PARAMETER_PERSONAL_ID); }
	private void stepTwo(IWContext iwc) throws RemoteException {		Form form = new Form();		form.maintainParameter(PARAMETER_PERSONAL_ID);		form.addParameter(PARAMETER_ACTION, "-1");		form.addParameter(PARAMETER_FROM_ACTION, ACTION_STEP_TWO);				Table table = new Table();		table.setCellpadding(0);		table.setCellspacing(0);		table.setWidth(Table.HUNDRED_PERCENT);		form.add(table);		int row = 1;		table.add(getPhasesTable(isIcelandic ? 2 : 1, isIcelandic ? 7 : 6, "run_reg.registration", "Registration"), 1, row++);		table.setHeight(row++, 12);		table.add(getInformationTable(localize("run_reg.information_text_step_2", "Information text 2...")), 1, row++);		table.setHeight(row++, 18);				Table choiceTable = new Table();		choiceTable.setColumns(3);		choiceTable.setCellpadding(2);		choiceTable.setCellspacing(0);		choiceTable.setWidth(1, "50%");		choiceTable.setWidth(2, 12);		choiceTable.setWidth(3, "50%");		choiceTable.setWidth(Table.HUNDRED_PERCENT);		table.add(choiceTable, 1, row++);		int iRow = 1;				IWTimestamp ts = IWTimestamp.RightNow();    Integer y = new Integer(ts.getYear());    String yearString = y.toString();    		boolean hasRuns = false;		DropdownMenu runDropdown = (DropdownMenu) getStyledInterface(new DropdownMenu(PARAMETER_RUN));		Collection runs = getRunBusiness(iwc).getRuns();		runDropdown.addMenuElement("-1", localize("run_year_ddd.select_run","Select run..."));		if(runs != null) {			Iterator iter = runs.iterator();			while (iter.hasNext()) {				Group run = (Group) iter.next();				if (runner.getUser() != null) {					if (!getRunBusiness(iwc).isRegisteredInRun(yearString, run, runner.getUser())) {						runDropdown.addMenuElement(run.getPrimaryKey().toString(), localize(run.getName(), run.getName()));						hasRuns = true;					}				}				else {					runDropdown.addMenuElement(run.getPrimaryKey().toString(), localize(run.getName(), run.getName()));					hasRuns = true;				}			}		}		if (runner.getRun() != null) {			runDropdown.setSelectedElement(runner.getRun().getPrimaryKey().toString());		}		runDropdown.setAsNotEmpty(localize("run_reg.must_select_run", "You have to select a run"), "");		if (!hasRuns) {			getParentPage().setAlertOnLoad(localize("run_reg.no_runs_available", "There are no runs you can register for."));			if (isIcelandic) {				removeRunner(iwc, runner.getPersonalID());				stepOne(iwc);				return;			}		}				DropdownMenu distanceDropdown = (DropdownMenu) getStyledInterface(new DropdownMenu(PARAMETER_DISTANCE));		distanceDropdown.addMenuElement("", localize("run_year_ddd.select_distance","Select distance..."));		if(runner.getRun() != null) {			Collection distances = getRunBusiness(iwc).getDistancesMap(runner.getRun(), yearString);			if(distances != null) {				distanceDropdown.addMenuElements(distances);			}			if (runner.getDistance() != null) {				distanceDropdown.setSelectedElement(runner.getDistance().getPrimaryKey().toString());			}		}		distanceDropdown.setAsNotEmpty(localize("run_reg.must_select_distance", "You have to select a distance"), "");		Text redStar = getHeader("*");		redStar.setFontColor("#ff0000");		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_PRIMARY_DD, "Run") + "/" + localize(IWMarathonConstants.RR_SECONDARY_DD, "Distance")), 1, iRow);		choiceTable.add(redStar, 1, iRow++);		choiceTable.mergeCells(1, iRow, choiceTable.getColumns(), iRow);		choiceTable.add(runDropdown, 1, iRow);		choiceTable.add(distanceDropdown, 1, iRow++);				RemoteScriptHandler rsh = new RemoteScriptHandler(runDropdown, distanceDropdown);		try {			rsh.setRemoteScriptCollectionClass(RunInputCollectionHandler.class);		}		catch (InstantiationException e) {			e.printStackTrace();		}		catch (IllegalAccessException e) {			e.printStackTrace();		}		add(rsh);		choiceTable.setHeight(iRow++, 12);				TextInput nameField = (TextInput) getStyledInterface(new TextInput(PARAMETER_NAME));		nameField.setWidth(Table.HUNDRED_PERCENT);		if (runner.getName() != null) {			nameField.setContent(runner.getName());		}		if (isIcelandic) {			nameField.setDisabled(true);			if (runner.getUser() != null) {				nameField.setContent(runner.getUser().getName());			}		}		else {			nameField.setAsAlphabeticText(localize("run_reg.name_err_msg", "Your name may only contain alphabetic characters"));			nameField.setAsNotEmpty(localize("run_reg.name_not_empty", "Name field can not be empty"));		}		DropdownMenu genderField = (DropdownMenu) getStyledInterface(new DropdownMenu(PARAMETER_GENDER));		Collection genders = getGenderBusiness(iwc).getAllGenders();		genderField.addMenuElement("", localize("run_reg.select_gender","Select gender..."));		if(genders != null) {			Iterator iter = genders.iterator();			while (iter.hasNext()) {				Gender gender = (Gender) iter.next();				genderField.addMenuElement(gender.getPrimaryKey().toString(), localize("gender." + gender.getName(), gender.getName()));			}		}		if (runner.getGender() != null) {			genderField.setSelectedElement(runner.getGender().getPrimaryKey().toString());		}		if (isIcelandic) {			genderField.setDisabled(true);			if (runner.getUser() != null) {				genderField.setSelectedElement(runner.getUser().getGenderID());			}		}		else {			genderField.setAsNotEmpty(localize("run_reg.gender_not_empty", "Gender can not be empty"));		}		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_NAME, "Name")), 1, iRow);		choiceTable.add(redStar, 1, iRow);		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_GENDER, "Gender")), 3, iRow);		choiceTable.add(redStar, 3, iRow++);		choiceTable.add(nameField, 1, iRow);		choiceTable.add(genderField, 3, iRow++);		choiceTable.setHeight(iRow++, 3);		TextInput ssnISField = (TextInput) getStyledInterface(new TextInput(PARAMETER_PERSONAL_ID));		ssnISField.setLength(10);		if (isIcelandic) {			ssnISField.setDisabled(true);			if (runner.getUser() != null) {				ssnISField.setContent(runner.getUser().getPersonalID());			}		}		IWTimestamp stamp = new IWTimestamp();		DateInput ssnField = (DateInput) getStyledInterface(new DateInput(PARAMETER_PERSONAL_ID));		ssnField.setAsNotEmpty("Date of birth can not be empty");		ssnField.setYearRange(stamp.getYear(), stamp.getYear() - 100);		if (runner.getDateOfBirth() != null) {			ssnField.setDate(runner.getDateOfBirth());		}		Collection countries = getRunBusiness(iwc).getCountries();		DropdownMenu nationalityField = (DropdownMenu) getStyledInterface(new DropdownMenu(PARAMETER_NATIONALITY));		DropdownMenu countryField = (DropdownMenu) getStyledInterface(new DropdownMenu(PARAMETER_COUNTRY));		nationalityField.addMenuElement("-1", localize("run_reg.select_nationality", "Select nationality..."));		countryField.addMenuElement("-1", localize("run_reg.select_country", "Select country..."));		SelectorUtility util = new SelectorUtility();		if (countries != null && !countries.isEmpty()) {			nationalityField = (DropdownMenu) util.getSelectorFromIDOEntities(nationalityField, countries, "getName");			countryField = (DropdownMenu) util.getSelectorFromIDOEntities(countryField, countries, "getName");		}		if (isIcelandic) {			countryField.setDisabled(true);			nationalityField.setSelectedElement("104");			if (runner.getUser() != null) {				Address address = getUserBusiness(iwc).getUsersMainAddress(runner.getUser());				if (address != null && address.getCountry() != null) {					countryField.setSelectedElement(address.getCountry().getPrimaryKey().toString());				}			}		}		nationalityField.setWidth(Table.HUNDRED_PERCENT);		nationalityField.setAsNotEmpty(localize("run_reg.must_select_nationality", "You must select your nationality"));		countryField.setWidth(Table.HUNDRED_PERCENT);		if (!isIcelandic) {			countryField.setAsNotEmpty(localize("run_reg.must_select_country", "You must select your country"));		}		if (runner.getCountry() != null) {			countryField.setSelectedElement(runner.getCountry().getPrimaryKey().toString());		}		if (runner.getNationality() != null) {			nationalityField.setSelectedElement(runner.getNationality().getPrimaryKey().toString());		}				choiceTable.add(getHeader(localize(IWMarathonConstants.RR_SSN, "SSN")), 1, iRow);		choiceTable.add(redStar, 1, iRow);		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_NATIONALITY, "Nationality")), 3, iRow);		choiceTable.add(redStar, 3, iRow++);		if (isIcelandic) {			choiceTable.add(ssnISField, 1, iRow);		}		else {			choiceTable.add(ssnField, 1, iRow);		}		choiceTable.add(nationalityField, 3, iRow++);		choiceTable.setHeight(iRow++, 3);				TextInput addressField = (TextInput) getStyledInterface(new TextInput(PARAMETER_ADDRESS));		addressField.setWidth(Table.HUNDRED_PERCENT);		if (!isIcelandic) {			addressField.setAsNotEmpty(localize("run_reg.must_provide_address", "You must enter your address."));		}		if (runner.getAddress() != null) {			addressField.setContent(runner.getAddress());		}		if (isIcelandic) {			addressField.setDisabled(true);			if (runner.getUser() != null) {				Address address = getUserBusiness(iwc).getUsersMainAddress(runner.getUser());				if (address != null) {					addressField.setContent(address.getStreetAddress());				}			}		}		TextInput emailField = (TextInput) getStyledInterface(new TextInput(PARAMETER_EMAIL));		emailField.setAsEmail(localize("run_reg.email_err_msg", "Not a valid email address"));		emailField.setEmptyConfirm(localize("run_reg.continue_without_email", "Are you sure you want to continue without entering an e-mail?"));		emailField.setWidth(Table.HUNDRED_PERCENT);		if (runner.getEmail() != null) {			emailField.setContent(runner.getEmail());		}		else if (runner.getUser() != null) {			try {				Email mail = getUserBusiness(iwc).getUsersMainEmail(runner.getUser());				emailField.setContent(mail.getEmailAddress());			}			catch (NoEmailFoundException nefe) {				//No email registered...			}		}				choiceTable.add(getHeader(localize(IWMarathonConstants.RR_ADDRESS, "Address")), 1, iRow);		choiceTable.add(redStar, 1, iRow);		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_EMAIL, "Email")), 3, iRow++);		choiceTable.add(addressField, 1, iRow);		choiceTable.add(emailField, 3, iRow++);		choiceTable.setHeight(iRow++, 3);		TextInput cityField = (TextInput) getStyledInterface(new TextInput(PARAMETER_CITY));		cityField.setWidth(Table.HUNDRED_PERCENT);		if (!isIcelandic) {			cityField.setAsNotEmpty(localize("run_reg.must_provide_city", "You must enter your city of living."));		}		if (runner.getCity() != null) {			cityField.setContent(runner.getCity());		}		if (isIcelandic) {			cityField.setDisabled(true);			if (runner.getUser() != null) {				Address address = getUserBusiness(iwc).getUsersMainAddress(runner.getUser());				if (address != null) {					cityField.setContent(address.getCity());				}			}		}		TextInput telField = (TextInput) getStyledInterface(new TextInput(PARAMETER_HOME_PHONE));		telField.setWidth(Table.HUNDRED_PERCENT);		if (runner.getHomePhone() != null) {			telField.setContent(runner.getHomePhone());		}		else if (runner.getUser() != null) {			try {				Phone phone = getUserBusiness(iwc).getUsersHomePhone(runner.getUser());				telField.setContent(phone.getNumber());			}			catch (NoPhoneFoundException nefe) {				//No phone registered...			}		}		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_CITY, "City")), 1, iRow);		choiceTable.add(redStar, 1, iRow);		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_TEL, "Telephone")), 3, iRow++);		choiceTable.add(cityField, 1, iRow);		choiceTable.add(telField, 3, iRow++);		choiceTable.setHeight(iRow++, 3);		TextInput postalField = (TextInput) getStyledInterface(new TextInput(PARAMETER_POSTAL_CODE));		if (!isIcelandic) {			postalField.setAsNotEmpty(localize("run_reg.must_provide_postal", "You must enter your postal address."));		}		postalField.setMaxlength(10);		postalField.setLength(10);		if (runner.getPostalCode() != null) {			postalField.setContent(runner.getPostalCode());		}		if (isIcelandic) {			postalField.setDisabled(true);			if (runner.getUser() != null) {				Address address = getUserBusiness(iwc).getUsersMainAddress(runner.getUser());				if (address != null) {					PostalCode postal = address.getPostalCode();					if (postal != null) {						postalField.setContent(postal.getPostalCode());					}				}			}		}		TextInput mobileField = (TextInput) getStyleObject(new TextInput(PARAMETER_MOBILE_PHONE), STYLENAME_INTERFACE);		mobileField.setWidth(Table.HUNDRED_PERCENT);		if (runner.getMobilePhone() != null) {			mobileField.setContent(runner.getMobilePhone());		}		else if (runner.getUser() != null) {			try {				Phone phone = getUserBusiness(iwc).getUsersMobilePhone(runner.getUser());				mobileField.setContent(phone.getNumber());			}			catch (NoPhoneFoundException nefe) {				//No phone registered...			}		}		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_POSTAL, "Postal Code")), 1, iRow);		choiceTable.add(redStar, 1, iRow);		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_MOBILE, "Mobile Phone")), 3, iRow++);		choiceTable.add(postalField, 1, iRow);		choiceTable.add(mobileField, 3, iRow++);		choiceTable.setHeight(iRow++, 3);		DropdownMenu tShirtField = (DropdownMenu) getStyledInterface(new DropdownMenu(PARAMETER_SHIRT_SIZE));		tShirtField.addOption(new SelectOption(localize("run_reg.select_tee_shirt_size", "Select tee-shirt size"), "-1"));		tShirtField.addOption(new SelectOption(localize("run_reg.adult_sized", "Adult sizes"), "-1"));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.small", "Small"), IWMarathonConstants.PARAMETER_TSHIRT_S));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.medium", "Medium"), IWMarathonConstants.PARAMETER_TSHIRT_M));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.large", "Large"), IWMarathonConstants.PARAMETER_TSHIRT_L));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.xlarge", "Larger"), IWMarathonConstants.PARAMETER_TSHIRT_XL));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.xxlarge", "Largest"), IWMarathonConstants.PARAMETER_TSHIRT_XXL));		tShirtField.addOption(new SelectOption(localize("run_reg.kids_sized", "Kids sizes"), "-1"));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.small_kids", "Small"), IWMarathonConstants.PARAMETER_TSHIRT_S + "_kids"));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.medium_kids", "Medium"), IWMarathonConstants.PARAMETER_TSHIRT_M + "_kids"));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.large_kids", "Large"), IWMarathonConstants.PARAMETER_TSHIRT_L + "_kids"));		tShirtField.addOption(new SelectOption("- " + localize("run_reg.xlarge_kids", "Larger"), IWMarathonConstants.PARAMETER_TSHIRT_XL + "_kids"));		tShirtField.setAsNotEmpty(localize("run_reg.must_select_shirt_size", "You must select tee-shirt size"), "-1");		if (runner.getShirtSize() != null) {			tShirtField.setSelectedElement(runner.getShirtSize());		}		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_COUNTRY, "Country")), 1, iRow);		choiceTable.add(redStar, 1, iRow);		choiceTable.add(getHeader(localize(IWMarathonConstants.RR_TSHIRT, "T-Shirt")), 3, iRow++);		choiceTable.add(countryField, 1, iRow);		choiceTable.add(tShirtField, 3, iRow++);		SubmitButton next = (SubmitButton) getButton(new SubmitButton(localize("next", "Next")));		next.setValueOnClick(PARAMETER_ACTION, String.valueOf(ACTION_STEP_THREE));				table.setHeight(row++, 18);		table.add(next, 1, row);		table.setAlignment(1, row, Table.HORIZONTAL_ALIGN_RIGHT);		add(form);	}