Closed c-kobo closed 9 months ago
Just found that the fpm writer for the Custom Page Controller sets the namespace similarly wrong: https://github.com/SAP/open-ux-tools/blob/45bf0515ec82c9a7d6749a49d5e1ea8d6ba0c527/packages/fe-fpm-writer/templates/page/custom/1.94/ext/Controller.ts#L4
@c-kobo
thanks for pointing to issue and solutions. I also checked controller of custom page and it looks little bit odd for me, current version generated for custom page's controller:
/**
* @namespace project1.ext.view.Aaaaaaaa.controller
*/
export default class Aaaaaaaa extends Controller {
js compiled version:
var Aaaaaaaa = Controller.extend("project1.ext.view.Aaaaaaaa.controller.Aaaaaaaa", {
while file is under webapp\ext\view\Aaaaaaaa.controller.ts
But as I tested it works ok with view.xml + also works following variant:
/**
* @namespace project1.ext.view.controller
*/
export default class Aaaaaaaa extends Controller {
compiled as:
var Aaaaaaaa = Controller.extend("project1.ext.view.controller.Aaaaaaaa", {
fix - https://github.com/SAP/open-ux-tools/pull/1661
I am applying approach with @namespace
for both controller extensions and also custom page's controllers:
/**
* @namespace project3.ext.controller
* @controller
*/
export default class Test extends ControllerExtension<ExtensionAPI> {
compiled as:
var Test = ControllerExtension.extend("project3.ext.controller.Test", {
/**
* @namespace project3.ext.view
*/
export default class Test extends Controller {
compiled as:
var Test = Controller.extend("project3.ext.view.Test", {
As tested with app - both works for me
Description
An issue had been reported about not found formatter functions in controller extensions for FE apps with a TypeScript project setup: https://answers.sap.com/questions/14015781/use-formatter-in-fiori-elements-custom-section-of.html
The reason seems to lie with the wrong generation of the namespace, as the package name is being appended to it: https://github.com/SAP/open-ux-tools/blob/45bf0515ec82c9a7d6749a49d5e1ea8d6ba0c527/packages/fe-fpm-writer/templates/controller-extension/Controller.ts#L5
The transpiled js representation of the TS controller file gets the package name added additionally, resulting in 'not found' issues with e.g. non resolved formatters paths in XML fragments:
Solution
The fpm writer should either define @namespace <%- ns %> or @name <%- ns %>.<%- name %>
Both options will work.
Misc
This issue is the cause for the problems reported at https://answers.sap.com/questions/14015781/use-formatter-in-fiori-elements-custom-section-of.html