cancel
Showing results for 
Search instead for 
Did you mean: 

How to use SAPUI5 Building blocks inside a section of a ObjectPage in a freestyle app?

Andreas_M
Explorer
0 Kudos
737

Is it possible to use building blocks, specifically Fields, within a Section of an ObjectPage in a Freestyle app? I'm receiving the following error message: ModuleError: failed to load 'sap/fe/macros/Field.js' from ../resources/sap/fe/macros/Field.js: script load error. Is this even possible and what should I keep in mind? I have been able to integrate the building blocks within DynamicPages or other pages.

Thanks for your help.

Best regards
Andreas

Accepted Solutions (0)

Answers (1)

Answers (1)

nicolas_lunet
Product and Topic Expert
Product and Topic Expert

Hello Andreas,

It all depends on how you load your ObjectPage, i assume that you are not using the standard FE object page in this case but rather loading an own ObjectPageLayout in this case.

Then you'd fit within the `usage from custom apps` case that we describe here https://sapui5.hana.ondemand.com/test-resources/sap/fe/core/fpmExplorer/index.html#/buildingBlocks/g...

Your page need to be loaded from within an FE component and extend the base FE page controller in order to use the FE building blocks inside.

Hope that helps !

Andreas_M
Explorer
0 Kudos

Hello Nicolas,

thanks for your answer. Your assumption is correct that I want to use my own ObjectPageLayout. I defined my page as described in the documentation in the manifest and using the Page Controller from "sap/fe/core/PageController". Inside the ObjectPage I use section with blocks and I assume there is the problem. I define my block in two extra files as stated in the UI5 documentation (e.g. Block.js and Block.view.xml ) and the block is extending from BlockBase. Is this the problem that I'm extending there from BlockBase oder that inside the block the sap.fe.macros couldn't be loaded?

Thanks for your help. If you need any additional info, please let me know.

Best regards
Andreas

nicolas_lunet
Product and Topic Expert
Product and Topic Expert
0 Kudos

It's more a question on how you are creating the block content.

The building blocks are xml templating operators so you cannot require them at runtime in JS.

Andreas_M
Explorer
0 Kudos

I don't know If I got it correctly.

For example I have this part in my code for the ObjectPage:

<ObjectPageSection titleUppercase="false" id="opsArticle" title="Article">

 <subSections>

 <ObjectPageSubSection id="opssArticle">

 <blocks>

 <blocks:BlockArticle id="blockArticle"/>

 </blocks>

 </ObjectPageSubSection>

 </subSections>

 </ObjectPageSection>

And my code is defined in BlockArticle.view.xml:

<VBox width="30vw">

 <Text text="Field A" />

 <macros:Field metaPath="A" id="fA" />

 <Text text="Field B" />

 <macros:Field metaPath="B" id="fB" />

</VBox>

This is my current setup where I got the error in my question. My Building Block is defined in XML but is this block loaded in JS during runtime?

If its the question how I'm creating the block, what is the right way to do it to use building blocks inside?

Thanks & Best regards
Andreas