Skip to Content
0
Former Member
Jul 25, 2013 at 10:37 AM

Reusable view in UI5

171 Views

Hi All,

I am trying to use one view as a reusable/subview in different views but whenever i use this view, it gives me duplicate text field etc error. I am wondering if anyone knows about it..

Use Case is :

I create one common view and add all the elements in that View Called skillsView

  1. sap.ui.jsview("persistence_with_jpa_ui.skillsView, {

getControllerName : function() {

return "persistence_with_jpa_ui.skillsView";

},

createContent : function(oController) {

// here i add all the controls

var name = new sap.ui.commons.Link("nameLabel", {

text: "Name",

width: "200px",

enabled :false,

});

Now i am using this view as a reuse/subview view in other views like

2 Create Another view called ProfileView view and inside view i reuse skillsView

sap.ui.jsview("persistence_with_jpa_ui.ProfileView", {

getControllerName : function() {

return "persistence_with_jpa_ui.ProfileView ";

},

createContent : function(oController) {

// now i am calling skillsView here

var view = sap.ui.view({

id : "createContentView",

viewName : "persistence_with_jpa_ui.skillsView", //calling skills view as a subview at this point

type : sap.ui.core.mvc.ViewType.JS

});

return view;

}

});

it works fine in this view and display all the controls

3) Now, i have created another view called Setting view and call the skills view inside

sap.ui.jsview("persistence_with_jpa_ui.SettingView", {

getControllerName : function() {

return "persistence_with_jpa_ui.SettingView";

},

createContent : function(oController) {

// now i am calling skillsView here

var view = sap.ui.view({

id : "createContentView",

viewName : "persistence_with_jpa_ui.skillsView", //calling skills view as a subview at this point

type : sap.ui.core.mvc.ViewType.JS

});

return view;

}

});

But at this point,, it gives me duplicate element "nameLabel" error on js console?

Any idea?