Skip to Content
avatar image
Former Member

SAPUI5 (jQuery) changes

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"/>
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 31, 2017 at 01:34 PM

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

    src="{PDF>/mapUrl}" 

    Regards,

    Jamie

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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"}
      
  • Oct 31, 2017 at 02:25 PM

    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

    Add comment
    10|10000 characters needed characters exceeded