/* * $Id: MessageTypeHandler.java,v 1.1 2005/10/19 12:52:55 laddi Exp $ * Created on Oct 19, 2005 * * Copyright (C) 2005 Idega Software hf. All Rights Reserved. * * This software is the proprietary information of Idega hf. * Use is subject to license terms. */ package com.idega.block.process.message.business; import java.rmi.RemoteException; import java.util.Iterator; import java.util.List; import javax.ejb.FinderException; import com.idega.block.process.business.CaseBusiness; import com.idega.block.process.data.CaseCode; import com.idega.business.IBOLookup; import com.idega.business.IBOLookupException; import com.idega.business.IBORuntimeException; import com.idega.core.builder.presentation.ICPropertyHandler; import com.idega.idegaweb.IWApplicationContext; import com.idega.presentation.IWContext; import com.idega.presentation.PresentationObject; import com.idega.presentation.ui.DropdownMenu; /** * Last modified: $Date: 2005/10/19 12:52:55 $ by $Author: laddi $ * * @author <a href="mailto:laddi@idega.com">laddi</a> * @version $Revision: 1.1 $ */ public class MessageTypeHandler implements ICPropertyHandler { /* (non-Javadoc) * @see com.idega.core.builder.presentation.ICPropertyHandler#getDefaultHandlerTypes() */ public List getDefaultHandlerTypes() { return null; } /* (non-Javadoc) * @see com.idega.core.builder.presentation.ICPropertyHandler#getHandlerObject(java.lang.String, java.lang.String, com.idega.presentation.IWContext) */ public PresentationObject getHandlerObject(String name, String stringValue, IWContext iwc) { DropdownMenu menu = new DropdownMenu(name); menu.addMenuElementFirst("", "Select"); Iterator iter = MessageTypeManager.getInstance().getMessageCodes().iterator(); while (iter.hasNext()) { String code = (String) iter.next(); try { CaseCode caseCode = getCaseBusiness(iwc).getCaseCode(code); menu.addMenuElement(caseCode.getCode(), caseCode.getDescription() != null ? caseCode.getDescription() : caseCode.getCode()); } catch (FinderException fe) { fe.printStackTrace(); return null; } catch (RemoteException re) { throw new IBORuntimeException(re); } } if (stringValue != null) { menu.setSelectedElement(stringValue); } return menu; } /* (non-Javadoc) * @see com.idega.core.builder.presentation.ICPropertyHandler#onUpdate(java.lang.String[], com.idega.presentation.IWContext) */ public void onUpdate(String[] values, IWContext iwc) { } protected CaseBusiness getCaseBusiness(IWApplicationContext iwac) { try { return (CaseBusiness) IBOLookup.getServiceInstance(iwac, CaseBusiness.class); } catch (IBOLookupException ile) { throw new IBORuntimeException(ile); } } }