cancel
Showing results for 
Search instead for 
Did you mean: 

how to load multiple json file present in the same path or keep whole data in single file

former_member338801
Participant
0 Kudos

Hello Experts, I need help in one requirement. I have to show same kind of information on click of 3 separate Generic tiles in sap ui5. On click of first time need to show title, image and description similarly for the other tiles as well same field but data would be different. It is JSON model and I have prepared json file in default model same json file path has been defined. I can access data in case of first tile click but in other cases getting below error. I have used manifest.json configuration no controller code here. Error : "Assertion failed: list bindings support only a single template object" manifest.json code : "dataSources": { "init_data": { "uri": "model/data.json", "type": "JSON" } } "": { "type": "sap.ui.model.json.JSONModel", "dataSource": "init_data" } Json file structure : { "hrAppCollection": [{ "Heading": "TimeSheet Entry app", "AppPicUrl": "./image/timesheet.jpg", "PlaceHolderText": "Approval of Firefighter Access Request submitted for Production system instances." }, { "Heading": "Approve Firefighter Request", "AppPicUrl": "./image/timesheet.jpg", "PlaceHolderText": "Approval of Firefighter Access Request submitted for Production system instances." }] } I have tried using named model concept and did some json file data manipulation but I am not able to figure out how to achieve this. Let me know if you need any further information on the same. BR, RK

maheshpalavalli
Active Contributor
0 Kudos

Hi ram mishra,

The code is unreadable, you can put it in the code editor for formatting..

Are doing list binding anywhere? the question is not very informative as well. Please rephrase your question in points. Code where you are binding will be helpful. And please tell the place where the error is instantiating from..? Like when you are setting or binding model..

BR,

Mahesh

former_member338801
Participant
0 Kudos

Thanks Mahesh for your reply. You can download the code and check from below github url.

1) I have to show list of app in the card upon click of tile.

2) All the data coming from the json file. I am using Carousel sap ui5 control to achieve this requirement.

3) I am able to read using manifest.json configuration for first tile but How can I achieve the same for other three. If you run the code you will be able to understand that.

Zovppoc.zip

url : https://github.com/rkmishra2703/RK-

Let me know if you have any doubt.

BR,

RK

maheshpalavalli
Active Contributor
0 Kudos

HI ram mishra,

Your app looks good, Only for the first page you did the binding and other places it's hard coded.. So what is the issue you are getting?

BR,

Mahesh

former_member338801
Participant
0 Kudos

Hi Mahesh,

As explain I am trying to access 2 diffrent JSON files. You would have seen. I am not able to access 2nd JSON data in second tile name hr tile. Hope you got my issue.

I tried named model concept but didn't help.

I was trying many thing so binding would have removed by me.

BR,

RK

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hello ram mishra,

Please understand you Products.json file. It contains the array of data so you have to select properly which data you want to show.

For example purpose I have selected first one.You can refer the screenshot.

maheshpalavalli
Active Contributor
0 Kudos

Hi ram mishra,

You need to load odata models in the data sources as far as I know.. You just need to enter the data at the models and mention the URI..

In your same project's manifest.json. Just add the below lines of code it will load the JSON data and set it the test and test1 models respectively.

If you don't want a name for the model it then don't give any name there just pass "". But remember there can be only one nameless model for a control.. So for the component, there can be only one. So for other models you need to provide name.

		"models": {
			"i18n": {
				"type": "sap.ui.model.resource.ResourceModel",
				"settings": {
					"bundleName": "com.newtiles.Znewtilesovp.i18n.i18n"
				}
			},
			"test": {
				"type": "sap.ui.model.json.JSONModel",
				"uri": "./mockdata/scmapp.json",
				"preload": true
			},
			"test1": {
				"type": "sap.ui.model.json.JSONModel",
				"uri": "./mockdata/products.json",
				"preload": true
			}
		},

Alternatively you can load all the data in a single model.. Just prepare your data in the below format:

{
"scmAppCollection":[{...},{...},{...}],

"anotherProperty":[{...},{...},{...}]
}

BR,

Mahesh

former_member338801
Participant
0 Kudos

Really appreciate your help and support. I have tried all these things in my case but nothing worked.

Named Model concept (creating model by different names) and changes in the json file as you suggested. You can also check in my code.

I am getting below error in the console.

Error : "Assertion failed: list bindings support only a single template object"

BR,

RK

former_member338801
Participant
0 Kudos

Just to add more first call works well but in the second call data is not getting retrieved due to below console error : "Assertion failed: list bindings support only a single template object"

You could suggest some alternative that will be really helpful for me.

BR,

RK

maheshpalavalli
Active Contributor
0 Kudos

Hi ram mishra

You might be missing some small thing there in your project.. Attaching your updated project.. I changed it to named model.

https://github.com/mahesh0431/testTemp.git

BR,
Mahesh

former_member338801
Participant
0 Kudos

Hi Mahesh,

I am getting error while running your project.

HTTP Status 404 - Not Found

BR,

RK

former_member338801
Participant
0 Kudos

Hi Mahesh,

Please find attached step by step screenshot to show my issue. My real issue is still not fixed first time it triggers but in case of 2nd time model triggeres blank data with attached error.

Multiple json file instantiation.docx

https://github.com/rkmishra2703/RK-

BR,

RK

maheshpalavalli
Active Contributor
0 Kudos

Hi ram mishra,

The error is coming because you are having 2 controls inside the carousel

			<Carousel xmlns="sap.m" id="carousel0" pages="{test1>/ProductCollection}">
				<VBox id="vbox0">
					<Text text="Timesheet Entry App"/>
					<Image src="./image/timesheet.jpg" height="30%" width="20%"/>
					<Text xmlns="sap.m" text="Used to achieve time sheet entry capture and get approval." id="text2"/>
					<f:Card>
						<f:header>
							<cards:Header title="{Name}" subtitle="{Description}" iconSrc="{ProductPicUrl}" iconDisplayShape="Square"/>
						</f:header>
						<f:content>
							<VBox class="sapUiSmallMargin">
								<HBox>
									<Label text="Supplier" class="sapUiTinyMarginEnd"/>
									<Text text="{SupplierName}"/>
								</HBox>
								<HBox>
									<Label text="Status" class="sapUiTinyMarginEnd"/>
									<Text text="{Status}"/>
								</HBox>
							</VBox>
						</f:content>
					</f:Card>
				</VBox>
				<!--<VBox id="vbox1">-->
				<!--	<Text text="Page 2"/>-->
				<!--</VBox>-->
			</Carousel>

If you comment the other vbox : vbox1, then the error will gone..

Please check and confirm.

BR,

Mahesh