/**
 * $Id $
 */
package gov.nih.nci.cagrid.browser.converters;

import gov.nih.nci.cagrid.dorian.idp.bean.StateCode;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

/**
 * @author <a href="mailto:joshua.phillips@semanticbits.com">Joshua Phillips</a>
 * 
 */
public class StateCodeConverter implements Converter {

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
	 *      javax.faces.component.UIComponent, java.lang.String)
	 */
	public Object getAsObject(FacesContext context, UIComponent component,
			String value) throws ConverterException {

		StateCode code = null;
		if (value != null && value.trim().length() > 0) {
			try {
				code = StateCode.fromValue(value.trim());
			} catch (Exception ex) {
				throw new ConverterException("Error converting '" + value
						+ "' to String: " + ex.getMessage(), ex);
			}
		}

		return code;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
	 *      javax.faces.component.UIComponent, java.lang.Object)
	 */
	public String getAsString(FacesContext context, UIComponent component,
			Object code) throws ConverterException {
		String s = null;
		if (code != null) {
			try {
				s = ((StateCode) code).getValue();
			} catch (Exception ex) {
				throw new ConverterException("Error converting '" + code
						+ "' to StateCode: " + ex.getMessage(), ex);
			}
		}

		return s;
	}

}

@@ -1550,32 +1550,77 @@
 ), ex);%0A%09%09%09%7D%0A%09%09%7D
+%0A%09%09if(%22Outside_US%22.equals(s))%7B%0A%09%09%09s = %22%22;%0A%09%09%7D
 %0A%0A%09%09return s;%0A%09%7D

Fix for bug #9110