Skip to Content
0
Apr 25, 2018 at 07:33 AM

Data is not coming on second view page.

107 Views Last edit Apr 25, 2018 at 01:54 PM 4 rev

Hi All,

I am passing value from one view to another view but data is not coming on send view page.

can anyone give input on same,why data is not passing on page view2.

error:

<br>

View1-Controller:


onInit: function() { //this.mymodelobject = new sap.ui.model.json.JSONModel(); jsonModel = new sap.ui.model.json.JSONModel(); },


 senddata : function (){ 

var form_ref = sap.ui.getCore().byId("Id_simpleform1"); 
var objectForm = form_ref.getContent();
var myJson = {}; myJson.oName = objectForm [1].getValue();
    myJson.oId = objectForm [3].getValue();
    myJson.OSubject = objectForm [5].getValue(); 
    myJson.oLocation = objectForm [7].getValue(); 
    jsonModel.setData(myJson); 
    sap.ui.getCore().setModel(jsonModel); 
    var form_ref = sap.ui.getCore().byId("Id_simpleform1"); 
    var view_ref = sap.ui.getCore().byId("idview2"); 
    form_ref.removeAllContent(); 
    form_ref.addContent(view_ref); },


view2 page:
createContent : function(oController) {
		
		 var oTextview = new sap.ui.commons.TextView({
			                       text : "Welcome to My second page."
		 });
		 var oSimplelayoutFormview2 = new sap.ui.layout.form.SimpleForm({
			                                 
			                        id: "simpleform_v2" ,
                                    maxContainerCols : 2,
                                    editable: true ,
                                    content : [
                                               
                                             
                                               new sap.ui.commons.Label({ text : "NAME:" }),
                                               new sap.ui.commons.TextField({ value : "{/xyz}" , width : "15em"}),
                                              


                                               new sap.ui.commons.Label({ text : "ID:" }) , //2
                                               new sap.ui.commons.TextField({ value : "{/Id}" , width : "15em"}) ,//3


                                               new sap.ui.commons.Label({ text : "SUBJECT:" }) , //4
                                               new sap.ui.commons.TextField({ value : "{/Subject}" , width : "15em"}) , //5


                                               new sap.ui.commons.Label({ text : "LOCATION:" }) , //6
                                               new sap.ui.commons.TextField({ value : "{/pqr}" , width : "15em"}) , //7
                                               new sap.ui.commons.Button({
       		    	                                                         text : "SubmitData1",
       		    	                                                         width : "100px",
       		    	                                                         height : "25px",
       		    	                                                         press : oController.senddatax
       		    	                              
       		                                      })  
                                               
                                                                                              
                                               ]
		 });
		 
		                 return [oSimplelayoutFormview2 , oTextview];

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.ui.commons"
				data-sap-ui-theme="sap_bluecrystal">
		</script>
		<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->


		<script>
				sap.ui.localResources("zbh_passvalue_v1_to_v2");
				var view1 = sap.ui.view({id:"idview1", viewName:"zbh_passvalue_v1_to_v2.view", type:sap.ui.core.mvc.ViewType.JS});
				var view2 = sap.ui.view({id:"idview2", viewName:"zbh_passvalue_v1_to_v2.view1", type:sap.ui.core.mvc.ViewType.JS});
				view1.placeAt("content");
		</script>


	</head>
	<body class="sapUiBody" role="application">
		<div id="content"></div>
	</body>
</html>
View1 page:-
createContent : function(oController) {


		       var oSimpleFormLayout = new sap.ui.layout.form.SimpleForm({
		    	   
		    	                     id: "Id_simpleform1" ,
                                     maxContainerCols : 2,
                                     editable: true ,
                                     content : [
                                                
                                                 new sap.ui.commons.Label({ text : "NAME:" }) ,//0
                                                 
                                               
                                                 new sap.ui.commons.TextField({ value : "{/xyz}" , width : "15em"}) , //1


                                                 new sap.ui.commons.Label({ text : "ID:" }) , //2
                                                 new sap.ui.commons.TextField({ value : "{/Id}" , width : "15em"}) ,//3


                                                 new sap.ui.commons.Label({ text : "SUBJECT:" }) , //4
                                                 new sap.ui.commons.TextField({ value :"{/Subject}" , width : "15em"}) , //5


                                                 new sap.ui.commons.Label({ text :"LOCATION:" }) , //6
                                                 new sap.ui.commons.TextField({ value : "{/pqr}" , width : "15em"}) , //7
		                                                            


                                  		          new sap.ui.commons.Button({
                                  		    	                              text : "SubmitData",
                                  		    	                              width : "100px",
                                  		    	                              height : "25px",
                                  		    	                              press : [oController.senddata,oController]
                                  		    	                              
                                  		          })
                                  		      
                                                
                                                
                                                ]
		       });
		
		       	       
		       
		       return [oSimpleFormLayout,oButton1];

}

Attachments

blankpage.jpg (27.4 kB)