on 12-28-2014 6:08 PM
Hi,
I am trying to use component .During that i am facing an error in component.js file .Please help me to find the error.And suggest me to know more about component.js for a fresher in UI5
Please go through the code :
Error i am facing :
UIComponent.js:6 Uncaught TypeError: undefined is not a function
Index.html
---------------
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-resourceroots='{
"sap.ui.demo.myApp": "./"
}'>
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
new sap.ui.core.ComponentContainer({
name : "sap.ui.demo.myApp"
}).placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
component.js
--------------------
jQuery.sap.declare("sap.ui.demo.myApp.Component");
sap.ui.core.UIComponent.extend("sap.ui.demo.myApp.Component",{
createContent : function()
{
/*var oview = sap.ui.view({
id : "app",
viewName : "sap.ui.demo.myApp.view.App",
type : "JS",
viewData : { component : this }
});*/
var oView = sap.ui.view({
id : "app",
viewName : "sap.ui.demo.myApp.view.App",
type : "JS",
//viewData : { component : this }
});
//var omodel = new sap.ui.model.json.JSONModel("model\mock.json");
//oView.setModel(omodel);
return (oView);
}
});
App.view
-------------
sap.ui.jsview("view.App", {
getControllerName : function() {
return "view.App";
},
createContent : function(oController) {
var btn = new sap.m.Button({
text : "Hii"
});
return btn;
}
});
Hello Jagadeesh,
Two things,
1. In the App.view.js, change the first line from:
"sap.ui.jsview("view.App", {"
to:
"sap.ui.jsview("sap.ui.demo.myApp.view.App", {"
2. Create an App.controller.js with content such as:
sap.ui.core.mvc.Controller.extend("sap.ui.demo.myApp.view.App", {
});
If the above changes resolve your error, you can then add a function to the controller which handles the button's press event.
Regards,
Scott
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank You Scott.It resolved my problem i got the expected output.
But still in console log i am getting an error .Could u please check
GET http://localhost:8081/my_app/Component-preload.js 404 (Not Found)sap-ui-core.js:27 Q.ajaxTransport.sendsap-ui-core.js:27 Q.extend.ajaxsap-ui-core.js:80 Xsap-ui-core.js:80 jQuery.sap.requiresap-ui-core.js:134 sap.ui.component.loadsap-ui-core.js:134 sap.ui.componentComponentContainer.js:6 sap.ui.core.ComponentContainer.onBeforeRenderingsap-ui-core.js:134 a._callEventHandlessap-ui-core.js:134 a._handleEventsap-ui-core.js:134 tsap-ui-core.js:134 R.renderControlsap-ui-core.js:134 R.rendersap-ui-core.js:134 U.rerendersap-ui-core.js:134 k.renderPendingUIUpdatessap-ui-core.js:134 k.initsap-ui-core.js:134 k.handleLoadsap-ui-core.js:134 (anonymous function)sap-ui-core.js:80 lsap-ui-core.js:80 finishTasksap-ui-core.js:134 (anonymous function)sap-ui-core.js:27 Q.Callbacks.rsap-ui-core.js:27 Q.Callbacks.t.fireWithsap-ui-core.js:16 Q.extend.readysap-ui-core.js:16 U
@Sakthivel Elango please help me on this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.