Skip to Content
avatar image
Former Member

unable to reuse fragment sapui5

HI All,

I am creating Fiori app using master/Detail template. I have different screens

1. search

2. Create

3. Change

In all this i have a common valueHelp for function location. My problem is when I am in create page and open functionlocation value help it opens up. But when i move to search screen, and open it I am getting duplicate id error.

I want to reuse the fragments . Any pointers?

Note : I tried to destroy the fragment in exit method, but when i navigate(from ccreate to search) exit is not getting called.

regards

Fehmina

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 05, 2017 at 06:10 AM

    Do not use id's in fragments. If you are using id's then you have to destroy the control on closing the fragment. Without using id's also you can manipulate the fragment controls, by using the getContent() method to the fragment object. This method returns an array of all your fragment controls. You can manipulate the fragment controls by referring them from this array instead of using id's.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 29, 2017 at 04:03 PM

    Hello,

    In your fragment, do not populate id property from tags.

    Regards

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2017 at 06:45 AM

    I am assuming you have different views for Search, Create and Change scenarios. If you do, then when you are creating the object from fragment pass the id of the View, something like this.

    var oDialog = sap.ui.xmlfragment(this.getView().getId(),"your.fragment.path.name", this)

    "this" object is the controller of the View that's (re)using the fragment.

    As can be see, the first parameter is the ID of the view that is using the XML fragment. The IDs within the fragment are now prefixed with xml view id that and you should not get duplicate Id errors.

    Add comment
    10|10000 characters needed characters exceeded