on 08-06-2017 5:38 AM
Hello I have JS View and One controller. I want to import all the data from js view into controller and store it in variable. How would I do that. I tried using
1.var oView = sap.ui.jsview('view.main') in controller but didnt work. can some one guide me. By doing this i want to write a function on Button press (in a view) which can function definition in controller and displays alert message. Below is my code.
2. what is use of oninit, onAfterrndering(), onBeforeRendering() etc. I didnt get it.
Any help/guidance will be really appreciated. Thanks 🙂
view.js file
sap.ui.jsview('view.main',{
getControllerName: function(){
return "view.main";
},
createContent: function(oController){
var text = new sap.m.Text({
text:"Hello SAP, We met finally!!",
});
var button = new sap.m.Button({
text:"Press Me",
press: function(){
alert("Hello, Are you SAP");
}
});
return new sap.m.Page({
// title:"{/name}",
content:[text, button]
});
}
});
------------------------------------
controller.js file
sap.ui.controller('view.main',{
// var oView = sap.ui.jsview('view.main');
onInit: function() {
},
// onBeforeRendering: function() {
// },
// onAfterRendering: function() {
// },
// onExit: function() { }
});
----------------------
Script.js file
sap.ui.getCore().attachInit(function(){
sap.ui.localResources("view");
var app = new sap.m.App({
initialPage : "idViewDashboard"
});
var view = sap.ui.view({
id : "idViewDashboard",
viewName:"view.main",
type : sap.ui.core.mvc.ViewType.JS
});
app.addPage(view);
app.placeAt("content");
});
I think it would be very helpful if you read this tutorial
https://sapui5.hana.ondemand.com/#docs/guide/3da5f4be63264db99f2e5b04c5e853db.html
the main idea is not to get an answer right away but you should try to understand how the framework works (MVC, data models in your application, how does the view/controller work, etc)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.