Skip to Content
avatar image
Former Member

How to load a fragment with xml templating?

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    May 16 at 10:13 AM

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

    • Former Member

      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.

  • May 16 at 12:40 PM

    do you have the property rel=preload while using the template? If yes try it.

    Add comment
    10|10000 characters needed characters exceeded