Changeset 2227 for FCKeditor.Java/trunk
- Timestamp:
- 2008-07-16 23:55:32 (5 months ago)
- Location:
- FCKeditor.Java/trunk
- Files:
-
- 6 modified
-
java-core/src/main/java/net/fckeditor/FCKeditor.java (modified) (4 diffs)
-
java-core/src/main/java/net/fckeditor/tags/EditorTag.java (modified) (1 diff)
-
java-core/src/main/java/net/fckeditor/tool/Utils.java (modified) (3 diffs)
-
java-core/src/main/resources/META-INF/FCKeditor.tld (modified) (2 diffs)
-
java-core/src/test/java/net/fckeditor/tool/UtilsTest.java (modified) (1 diff)
-
src/changes/changes.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/FCKeditor.java
r2224 r2227 45 45 private String instanceName; 46 46 private String value; 47 private String basePath;48 47 private HttpServletRequest request; 49 48 … … 52 51 private String width = PropertiesLoader.getProperty("fckeditor.width"); 53 52 private String height = PropertiesLoader.getProperty("fckeditor.height"); 54 private String defaultBasePath = PropertiesLoader.getProperty("fckeditor.basePath");55 56 /** 57 * Main constructor.<br >53 private String basePath = PropertiesLoader.getProperty("fckeditor.basePath"); 54 55 /** 56 * Main constructor.<br /> 58 57 * All important settings are done here and will be preset by the defaults 59 * taken from {@link PropertiesLoader}. 58 * taken from {@link PropertiesLoader}. Any parameter except instanceName 59 * failing {@link Utils#isNotBlank(String)} will be ignored. 60 60 * 61 61 * @param request … … 69 69 * @param toolbarSet 70 70 * toolbarSet name 71 * @throws IllegalArgumentException 72 * when instanceName is not valid HTML id 71 73 */ 72 74 public FCKeditor(final HttpServletRequest request, final String instanceName, … … 74 76 final String basePath) { 75 77 this.request = request; 76 this.instanceName = instanceName; 77 if (Utils.isNotEmpty(width)) 78 if (Utils.isBlank(instanceName)) 79 throw new IllegalArgumentException( 80 "instanceName must be a valid HTML id"); 81 else 82 this.instanceName = instanceName; 83 if (Utils.isNotBlank(width)) 78 84 this.width = width; 79 if (Utils.isNot Empty(height))85 if (Utils.isNotBlank(height)) 80 86 this.height = height; 81 if (Utils.isNot Empty(toolbarSet))87 if (Utils.isNotBlank(toolbarSet)) 82 88 this.toolbarSet = toolbarSet; 89 // TODO Should be check here for empty or blank? 83 90 if (Utils.isNotEmpty(value)) 84 91 this.value = value; 85 if (Utils.isNotEmpty(basePath)) 92 else 93 this.value = new String(); 94 if (Utils.isNotBlank(basePath)) 86 95 this.basePath = request.getContextPath().concat(basePath); 87 96 else 88 this.basePath = request.getContextPath().concat( defaultBasePath);97 this.basePath = request.getContextPath().concat(this.basePath); 89 98 90 99 config = new FCKeditorConfig(); -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/tags/EditorTag.java
r2151 r2227 123 123 */ 124 124 public int doStartTag() throws JspException { 125 fckEditor = new FCKeditor( 126 (HttpServletRequest) pageContext.getRequest(), instanceName, 127 width, height, toolbarSet, value, basePath); 125 126 try { 127 fckEditor = new FCKeditor((HttpServletRequest) pageContext 128 .getRequest(), instanceName, width, height, toolbarSet, 129 value, basePath); 130 } catch (IllegalArgumentException e) { 131 throw new JspException(e); 132 } 128 133 129 134 return EVAL_BODY_INCLUDE; -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/tool/Utils.java
r2151 r2227 74 74 * @param str 75 75 * to check 76 * @return <code>true</code> if the string is <code>null</code>. 76 * @return <code>true</code> if the string is <code>null</code> or 77 * empty. 77 78 */ 78 79 public static boolean isEmpty(final String str) { … … 84 85 * 85 86 * @param str 86 * @return <code>true</code> if the String is not empty and not 87 * to ckeck 88 * @return <code>true</code> if the String is not empty or not 87 89 * <code>null</code>. 88 90 */ … … 90 92 return !isEmpty(str); 91 93 } 94 95 /** 96 * Checks if a String is whitespace, empty or null. 97 * 98 * @param str 99 * to check 100 * @return <code>true</code> if the string is <code>null</code>, empty 101 * or contains whitespace only. 102 */ 103 public static boolean isBlank(final String str) { 104 105 if (isEmpty(str)) 106 return true; 107 108 for (char c : str.toCharArray()) { 109 if (!Character.isWhitespace(c)) 110 return false; 111 } 112 113 return true; 114 } 115 116 /** 117 * Just a wrapper to {@link #isBlank(String)}. 118 * 119 * @param str 120 * to check 121 * @return <code>true</code> if the string is not <code>null</code>, 122 * not empty or does not contain whitespace only. 123 */ 124 public static boolean isNotBlank(final String str) { 125 return !isBlank(str); 126 } 92 127 } -
FCKeditor.Java/trunk/java-core/src/main/resources/META-INF/FCKeditor.tld
r2044 r2227 4 4 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 5 5 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" 6 version="2.0" 7 > 6 version="2.0"> 8 7 <description> 9 8 The FCKeditor Tag Library offers a very convenient way to create … … 17 16 <tag> 18 17 <description> 19 Creates a FCKeditor instance with the given parameters. 18 Creates a FCKeditor instance with the given parameters. Any 19 parameter except instanceName which is empty or contains 20 whitespaces only will be ignored. 20 21 </description> 21 22 <display-name>editor</display-name> -
FCKeditor.Java/trunk/java-core/src/test/java/net/fckeditor/tool/UtilsTest.java
r2168 r2227 74 74 } 75 75 76 @Test 77 public void isBlank01() { 78 assertTrue(Utils.isBlank(null)); 79 } 80 81 @Test 82 public void isBlank02() { 83 assertTrue(Utils.isBlank("")); 84 } 85 86 @Test 87 public void isBlank03() { 88 assertTrue(Utils.isBlank(" ")); 89 } 90 91 @Test 92 public void isBlank04() { 93 assertTrue(Utils.isBlank(" \t \n \r")); 94 } 95 96 @Test 97 public void isBlank05() { 98 assertFalse(Utils.isBlank(" h ")); 99 } 100 101 @Test 102 public void isBlank06() { 103 assertFalse(Utils.isBlank("\t n ")); 104 } 105 106 @Test 107 public void isNotBlank01() { 108 assertTrue(Utils.isNotBlank(" h ")); 109 } 110 111 @Test 112 public void isNotBlank02() { 113 assertTrue(Utils.isNotBlank(" h \t ")); 114 } 115 116 @Test 117 public void isNotBlank03() { 118 assertFalse(Utils.isNotBlank(" \t \n \r")); 119 } 120 121 @Test 122 public void isNotBlank04() { 123 assertFalse(Utils.isNotBlank(null)); 124 } 125 126 @Test 127 public void isNotBlank05() { 128 assertFalse(Utils.isNotBlank("")); 129 } 130 131 @Test 132 public void isNotBlank06() { 133 assertFalse(Utils.isNotBlank(" ")); 134 } 135 76 136 } -
FCKeditor.Java/trunk/src/changes/changes.xml
r2212 r2227 10 10 <action dev="mosipov" type="fix" issue="2355">FCK:editor output is not XHTML 1.0 compliant</action> 11 11 <action dev="mosipov" type="fix" issue="2359">fckeditor-java-demo fails in Glassfish</action> 12 12 <action dev="mosipov" type="fix" issue="2372">Empty/non-set FCK:editor value causes NullPointerException</action> 13 13 </release> 14 14 </body>