Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Fragments with their own controller - Initiated by a XML VIew

$
0
0

Hello again!

 

a new day - new issues... :-(

I have to admit, I am going to get really frustrated. You always have a learning curve, when you are working with a new framework, but SAPUI is a really tough one (close second was/is Spring , a bit better after Spring boot).

 

I do not know how much time I invested to rewrite a js-example in a XML view. I am really not sure if it is the right approach to give the user millions of ways to do a thing. But enough complaining.

 

 

The problem today is how to attach a controller to a fragment. Pretty easy achievable in js, example: DialogTest/initial.controller.js at master · njames/DialogTest · GitHub

 

I am doing exactly that for my dialogs. But now I have a fragment, which will be shown directly at startup in the view.

 

Normally I have something like this:

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="ViewController">

    <Page>

        <content>

            <core:Fragment fragmentName="superView" type="XML" />

        </content>

    </Page>

</mvc:View>

 

But how to pass a controller in this case? 'superView' needs its own controller.

Of course, I could place it using the afterRendering Method of the view.

But this is not the way it should work...

 

Hope you can help me again!

 

Thanks a lot and best regards

Ben


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>