You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ManagedObject.extend third optional parameter "FNMetaImpl?" #520
In the ManagedObject "extend" function documentation you can see that it is possible to use the third parameter for specifying a Constructor function for the metadata object.
Since in TS you don't call directly the "extend" function but rather the builder/transpiler does it, how can one pass a custom metadata costructor to the definition of a custom class?
Since metadata information (that are part of the second parameter "oClassInfo?" in the "extend" call) are automagically passed by defining a "public static metadata" (or "static readonly metadata", not very clear) attribute in the class (and doesn't always work...) , I suspect that there mey be something along the same line, like defining a static "metadataImplementation" or similar?
Is there an alternative way to define and use a custom metadata constructor for my custom class?
So far, we see the possibility to introduce new metadata classes mainly as a feature for framework internal use. That's why TypeScript support does not expose this as a feature, currently. To my knowledge, the babel-plugin-transform-modules-ui5 also has no support for it, yet.
I used it in this project in the "javascript way" and since I'm porting it to TS, I would have liked to use it there also.
What I need to do is to be able to specify custom "properties" in the metadata options and create custom mutators for those.
I'm extending the "Model" class to support a custom Client/Server ajax-based communication used in this project since the beginning and since each service I'm calling is really a BSP page that accepts a json and replies with json data, I'd like to define those "pages" as "methods" in a way similar to what the framework does with "properties" (aka creating getter and mutator).
In javascipt, by creating a custom metadata object, i managed to pass somithing like this: metadata: { ajaxMethods: { getUserInfo: { pageName: "getuserinfo.m", method: "POST" }, echo: { pageName: "echoServlet.m", method: "POST", resultType: AjaxModel.ResultTypes.ReturnData } } }....
and get automatic creation of the "getUserInfo" and "echo" functions (that executes the ajax call to the server) .
Thank you for detailing your scenario. I didn't doubt that there are valid use cases for using the FNMetaImpl param. It's just not a common target use case for us.
Anyhow, if this does not sound too cumbersome, the easiest workaround might be to introduce an (artifical) base class (e.g. MyModelBase). If you implement that class the JavaScript way (using Model.extend) and specify the FNMetaImpl as you need it, then any TypeScript class inheriting from MyModelBase should inherit the FNMetaImpl from MyModelBase.
Activity
codeworrior commentedon Aug 12, 2025
So far, we see the possibility to introduce new metadata classes mainly as a feature for framework internal use. That's why TypeScript support does not expose this as a feature, currently. To my knowledge, the babel-plugin-transform-modules-ui5 also has no support for it, yet.
stellariAbstract commentedon Aug 12, 2025
I used it in this project in the "javascript way" and since I'm porting it to TS, I would have liked to use it there also.
What I need to do is to be able to specify custom "properties" in the metadata options and create custom mutators for those.
I'm extending the "Model" class to support a custom Client/Server ajax-based communication used in this project since the beginning and since each service I'm calling is really a BSP page that accepts a json and replies with json data, I'd like to define those "pages" as "methods" in a way similar to what the framework does with "properties" (aka creating getter and mutator).
In javascipt, by creating a custom metadata object, i managed to pass somithing like this:
metadata: { ajaxMethods: { getUserInfo: { pageName: "getuserinfo.m", method: "POST" }, echo: { pageName: "echoServlet.m", method: "POST", resultType: AjaxModel.ResultTypes.ReturnData } } }....and get automatic creation of the "getUserInfo" and "echo" functions (that executes the ajax call to the server) .
Is there a way around to this?
Thanks
codeworrior commentedon Aug 12, 2025
Thank you for detailing your scenario. I didn't doubt that there are valid use cases for using the
FNMetaImplparam. It's just not a common target use case for us.Anyhow, if this does not sound too cumbersome, the easiest workaround might be to introduce an (artifical) base class (e.g.
MyModelBase). If you implement that class the JavaScript way (usingModel.extend) and specify theFNMetaImplas you need it, then any TypeScript class inheriting fromMyModelBaseshould inherit theFNMetaImplfromMyModelBase.