goog.provide('oneup.ui.widgets.Widget');

oneup.ui.widgets.Widget = function(urlBase) {
	oneup.ui.Component.call(this);
	this.method_ = 'getData';
	this.controller_ = urlBase;
	this.widgetDiv_ = goog.dom.createDom('div');
	this.loader_ = new oneup.ui.widgets.Loader().render();
	this.holder_ = goog.dom.createDom('div', {'class':'widgetHolder', 'style': 'display:none;'});
	this.widgetDiv_.appendChild(this.loader_);
	this.widgetDiv_.appendChild(this.holder_);
};	
goog.inherits(oneup.ui.widgets.Widget, oneup.ui.Component);

oneup.ui.widgets.Widget.prototype.render = function() {
	var that = this;
	goog.net.XhrIo.send(oneup.app.dataAccess.getDataUrl(this.method_, this.controller_), function(response) {
		if (response.target.isSuccess()) {
			that.dataLoaded(response);
		}
		that.loader_.style.display = 'none';
		that.holder_.style.display = '';
	});
	return this.widgetDiv_;
};

oneup.ui.widgets.Widget.prototype.dataLoaded = goog.abstractMethod;

