on 04-28-2015 1:35 PM
Hello experts,
I cannot figure out why am i getting following error:
uncaught Error: Error: adding element with duplicate id 'menuBarID'
ID has been used just once in the application, so what can be the reason behind this error??
Please help.
Thank you,
Best Regards,
Chetna
Hi,
You will be clicking or calling an event or function module where ID would be created again and again.
Don't give IdName, Sapui5 will automatically assign a valid id name.
or use like this.
I have written this in view.
var oInput = new sap.ui.commons.TextField(this.createId("nameId"),{
value: "Dhananjay Choubey"
});
and for accessing that element, I have written this in controller.
var json = {};
json.name = sap.ui.getCore().byId(this.createId("nameId")).getValue();
This is just a refrence. Use according to your code.
Regards
Dhananjay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dhananjay,
I am not able to retrieve the TextField value in controller when i use this.createId("nameId").
Please let me know if i am missing something.
my code
var oInput = new sap.ui.commons.Textfield(this.createId("nameId"));
In controller
var oInput = sap.ui.getCore().byId(this.createId("nameId")).getValue();
Thanks and Regards,
Saravanan
I have used like this.
IN View
createContent : function(oController) {
var oText = new sap.ui.commons.TextView({
text: "Enter your name:"
});
var oInput = new sap.ui.commons.TextField(this.createId("nameId"),{
value: "Dhananjay Choubey"
});
var oButton = new sap.ui.commons.Button({
text: "Submit",
press: function(){
oController.navigateToView2("view2");
}
});
var ele = [ oText, oInput, oButton ];
return ele;
}
In Controller
navigateToView2: function(view){
var json = {};
json.name = sap.ui.getCore().byId(this.createId("nameId")).getValue();
this.myModel.setData(json);
sap.ui.getCore().setModel(this.myModel);
var oRouter = sap.ui.core.routing.Router.getRouter("appRouter");
oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
oHashChanger.setHash(oRouter.getURL(view));
}
And it's working.
See where you are making mistakes.
To solve: Uncaught Error: Error: adding element with duplicate id 'application-Test-url-component---Main'
when navigating back you have to remove "id": "Main" at "sap.ui5" in manifest.json at "sap.ui5":
"sap.ui5": {
"flexEnabled": false,
"rootView":
{
"viewName": "nl.something.example.view.Main",
"type": "XML",
"async": true,
"id": "Main"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
same issue i got this error while navigating back to my home page ! any help :
Uncaught Error: Error: adding element with duplicate id 'container-Services---View1'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thread is now locked to prevent further necromancy.
Regards,
Chandra (Moderator)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You are creating the id twice by using createId() thus to get the value write the below code.
sap.ui.getCore().byId("nameId").getValue();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ID has been used just once in the application, so what can be the reason behind this error??
Without seeing any code, i just can guess you're re-instantiating the same control again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.