Closed denislutz closed 1 month ago
The warning "Do not use deprecated sap.ui.core.mvc.JSView:" and the error "failed to load 'explorer.explorerfcl.view.App.js' from..." indicate what's going wrong.
When creating your typed view, you should refer to it with the "module:" prefix, followed by the module ID - which is a slash separated name, not dot separated. I guess loading your view fails due to this and the runtime falls back to a JSView
(btw: you can and should remove the type: ViewType.JS
setting. The use of the "module:" prefix already implies a typed view).
Please try that and fix the view names.
BTW: If my above assumption is correct, I would have expected a different (more helpful) error message. Something that indicates that the view could not be found. The silent fallback to JSView surprises me.
Hello Frank,
thanks a lot for your reply. Now I tried for several hours to apply your input, I created a fresh and very clean TS sample but it is still not working. My general feeling as a SAPUI new comer, that there are too many places where I can do something wrong in configuration. Also I feel like the framework expects it all to be compiled in .js version but my TS code is missing something to deliver it.
My last error is this:
2024-07-19 12:06:07.815000 [FUTURE FATAL] Failed to load component for container __container0 - ModuleError: failed to load 'com/dl/explorer/view/App.js' from ./view/App.js: 404 - Not Found ModuleError: failed to load 'com/dl/explorer/view/App.js' from ./view/App.js: 404 - Not Found makeModuleError http://localhost:8080/resources/ui5loader.js:1190 failWith http://localhost:8080/resources/ui5loader.js:958 requireModule http://localhost:8080/resources/ui5loader.js:1692 requireSync http://localhost:8080/resources/ui5loader.js:2228 createView http://localhost:8080/resources/sap/ui/core/mvc/View.js:1327 createView http://localhost:8080/resources/sap/ui/core/mvc/View.js:1332 viewFactory http://localhost:8080/resources/sap/ui/core/mvc/View.js:1266 createContent http://localhost:8080/resources/sap/ui/core/UIComponent.js:773 init http://localhost:8080/resources/sap/ui/core/UIComponent.js:394 runWithPreprocessors http://localhost:8080/resources/sap/ui/base/ManagedObject.js?eval:1189 init http://localhost:8080/resources/sap/ui/core/UIComponent.js:393 runWithOwner http://localhost:8080/resources/sap/ui/base/ManagedObject.js?eval:1216 Caused by: XHRLoadError: 404 - Not Found createXHRLoadError ui5loader.js:1403 loadSyncXHR ui5loader.js:1416 callHandler syncXHRFix.js:149 fnWrappedHandler syncXHRFix.js:161 get syncXHRFix.js:222 loadSyncXHR ui5loader.js:1426
Here my full project that you can just replicate what I have.
If you do take a look at the Component.ts as the first step, there I deactivated the creation of the views.
com.dl.explorer.zip
I would be very nice if you could provide a very basic sample of working typed views with TS, there is not a single show case on the whole net that demonstrates it.
Just one minor thing is wrong: your view is named view/App.view.js . The module ID therefore is "<your app namespace>/view/App.view". The ".view" part is missing in your manifest.json, both, for the root view and for the views in the routing section.
After fixing that, I see the product list.
Clicking on an item in the product list revels another issue: the event handler is not bound to the controller. Typed views are just JavaScript, so if you assign a function reference as event handler to a Button's press event, the button cannot know where this reference came from (the controller instance). in XMLViews, the framework knows the relationship and can bind the function accordingly. In a typed view, you have to compensate this:
press: (this.getController() as Master).onListItemPress.bind(this.getController()),
After that, the app work as intended, as far as I can judge this.
Hi Frank,
wow it works now, thanks so much for your support. What a nice start in the week end.
Here is the adapted version, for everyone who comes for this issue to this thread: com.dl.explorer.zip
Grüsse aus Mannheim!
Answer complete
Hi dear SAPUI experts and thanks a lot for your work.
I am attempting to use typed views with TypeScript
Coming from react.js I want to leverage the full power of TypeScript without encountering any language breaks with XML by having a pure TS MVC cycle.
Despite following various guides and documentation, I continuously face issues when trying to implement typed views in my SAP UI5 project. Below are the core parts of my code, including the manifest.json, three view classes (App, Master, and Detail), and the Component initialization file.
Here is my current setup: Manifest.json:
The errors I am getting are always the same:
Warnings
Errors
Do you see what I am doing, wrong? Thanks a lot in advance.