gt: 				if (emailLink != null){
context: /*
   * Created on 8.4.2003
   */
  package se.idega.idegaweb.commune.childcare.presentation;
  
  import is.idega.block.family.business.FamilyLogic;
  import is.idega.block.family.business.NoCustodianFound;
  
  import java.rmi.RemoteException;
  import java.util.Collection;
  import java.util.Iterator;
  
  import se.idega.idegaweb.commune.business.CommuneUserBusiness;
  import se.idega.idegaweb.commune.care.data.ChildCareApplication;
  import se.idega.idegaweb.commune.childcare.event.ChildCareEventListener;
  
  import com.idega.core.contact.data.Email;
  import com.idega.presentation.IWContext;
  import com.idega.presentation.Table;
  import com.idega.presentation.text.Link;
  import com.idega.presentation.ui.DropdownMenu;
  import com.idega.presentation.ui.Form;
  import com.idega.presentation.ui.HiddenInput;
  import com.idega.presentation.ui.SubmitButton;
  import com.idega.user.business.NoEmailFoundException;
  import com.idega.user.data.User;
  import com.idega.util.IWCalendar;
  import com.idega.util.PersonalIDFormatter;
  
  /**
   * @author laddi
   */
  public class ChildCareAdminRejected extends ChildCareBlock {
  
  	private static final String PARAMETER_APPLICATION_ID = "ccr_application_id";
  	private boolean _requiresPrognosis = true;
  
  	/**
  	 * @see se.idega.idegaweb.commune.childcare.presentation.ChildCareBlock#init(com.idega.presentation.IWContext)
  	 */
  	public void init(IWContext iwc) throws Exception {
  		if (canSeeRejected()) {
  			performAction(iwc);
  			
  			Table table = new Table(1, 3);
  			table.setCellpadding(0);
  			table.setCellspacing(0);
  			table.setWidth(getWidth());
  			table.setHeight(2, 12);
  			if (useStyleNames()) {
  				table.setCellpaddingLeft(1, 1, 12);
  				table.setCellpaddingRight(1, 1, 12);
  			}
  			
  			table.add(getNavigationForm(), 1, 1);
  			table.add(getApplicationTable(iwc), 1, 3);
  			
  			add(table);
  		}
  		else {
  			add(getSmallErrorText(localize("child_care.prognosis_must_be_set","Prognosis must be set or updated before you can continue!")));
  		}
  	}
  	
  	protected boolean canSeeRejected() {
  		boolean hasPrognosis = false;
  		if (this._requiresPrognosis) {
  			try {
  				hasPrognosis = getSession().hasPrognosis();
  			}
  			catch (RemoteException e) {
  				hasPrognosis = false;
  			}
  		}
  		else {
  			hasPrognosis = true;
  		}
  		
  		return hasPrognosis;
  	}
  	
  	private Form getApplicationTable(IWContext iwc) throws RemoteException {
  		Form form = new Form();
  		form.add(new HiddenInput(PARAMETER_APPLICATION_ID, ""));
  		
  		Table table = new Table();
  		table.setWidth(Table.HUNDRED_PERCENT);
  		table.setCellpadding(getCellpadding());
  		table.setCellspacing(getCellspacing());
  		table.setColumns(7);
  		if (useStyleNames()) {
  			table.setRowStyleClass(1, getHeaderRowClass());
  		}
  		else {
  			table.setRowColor(1, getHeaderColor());
  		}
  		form.add(table);
  		int row = 1;
  		int column = 1;
  			
  		if (useStyleNames()) {
  			table.setCellpaddingLeft(1, row, 12);
  			table.setCellpaddingRight(table.getColumns(), row, 12);
  		}
  		table.add(getLocalizedSmallHeader("child_care.name","Name"), column++, row);
  		table.add(getLocalizedSmallHeader("child_care.personal_id","Personal ID"), column++, row);
  		table.add(getLocalizedSmallHeader("child_care.status","Status"), column++, row);
  		table.add(getLocalizedSmallHeader("child_care.queue_date","Queue date"), column++, row);
  		table.add(getLocalizedSmallHeader("child_care.placement_date","Placement date"), column++, row);
  		table.add(getLocalizedSmallHeader("child_care.reject_date","Reject date"), column++, row++);
  				
  		Collection applications = null;
  		if (getSession().getStatus() != null) {
  			applications = getBusiness().getTerminatedApplicationsByProviderAndApplicationStatus(getSession().getChildCareID(), getSession().getStatus());
  		}
  		else {
  			applications = getBusiness().getInactiveApplicationsByProvider(getSession().getChildCareID());
  		}
  		if (applications != null && !applications.isEmpty()) {
  			ChildCareApplication application;
  			User child;
  			IWCalendar queueDate;
  			IWCalendar placementDate;
  			IWCalendar rejectDate;
  			SubmitButton activateApplication;
  			int numberOfChildren = applications.size();
  			String name = null;
  			Link emailLink = null;
  			String emails = null;
  			Email email = null;
  			
  			Iterator iter = applications.iterator();
  			while (iter.hasNext()) {
  				column = 1;
  				application = (ChildCareApplication) iter.next();
  				child = application.getChild();
  				emailLink = null;
  				email = null;
  				emails = "";
  				
  				if (application.getQueueDate() != null) {
  					queueDate = new IWCalendar(iwc.getCurrentLocale(), application.getQueueDate());
  				}
  				else {
  					queueDate = null;
  				}
  				placementDate = new IWCalendar(iwc.getCurrentLocale(), application.getCreated());
  				if (application.getRejectionDate() != null) {
  					rejectDate = new IWCalendar(iwc.getCurrentLocale(), application.getRejectionDate());
  				}
  				else {
  					rejectDate = null;
  				}
  						
  				if (useStyleNames()) {
  					if (row % 2 == 0) {
  						table.setRowStyleClass(row, getDarkRowClass());
  					}
  					else {
  						table.setRowStyleClass(row, getLightRowClass());
  					}
  					table.setCellpaddingLeft(1, row, 12);
  					table.setCellpaddingRight(table.getColumns(), row, 12);
  				}
  				else {
  					if (row % 2 == 0) {
  						table.setRowColor(row, getZebraColor1());
  					}
  					else {
  						table.setRowColor(row, getZebraColor2());
  					}
  				}
  
  				//// email to parent
  				try {
  					Collection parents = getMemberFamilyLogic(iwc).getCustodiansFor(child);
  					
  					if (parents != null && !parents.isEmpty()) {
  						Iterator iterPar = parents.iterator();
  						while (iterPar.hasNext()) {
  							User parent = (User) iterPar.next();
  							
  							try {
  								email = getCommuneUserBusiness(iwc).getUsersMainEmail(parent);
  								if (email != null && email.getEmailAddress() != null && !email.getEmailAddress().equals(" ")) {
  									emailLink = this.getSmallLink(email.getEmailAddress());
  									if (emails != null) {
  										emails = emails + "; " + email.getEmailAddress();
  									}
  									else {
  										emails = email.getEmailAddress();
  									}
  									
  									emailLink.setURL("mailto:" + emails);
  								}
  																
  							}
  							catch (NoEmailFoundException nef) {
  								log(nef);
  							}
  							
  						}
  					}
  				}catch (NoCustodianFound ncf) {
  				}
  				
  				name = getBusiness().getUserBusiness().getNameLastFirst(child, true);
  