on 05-16-2018 7:35 AM
Hi ,
I have a xml fragment which has xml tempalte <template:with>... When i try to laod this tempalte in the controller using the sap.ui.xmlfragment() constructor it throws error that template.js is not found. How can I pre-process this fragment and load this fragment inside the controller?
do you have the property rel=preload while using the template? If yes try it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where should i include this exactly? My fragment is as below:
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:layout="sap.ui.layout"
xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"
xmlns:build="sap.build">
<layout:content>
<template:with path="ovpCardProperties>/annotationPath" helper="sap.ovp.cards.AnnotationHelper.resolveEntityTypePath" var="lineItem">
<!-- Sap ui5 controls -->
</template:with>
</layout:content>
</core:FragmentDefinition>
I am not sure where and how you are using "<template:with>", but SAPUI5 is looking for template.js to be able to handle the control. So template.js is not defined at project level.
The JS files (namespaces) for XML elements (controls) are defined in the first level of XML.
For example:
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<Dialog id="helloDialog" title="Hello {/recipient/name}"> </Dialog>
</core:FragmentDefinition>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My template is in a file called 'orders.fragment.xml' as below :
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:layout="sap.ui.layout"
xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"
xmlns:build="sap.build">
<template:with path="ovpCardProperties>/annotationPath" helper="sap.ovp.cards.AnnotationHelper.resolveEntityTypePath" var="lineItem">
<!-- Sap ui5 controls -->
</template:with>
</core:FragmentDefinition>
<br>
Then in my javascript I try to load the fragment as below :
var orderFragment = sap.ui.xmlfragment(this.getView().getId(), "sap.container.orders", this);<br>
This line then throws the error : GET https://<tenent-name>.hana.ondemand.com/sap/ui5/1/resources/~201802081542~/http://schemas/sap/com/sa... 404 (Not Found)
I never used absolute URL in XML namespace definition and I do not think this is allowed by CORS anyway. You might be better off downloading the JS file into a project folder and add the relative path. Or there is some workaround with the "neo-app.json" file or with "manifest.json" by defining path or resource.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.