Closed dabretin closed 1 year ago
Hi dabretin, can you please describe in more detail what you are missing? I understood that you would like a single view which you fill with different data, according to the current route. Is that correct? Best Regards, Martin OpenUI5 Team
First of all, thx for your interest ;)
Now, a simple sample where viewData
could be very interesting:
We could make a single View
Detail
wich do all the layout and which use simple Label
or Input
(for example) depending of the viewData
.
I think it should be a additional parameter of the Target
class.
As it's actually complicated to extend a custom view, this possibility would be great.
metadata :
{
....
routing :
{
config
{
...
},
routes :
[
...
{
pattern : "detail/{id}",
name : "detail",
target : [ "detail" ]
},
{
pattern : "detailEdit/{id}",
name : "edit",
target : [ "detailEdit" ]
},
...
],
targets :
{
...
detail :
{
viewName : "Detail",
viewData : true /* ReadOnly */
},
detailEdit :
{
viewName : "Detail",
viewData : false /* !ReadOnly */
},
...
}
}
}
Hi dabretin,
i think allowing the viewData is ok, it just would not work for the usecase you described. Since the viewName is the same, Targets will create the same view Instance. Therefore the target displayed first will decide wich viewData is taken into account.
We already have a similar requirement allowing preprocessors to run with the routing. So it might be we implement a hook for applications to register a view factory in the routing. Then you have the full control about creating the views. But this is probably started in the 1.32 release of UI5.
BR, Tobias
Arg...I didn't think about the view cache made by Targets... So you're right, my request is useless !
But I will definitly be a fan of the custom view factory possibility ! :+1:
Thx for your great work and your fast as light support ! PS: and sorry to had not thinked about the view creation (by Targets class)...
@TobiasOetzel , I'm just seeing your comment now about preprocessors, as a colleague of mine stumbled upon an issue using template tags (http://stackoverflow.com/questions/32289904/using-template-schema-in-xml-view). Has anything changed, or is any support for a custom view factory en route for 1.32?
Hi,
sorry there was another feature - async view loading what has been done first. I hope the view factory will come in one of the next releases. The only workaround is to create the views eagerly and set the instances of the view to the sap.ui.core.routing.Views instance of the router. But that somehow defeats the lazy loading purpose.
Best regards, Tobias
Hallo,
so there is currently no good way to use XML Templating in an app that creates the views via routing? If this would be implemented soon I would greatly appreciate it since I need to manually access some OData V4 Annotations.
So, +1 for the view factory!
Kind regards Pascal
Hi @dabretin , first of all: Sorry for the very late reply to your issue. Despite the issue is so old, the content is still relevant.
In the meantime we have enabled XML templating for views created by the asynchronous routing. See section "Global availability" on topic 48b81b967af34ad08f1f88c962b4740a.
Furthermore I want to make a proposal for an enhanced routing configuration.
Changing the target section is not sufficient because targets might be reused. Also targets are not longer restricted to sap.ui.core.mvc.View
artefacts. Also sap.ui.core.UIComponents
can be used. Therefore, I vote for enhancing the routes
section:
"sap.ui5": {
"routing": {
"routes": [
{
"pattern": "detail/{id}",
"name": "detail",
"target": "detail",
"data": { "edit": false }
},
{
"pattern": "detailEdit/{id}",
"name": "edit",
"target": "detail",
"data": { "edit": true }
}
],
"targets": {
"detail" :
{
"name": "Detail"
"id": "detail"
}
}
}
}
Whats your opinion on that?
Closing this issue. Scenario can be achieved as described above.
Hello ! It would be great if we could add viewData information in routing (statically declared or with new sap.ui.core.routing.Route)... It would enable to create generic view which uses viewData to specialize (RO/RW view for example).