Revision 2487 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.services/src/main/java/org/gvsig/tools/dynform/services/dynformfield/URL/JDynFormFieldURL.java

View differences:

JDynFormFieldURL.java
28 28
import java.net.URL;
29 29

  
30 30
import javax.swing.JFileChooser;
31
import org.apache.commons.lang3.StringUtils;
31 32
import org.gvsig.tools.dynform.DynFormFieldDefinition;
32 33

  
33 34
import org.gvsig.tools.dynform.services.dynformfield.File.JDynFormFieldFile;
......
54 55
        URL value = null;
55 56
        String s = "";
56 57
        s = this.jtext.getText();
57
        if (s.trim().length() == 0) {
58
            Object x = this.getDefinition().getDefaultValue();
59
            if (x == null) {
60
                value = null;
61
            } else {
62
                try {
63
                    value = new URL(x.toString());
64
                } catch (MalformedURLException e) {
65
                    LOGGER.info("Error. URL Syntax: " + x.toString());
66
                    value = null;
67
                }
68
            }
69
        } else {
70
            try {
71
                value = new URL(s);
72
            } catch (MalformedURLException e) {
73
                LOGGER.info("Error. URL Syntax: " + s.toString());
74
                value = null;
75
            }
58
        if (StringUtils.isBlank(s)){
59
            return null;  
76 60
        }
61
//        if (s.trim().length() == 0) {
62
//            Object x = this.getDefinition().getDefaultValue();
63
//            if (x == null) {
64
//                value = null;
65
//            } else {
66
//                try {
67
//                    value = new URL(x.toString());
68
//                } catch (MalformedURLException e) {
69
//                    LOGGER.info("Error. URL Syntax: " + x.toString());
70
//                    value = null;
71
//                }
72
//            }
73
//        } else {
74
        try {
75
            value = new URL(s);
76
        } catch (MalformedURLException e) {
77
            LOGGER.info("Error. URL Syntax: " + s.toString());
78
            value = null;
79
        }
80
//        }
77 81
        return value;
78 82
    }
79 83

  

Also available in: Unified diff