New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sap-language parameter is not added to sap.ui.model.odata.v2.ODataModel if model is extended #3126
Comments
Hi @iljapostnovs, Thank you for sharing this finding. I've created an internal incident 2180022569. The status of the issue will be updated here in GitHub. All the best, |
Hi @iljapostnovs, |
Or actually it's not so easy, because metadata might be requested without language parameter anyway. In this case the model class can be requested using sap.ui.requireSync right before setting the parameters, and then you can use isA. It looks like drawback because require should be async, but taking in mind requireSync is used anyway in _createManifestModels, it will impact nothing. |
Hi @iljapostnovs, yes the method is private. But as of now, this would be the only option for you to achieve your scenario. |
Thanks a lot for your inputs. We'll discuss your points and report the outcome here 👍🏽 |
Thanks, but I figured out another temporary way out:
Waiting forward getting rid of this :) |
Hi @iljapostnovs, |
Hi, |
Hi @iljapostnovs.
This is unfortunately not true. The point in time where the models now are required and loaded is guaranteed to have preloads the code already. For the earlier point in time where the model settings are prepared (incl. the injection of the sap-language code), this is not guaranteed and therefore sync XHRs could be created for individual files. The path on which models that are flagged with "preload:true" are loaded, explicitly checks whether the code is preloaded already and if not, postpones model creation.
This is correct (and the reason why we introduced We could optimise the check for some scenarios (mainly for apps that use a self-contained bundle): If the model implementation has already been preloaded, then we could require it and do the
That's the most appealing alternative from my POV. I think the reason why it originally wasn't done like that was that the models don't have access to some of the parameters (esp. cache tokens). The global settings like language and client however would be available to them. |
Hi @codeworrior, |
I don't fully get the goal we are after here. The V4 OData model is already using "Accept-Language" header automatically. My understanding is that the sap-language URL parameter is most valuable when it comes to caching, and as @codeworrior said, "the models don't have access to some of the parameters (esp. cache tokens)". So what is the benefit of having sap-language URL w/o the others? |
Hi,
|
OK, I think I understand your scenario. As I said, this should not be an issue with v4.ODataModel because "Accept-Language" header is automatically set for both data and metadata. Just to clarify the scope of this issue... |
I didn't test this scenario for V4 ODataModel, so I hope that you are right :) |
Looking at the code, I'd say that V2 is also using "Accept-Language" headers for both data and metadata. Can you please confirm this? Why doesn't this have the same effect as sap-language? |
Hello @iljapostnovs ! Thanks for this detailed analysis. When I speak of ODataModel, I refer to UI5's implementation. Your screenshot illustrates the presence of "Accept-Language" request headers. But I also understand that the server's response treats "sap-language" differently than "Accept-Language". That is not a question to UI5 in the 1st place. Which server implementation/framework are you using? Best regards, |
I am using NetWeaver OData Service. I don't know which component exactly is responsible for OData implementation, but my guess would be that it is SAP_GWFND, release 750, SP-level 0008. |
Hello @iljapostnovs ! Thanks for your input. I will discuss this internally (beginning of next week) and let you know here. Stay tuned! Best regards, |
Hello @iljapostnovs ! I've got at least a preliminary answer: "Fix the server". I suggest you try and open a support ticket on SAP_GWFND asking why the "Accept-Language" request header does not have the desired effect. Then we will see if UI5 needs to change anything at all. Best regards, |
Hi, I googled a bit about accept-language and seems that it works correctly.
In my case the default system language is EN, but users can login with different language. |
Is that a generic user you are using? Would it be an option to set the desired language also in SU01? But I get the point that Fiori Launchpad settings should win... |
At least that's the case for my user in NW system I have.
Technically yes, but I don't think that somebody will be happy to edit thousands of user languages. And again, that also basically means that metadata language will be strictly set to one language, which should not be the case.
Precisely |
Hello @iljapostnovs ! Could you please do us a favor and try your scenario with a different language, maybe "en" or "de" or "fr" or "es" or "it"? That might make a difference and would be interesting to know. Best regards, |
Hi, What exactly you want me to try out? |
Hello @iljapostnovs ! Good point, I should have made this clearer. My understanding is that you start your UI5 app in a way which tells UI5 that Lithuanian is your language of choice. From the above, it sounds like Fiori Launchpad is where you maintain that setting. We have already seen that the Accept-Language request header is properly influenced by that setting, but it seemed to be ignored by the backend. My suggestion is now to use maybe "en" or "de" or "fr" or "es" or "it" as you language of choice in Fiori Launchpad. That should influence the Accept-Language request header and maybe make a difference for the server. Best regards, |
Hi, I have tried to do the same with ET, result is the same. |
Hello @iljapostnovs ! I just learned that our concerns regarding a difference between "lt" and "en" was kind of a false alarm. Sorry for that! Our current thinking is that Accept-Language is being ignored because you have already established a session with your backend (browser cookies) and that session's language wins. In that scenario, we would expect sap-language to NOT make any difference. Your screenshots show "standalone" requests in a browser where not session has been established, I guess. If you use a request with sap-language in a browser tab where your app is already running and fetching the wrong metadata - would that really make a difference? Please apologize our confusion, but there is some uncertainty as to the order of factors which influence a language, so to say. Best regards, |
Hi, Sorry for the delay on my answer, I was occupied by other tasks. However, If I will not be able to reproduce the issue, I'm still thinking that it's incorrect behavior that adding sap-language parameter affects everything except custom ODataModel even if I'm working with local development environment. |
I've created an internal incident 2170257172. The status of the issue will be updated here in GitHub. |
Triggered by this issue, we discussed again whether we can officially support custom subclasses of the existing models and finally decided against it. The API documentation now (db7069f) states for
You might notice that "...is not prepared..." is a rather soft statement. Technically, we do not prevent subclassing (model classes are not declared to be Especially in cloud scenarios with automatic version upgrades, there's no point in time where such incompatibilities could be detected and resolved before they break productive usages. That's why we thought it would be fair to document this as a restriction / warning. Well, at the same time, we re-implemented the model handling in the Component.js (2183384). It is now no longer based on class name equality, but uses the |
That's actually one of my proposals of solving the problem and exactly what was needed, thanks! |
OpenUI5 version: 1.85.0
Language url parameter is not added to the ODataModel if model is extended.
Steps to reproduce the problem:
What is the expected result?
sap-language url parameter should be added
What happens instead?
sap-language url parameter is not added
Any other information? (attach screenshot if possible)
Reason for it is in sap.ui.core.Component line: 1545
sap-language should be added if the model is instance of ODataModel, however right now class check is strictly set to sap.ui.model.odata.v2.ODataModel and sap.ui.model.odata.v4.ODataModel models.
The text was updated successfully, but these errors were encountered: