My favorites | Sign in
Project Logo
                
Search
for
Updated May 13, 2008 by branflake2267
project_RichTextEditor  
Testing rich text editing

Rich Text Editor

I am getting an error when adding a RichTextEditor to a DialogBox. I have tried a few workarounds and haven't found a good solution. I tried Timing the adding of the rta, this works for the first time the DialogBox is centered(). After hiding and trying for a second time to center() it, the Dialogbox will fail because of the rich text editor.

Bug

Issue 2396

Details

Error in eclipse Developments shell debugger
[ERROR] Uncaught exception escaped
java.lang.RuntimeException: Failed to invoke native method: @com.google.gwt.user.client.ui.impl.RichTextAreaImplStandard::unhookEvents() with 0 arguments.
	at com.google.gwt.dev.shell.moz.LowLevelMoz.invoke(LowLevelMoz.java:132)
	at com.google.gwt.dev.shell.moz.ModuleSpaceMoz.doInvoke(ModuleSpaceMoz.java:98)
	at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:474)
	at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:275)
	at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:121)
	at com.google.gwt.user.client.ui.impl.RichTextAreaImplStandard.unhookEvents(RichTextAreaImplStandard.java:308)
	at com.google.gwt.user.client.ui.impl.RichTextAreaImplStandard.uninitElement(RichTextAreaImplStandard.java:228)
	at com.google.gwt.user.client.ui.RichTextArea.onDetach(RichTextArea.java:435)
	at com.google.gwt.user.client.ui.Panel.doDetachChildren(Panel.java:174)
	at com.google.gwt.user.client.ui.Widget.onDetach(Widget.java:146)
Error in firefox (from demo)
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMEventTarget.removeEventListener]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: http://gawkat.com/RichTextEditorPopUp/8BB667AFA4257A2DB4290D56312C8A25.cache.html :: kB :: line 381"  data: no]
RichTextEditor in my DialogBox Class
public class RTAEditorDialogPopup extends DialogBox implements ClickListener {

		// change listeners for this widget
		private ChangeListenerCollection changeListeners;
		
		// main panel
		private VerticalPanel pWidget = new VerticalPanel();
		
		//use this for testing
		private VerticalPanel pInputTest = new VerticalPanel();
		
		//rta input (in popout editor)
		private RichTextArea input = new RichTextArea();
	
		// Buttons
		private PushButton bUpdate = new PushButton("Update");
		private PushButton bClose = new PushButton("Cancel");
		
		// Vars
		private String sSelected = null;
		
		/**
		 * constructor - init widget
		 */
		public RTAEditorDialogPopup() {

			setText("RTA Edit");

			//buttons
			HorizontalPanel hpButtons = new HorizontalPanel();
			hpButtons.setSpacing(4);
			hpButtons.add(bClose);
			hpButtons.add(bUpdate);
			
			//toolbar
		    RichTextToolbar tb = new RichTextToolbar(input);

		    //setup widget
		    pWidget.add(tb);
		    pWidget.add(input);
		    pWidget.add(pInputTest); //testing below not used on post
			pWidget.add(hpButtons);
			
			// init widget
			setWidget(pWidget);
			
			//Style
			pWidget.setCellHorizontalAlignment(hpButtons, HorizontalPanel.ALIGN_CENTER);
			input.setWidth("100%");
			input.setHeight("300");
			
			// observe
			bUpdate.addClickListener(this);
			bClose.addClickListener(this);
		
		}
		
		/**
		 * get rta text
		 * 
		 * @return html
		 */
		public String getRTAText() {
			return input.getHTML();
		}
		
		/**
		 * set rta text
		 * 
		 * @param text html
		 */
		public void setRTAText(String text) {
			input.setHTML(text);
		}
		
		
		/**
		 * draw rta timed
		 * 
		 * this will work, but only the first time 
		 */
		private void drawRTATimed() {
			
			Timer t = new Timer() {
				public void run() {
					drawRta();
				}
			};
			t.schedule(5);
			
		}
		
		/**
		 * init rta after timed event
		 */
		private void drawRta() {
			
			// init rta
			RichTextArea rtaInput = new RichTextArea();
			
			// init rta toolbar
			RichTextToolbar rtaToolbar = new RichTextToolbar(rtaInput);
			
			pInputTest.add(rtaToolbar);
			pInputTest.add(rtaInput);
			
			rtaInput.setWidth("100%");
			rtaInput.setHeight("300");
			
			this.center();
		}
		
		/**
		 * observe
		 */
		public void onClick(Widget sender) {
				
			if (sender == bUpdate) {
				this.sSelected = "update";
			}
			
			if (sender == bClose) {
				this.sSelected = "close";
			}
			
			//notify calendar of change
			if (changeListeners != null) {
				changeListeners.fireChange(this);
			}

		}
		
		/**
		 * get selected 
		 * @return
		 */
		public String getSelected() {
			return this.sSelected;
		}

		/**
		 * observers
		 * @param listener
		 */
		public void addChangeListener(ChangeListener listener) {
			if (changeListeners == null)
				changeListeners = new ChangeListenerCollection();
			changeListeners.add(listener);
		}

		public void removeChangeListener(ChangeListener listener) {
			if (changeListeners != null)
				changeListeners.remove(listener);
		}
}

Comment by re.pichler, Jun 29, 2008
Comment by modi.tamam, May 27, 2009

rtyrtytryx cfghfgh

Comment by george.viseloy, Jun 25, 2009

<b>Hi</b>


Sign in to add a comment
Hosted by Google Code