Using StringUtil.asHTML() to make some text HTML-safe, throws the following JavaScripException:
This behaviour is reproducable with the following code
Am I missing something?
I'm using GWT 2.2.0, SmartGWT 2.4, Java 1.6.0_25, NetBeans 6.9.1 on Windows 7 x64
Code:
Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): (new $wnd.String(str)).asHTML is not a function fileName: http://127.0.0.1:8888 lineNumber: 26 stack: ("Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): (new $wnd.String(str)).asHTML is not a function fileName: http://127.0.0.1:8888 lineNumber: 26 stack: ("A\ntext\nwith\5\nlines\n")@http://127.0.0.1:8888:26 ([object GWTJavaObject],1048775,[object GWTJavaObject])@http://127.0.0.1:8888/portal/hosted.html?portal:56 ([object Object],(void 0))@http://127.0.0.1:8888:1331 ((function () {var param = {};var event = __gwt_makeJavaInvoke(1)(null, 3276919, param);__gwt_makeJavaInvoke(1)(selfJ, 1048775, even t);var ret = __gwt_makeJavaInvoke(0)(event, 1179654);return !ret;}),[object Object],[object Arguments])@http://127.0.0.1:8888:20 (null,106,(function () {var param = {};var event = __gwt_makeJavaInvoke(1)(null, 3276919, param);__gwt_makeJavaInvoke(1)(selfJ, 1048 775, event);var ret = __gwt_makeJavaInvoke(0)(event, 1179654);return !ret;}),[object Object],[object Arguments])@http://127.0.0.1:88 88/portal/hosted.html?portal:56 ([object Object],(void 0))@http://127.0.0.1:8888:4 ([object Object],(void 0))@http://127.0.0.1:8888:13 isc_StatefulCanvas_handleActivate([object Object],(void 0))@http://127.0.0.1:8888/portal/sc/modules/ISC_Foundation.js:296 isc_StatefulCanvas_handleClick([object Object],(void 0))@http://127.0.0.1:8888/portal/sc/modules/ISC_Foundation.js:298 isc_c_EventHandler_bubbleEvent([object Object],"click")@http://127.0.0.1:8888/portal/sc/modules/ISC_Core.js?isc_version=7.1.js:1497 isc_c_EventHandler_handleClick([object Object])@http://127.0.0.1:8888/portal/sc/modules/ISC_Core.js?isc_version=7.1.js:1345 isc_c_EventHandler__handleMouseUp([object MouseEvent],(void 0))@http://127.0.0.1:8888/portal/sc/modules/ISC_Core.js?isc_version=7.1. js:1332 isc_c_EventHandler_handleMouseUp([object MouseEvent])@http://127.0.0.1:8888/portal/sc/modules/ISC_Core.js?isc_version=7.1.js:1323 isc_c_EventHandler_dispatch(isc_c_EventHandler_handleMouseUp,[object MouseEvent])@http://127.0.0.1:8888/portal/sc/modules/ISC_Core.j s?isc_version=7.1.js:1560 anonymous([object MouseEvent])@http://127.0.0.1:8888/portal/sc/modules/ISC_Core.js?isc_version=7.1.js:38 at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:129) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.smartgwt.client.util.StringUtil.asHTML(StringUtil.java) at de.ics.continuity.web.client.editor.DiscussionEditor.save(DiscussionEditor.java:173) at de.ics.continuity.web.client.editor.DiscussionEditor.access$1(DiscussionEditor.java:168) at de.ics.continuity.web.client.editor.DiscussionEditor$3.onClick(DiscussionEditor.java:79) at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:98) at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:1) at com.google.gwt.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:204) ... 28 more
Code:
import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.util.StringUtil; public class MainEntryPoint implements EntryPoint { @Override public void onModuleLoad() { String text = "A\ntext\nwith\n5\nlines\n"; System.out.println(StringUtil.asHTML(text)); } }
I'm using GWT 2.2.0, SmartGWT 2.4, Java 1.6.0_25, NetBeans 6.9.1 on Windows 7 x64