You can use a unique ID for a fragment that will be used as prefix for all controls in a fragment instance.
In SAPUI5, IDs are either automatically generated or given as string constants by the application developer.
In MVC views, another type of reusable components, all IDs which are given as static strings inside the declarative views (XML, HTML, JSON) are automatically prefixed with the view ID. For JSViews and for controls created in the controller code of declarative views, no automated prefixing exists. Instead, we recommend to use the View.createId() method to prefix the ID and ensure there are no ID collisions even when the view is used multiple times within the same page.
The method View.byId() is used to handle these prefixed IDs.
Fragments, however, are meant to be a more light-weight concept of separating and re-using UI parts, and in addition there are no fragment instances (in contrast to view instances) which could have IDs and handle ID prefixing helper functions. Therefore, static IDs in fragments are by default used as is, that is, they are not prefixed to make them unique. If no ID is given, it will be generated. However, when a fragment is supposed to be used more than once within one application, the prefixing mechanism can still be used by giving an ID when instantiating the fragment.
The basic principle is as follows: When a control ID is defined, declarative views add a prefix and the code in views should add a prefix. Fragments also add a prefix if they have a defined ID.
To get rid of the prefixes, the instance method View.byId() can be used with the static method sap.ui.core.Fragment.createID() if required, that is, if a fragment added a prefix.
Do not rely on the specific prefixing syntax because it may change. Always use methods like byId() and createId().