cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 (jQuery) changes

Former Member
0 Kudos

Hi guys,

I have some issues with the new release 🙂

For starters I'll link the MVC data

1. The view

<View 
	controllerName="generated.app.controller.pdf" 
	xmlns:m="sap.m" 
	xmlns:html="http://www.w3.org/1999/xhtml">
	<m:Label id="NameID" text="{PDF>mapUrl}" design="Bold"/>
	<html:div id="divPdf" style="height:100%">
		<html:iframe src="{PDF>mapUrl}" id="pdfFrame" style="width:100%;height:100%;overflow:visible"></html:iframe>
	</html:div>
</View>

2. And the controller:

		onInit: function() {
			var oModelPDF = new sap.ui.model.json.JSONModel();
			this.getView().setModel(oModelPDF, "PDF");
		},
onBeforeRendering: function() {
			var url = "https://www.dhs.state.or.us/policy/spd/transmit/ar/2017/ar17048.pdf";
			var model = this.getView().getModel("PDF");
			var data = {
				"mapUrl": url
			};
			model.setData(data);
			model.updateBindings();
		},
		onAfterRendering: function() {
			var url = "https://www.dhs.state.or.us/policy/spd/transmit/ar/2017/ar17048.pdf";
			var model = this.getView().getModel("PDF");
			var data = {
				"mapUrl": url
			};
			model.setData(data);
			model.updateBindings();
		}

What I'mt trying to achieve is to access the named model of my page. Sounds simple but I get "HTTP Status 404 - Not Found" and not because the link isn't accessible.

Although I can access the data in my model with the "usual" commands

code: sap.ui.getCore().byId("__component0---pdf").getModel("PDF").getData().mapUrl
answer: "https://www.dhs.state.or.us/policy/spd/transmit/ar/2017/ar17048.pdf"

The view can't access the model.

Any idea why ?

Kind regards,

Petru

PS: I even tried other ways to access the data model:

<m:Label id="NameID" text="{	path: '{PDF>mapUrl}' }" design="Bold"/>

Accepted Solutions (0)

Answers (2)

Answers (2)

jamie_cawley
Advisor
Advisor
0 Kudos

In your label you have an extra set of brackets, the binding should be

text="{path: 'PDF>/mapUrl' }"

and would require that you have

data-sap-ui-bindingSyntax="complex"

defined in the bootstrap. The iframe you probably have to set the source via javascript. The html namespace will not be processed through UI5.

Regards,

Jamie

jamie_cawley
Advisor
Advisor
0 Kudos

In your view binding you are missing a forward slash, it should be

src="{PDF>/mapUrl}" 

Regards,

Jamie

Former Member
0 Kudos

Hi Jamie,

I modified the code (for both label and iframe) and it still doesn't work:

	<m:Label id="NameID" text="{	path: '{PDF>/mapUrl}' }" design="Bold"/>
	<html:div id="divPdf" style="height:100%">
		<html:iframe src="{PDF>/mapUrl}" id="pdfFrame" style="width:100%;height:100%;overflow:visible"></html:iframe>
	</html:div><br>

I get almost the same Google Console Log error.

Failed to load resource: the server responded with a status of 404 (Not Found)      mapUrl%7D<br>

When before it was:

sap-ui-core.js:126 GET https://webidetestingxxxxxxxxx.dispatcher.hana.ondemand.com/webapp/test/%7BPDF%3E/mapUrl%7D 404 (Not Found)

PS: The model looks like this:

sap.ui.getCore().byId("__component0---pdf").getModel("PDF").getData()
{mapUrl: "https://www.dhs.state.or.us/policy/spd/transmit/ar/2017/ar17048.pdf"}