THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
import java.net.MalformedURLException; import java.net.URL; import java.util.Locale; import wicket.util.convert.ConversionException; import wicket.util.convert.IConverter; /** * Converts from and to URLs. * * @author Eelco Hillenius */ public class URLConverter implements IConverter { /** * Construct. */ public URLConverter() { } /** * @see wicket.util.convert.IConverter#convertIConverter#convertToObject(java.lang.Object, java.lang.Class) */ public Object convertconvertToObject(Object value, Class c) { if (value == null) { return null; } if (c == URL.class) { if (value.getClass() == URL.class) { return value; } try { return new URL(value.toString()); } catch (MalformedURLException e) { throw new ConversionException("'" + value + "' is not a valid URL"); } } return value.toString(); } /** * @see wicket.util.convert.ILocalizable#setLocale(java.util.Locale) */ public void setLocale(Locale locale) { } /** * @see wicket.util.convert.ILocalizable#getLocale() */ public Locale getLocale() { return Locale.getDefault(); } } |
...