Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    CodeMirror and GWT.

    Hey guys.

    I've gotten a task to make a Textarea syntax highlighted and to have the autofill method implemented.

    My Textarea will consist of XML markup and I am using gwt and smartgwt.

    So, what I have done so far is to look into http://codemirror.net/demo/xmlcomplete.html source code and tried that out. It all works if I copy paste this into my .html file.

    But when Im trying to implement this dynamically using GWT, things start to get troublesome.

    Here is my XMLWindow class that creates the textarea: (Its very primitive. The real textarea and form has more to it)
    Code:
    DynamicForm form2 = new DynamicForm();
    		TextAreaItem textA = new TextAreaItem();
    		textA.setValue("<test></test>");
    		String id = "test";
    
    		form2.getElement().getElementsByTagName("textarea").getItem(0)
    				.setId(id);
    form2.setNumCols(1);
    		form2.setItems(textA);
    		vl.setMembers(form2);
     addStyleToTextArea(String id)
    And a native method to call for my javascript function:
    Code:
    native void addStyleToTextArea(String id) /*-{
    		$wnd.addTest(id); //$wnd is a NSNI synonym for 'window'
    	}-*/;

    The javascript function is so to say a function including adding the codemirror functions and style to my textarea. It is very long, but it has everything from line 32 to line 108 in the source code from http://codemirror.net/demo/xmlcomplete.html, basically:
    Code:
    function addTest(id){
    //All the styling done from the source code from  [url]http://codemirror.net/demo/xmlcomplete.html[/url]
    
    var editor = CodeMirror.fromTextArea(document.getElementById(id), { 
    .................
    }
    I am getting a :
    Code:
    com.google.gwt.event.shared.UmbrellaException: Exception caught: (TypeError) @package.client.XMLWindow::addStyleToTextArea(Ljava/lang/String;)([string: 'test']): place is null
    I have been looking into the http://code.google.com/p/codemirror2-gwt/.
    But following his examples basically resulted in nothing happening at all.

    Have anyone tried the same and would know If I am doing it right or have some tips on how to solve this?

    Regards!
    Last edited by haavamoa; 13 Jun 2013, 02:11.

    #2
    bump

    bumpbumpbump

    Comment

    Working...
    X