All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ui5.controller.Connection.controller Maven / Gradle / Ivy

showFooter : function() {
	return true;
},
init : function() {
	var oModel = new JSONModel();
	var that = this;
	oModel.attachRequestFailed(function(oEvent) {
		that.displayError(JSON.parse(oEvent.getParameter("responseText")));
	});
	var oComponentsModel = new JSONModel();
	var sConnectionname = jQuery.sap.getUriParameters().get("connectionname");
	if (!!sConnectionname) {
		oModel.loadData("../rest/connections/" + encodeURI(sConnectionname));
		oStateModel.setProperty("/title", "Connection settings");
		oStateModel.setProperty("/new", false);
	} else {
		oModel.loadData("../rest/connection/template");
		oStateModel.setProperty("/title", "Create new Connection");
		oStateModel.setProperty("/new", true);
	}
	this.getView().setModel(oModel);
	oStateModel.setProperty("/breadcrumbs", [ {"text" : "Homepage", "link" : "./Home"}, {"text" : "Connections", "link" : "./Connections"} ] );
},
save : function(oEvent) {
	var oModel = this.getView().getModel();
	var data = JSON.stringify(oModel.getJSON());
	var that = this;
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("POST", "../rest/connections/" + encodeURI(oModel.getProperty("/name")));
	xmlhttp.setRequestHeader("Content-Type", "application/json");
	xmlhttp.onreadystatechange = function() {
	    if (xmlhttp.readyState == 4) {
	    	if (xmlhttp.status == 200) {
		        that.displaySuccess(JSON.parse(xmlhttp.responseText));
		    } else {
		        that.displayError(JSON.parse(xmlhttp.responseText));
		    }
		}
	}
	xmlhttp.send(oModel.getJSON());
},
cancel : function(oEvent) {
},
onTileProducerAdd : function(oEvent) {
	var sConnectionname = jQuery.sap.getUriParameters().get("name");
	window.location.href = './Producer?connectionname=' + encodeURI(sConnectionname);
},
onTileConsumerAdd : function(oEvent) {
	var sConnectionname = jQuery.sap.getUriParameters().get("name");
	window.location.href = './Consumer?connectionname=' + encodeURI(sConnectionname);
},
onTileProducerPress : function(oEvent) {
	var path = oEvent.getSource().getBindingContext().getPath();
	var oModel = this.getView().getModel("components");
	var obj = oModel.getProperty(path);
	var sConnectionname = jQuery.sap.getUriParameters().get("name");
	if (oEvent.mParameters.action === "Press") {
		window.location.href = './Producer?connectionname=' + encodeURI(sConnectionname) + "&producername=" + encodeURI(obj.producername);
	}
},
onTileConsumerPress : function(oEvent) {
	var path = oEvent.getSource().getBindingContext().getPath();
	var oModel = this.getView().getModel("components");
	var obj = oModel.getProperty(path);
	var sConnectionname = jQuery.sap.getUriParameters().get("name");
	if (oEvent.mParameters.action === "Press") {
		window.location.href = './Consumer?connectionname=' + encodeURI(sConnectionname) + "&consumername=" + encodeURI(obj.consumername);
	}
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy