cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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;


	

Accepted Solutions (0)

Answers (2)

Answers (2)

ericci
Active Contributor
0 Kudos

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?

former_member365727
Active Contributor
0 Kudos

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