Skip to Content
0

Getting the error - Uncaught TypeError: Cannot read property '0' of undefined

Aug 15, 2017 at 12:24 PM

191

avatar image
Former Member

Hi,

In my UI5 development, I am trying to create a simple form with a button. When I am adding the event 'press' in the sap.ui.commons.Button class, I am getting the error:

Uncaught TypeError: Cannot read property '0' of undefined
    at d.h.applySettings (ManagedObject-dbg.js:965)
    at ManagedObject-dbg.js:436
    at d.constructor (ManagedObject-dbg.js:450)
    at d.constructor (Element-dbg.js:99)
    at d.constructor (Control-dbg.js:103)
    at new f (Metadata-dbg.js:346)
    at new o (Global-dbg.js:294)
    at f.createContent (LoonyToons.view.js?eval:84)
    at eval (eval at evalModuleStr (jquery.sap.global-dbg.js:3265), <anonymous>:880:236)
    at Function.h.runWithPreprocessors (ManagedObject-dbg.js:800)

Here is my code -

var oForm = new sap.ui.commons.form.SimpleForm('idForm', {
maxContainerCols : 2,
content: [
         new sap.ui.commons.Label({text : "Employee Name"}),
			          new sap.ui.commons.TextField(
			        	{
	        		width :"5cm",
	        		value : "{/empStr/empName}",
	        		enabled : "{/empStr/fieldEnabled}"
			        	}
			        	
			          ),
			          
			  new sap.ui.commons.Label({text :"Employee No."}),
		          new sap.ui.commons.TextField(
			        	
	        		  {
	       			  width : "4cm",
	       			  value : {
	 		          path :"/empStr/empNo"
			          },
		       	  enabled :{
			       		  path : "/empStr/fieldEnabled"
			       		  },
			        		  }
			          ),
			      
		new sap.ui.commons.Label({text :"Employee City"}),
	        new sap.ui.commons.TextField({
			        	  
	           width : "4cm"
	}).bindValue("/empStr/empCity").bindProperty("enabled", "/empStr/fieldEnabled"),
			          
		new sap.ui.commons.Button("idButton", {

			text : "Press Me",
			press : oController.pressMe
			          	
			          })
			          ]         
		});
		return oForm;


	
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Srikanth KV Aug 15, 2017 at 04:05 PM
0

where is the event handler code for the button..? Why are you using sap.ui.commons.Button, this is depricated and you should use sap.m.Button

Share
10 |10000 characters needed characters left characters exceeded
Emanuele Ricci Aug 16, 2017 at 02:15 PM
0

As Srikanth already suggest you should:

1) use sap.m.Button

2) use XML View and not JS View

do you have a working demo we could see and test?

Share
10 |10000 characters needed characters left characters exceeded