Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » why does the document.getElementById(this._id) return null?(help to create custom widget)
why does the document.getElementById(this._id) return null? [message #768628] Tue, 20 December 2011 08:50
Song David is currently offline Song David
Messages: 185
Registered: April 2011
Senior Member
Hi all,
I want to create a custom widget, and the widget class has only one property and I invoke the method document.getElementById(this._id) in javascript, but got null, and can not find the dom element, but if I add an alert before it, after clicking the alert button and the method get a value. how to get the element without the alert ?

in rap view:
Bar2D bar = new Bar2D(parent, SWT.FILL);
bar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
bar.setChartData("bar");


in javascript code:
  properties : {
        chartData : {
            init : "",
            apply : "initChart"
        }
    },
    
    members : {
        _doActivate : function() {
            var shell = null;
            var parent = this.getParent();
            while( shell == null && parent != null ) {
                if( parent.classname == "org.eclipse.swt.widgets.Shell" ) {
                    shell = parent;
                }
                parent = parent.getParent();
            }
            if( shell != null ) {
                shell.setActiveChild( this );
            }
        },
        
        initChart : function() {
        	if(this.getChartData()){
        		var chartId = "fms"+Math.ceil(Math.random()*10000);
        		var chart = new FusionCharts("/resources/Area2D.swf?id=" + Math.random(), chartId , "100%", "100%", 0, 1);
        		chart.setJSONData(this.getChartData());
        		chart.render(this._id);
        	}
        }
       
    }


thanks a lot

David
Previous Topic:Use 1.5 M2 RA theme in 1.5 M4
Next Topic:RAP 1.50.M3 Standalone
Goto Forum:
  


Current Time: Mon Jul 28 10:34:30 EDT 2014

Powered by FUDForum. Page generated in 0.02206 seconds