Skip to content

ManagedObject.extend third optional parameter "FNMetaImpl?" #520

Open

Description

@stellariAbstract

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?

Thanks

Activity

  1. codeworrior commented on Aug 12, 2025

    @codeworrior
    Member

    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.

  2. stellariAbstract commented on Aug 12, 2025

    @stellariAbstract
    Author

    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

  3. codeworrior commented on Aug 12, 2025

    @codeworrior
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions