I have a view which I call in few other views with xmlns:mvc="sap.ui.core.mvc" and it's component XMLView like that:
<mvc:XMLView viewName="myViewPatch"
height="100%" id="myId" app:myProp="myProp" />
I want to access myProp in myViewPatch.controller but I think it's not possible that way because myProp is assigned to the mvc:XMLView not to the View itself. Is there any way to fake/create some kind of constructor? P.S. I am not able to use fragment and use different controllers.
Related
I am trying to make a business critical SAPUI5 application more accessible using screen readers by adding ARIA labels and landmarks. One issue is that some SAPUI5 elements such as sap.m.Title's without text have been used (abused) for layout purposes. I would like to add the aria-hidden attribute or a SAPUI5 analogue to these Title elements. But I can't figure out how to do this. I would like to change
<Title text="" class="title" />
into
<Title aria-hidden="true" text="" class="title" />
But setting aria-hidden on the Title like this seems to be invalid. How would I go about setting a standard HTML attribute on a SAPUI5 control?
Thank you in advance for your help!
Joshua
I wrote a SplitApp with a master and six detail views. Each detail view has it's own data model. The data is loaded in the onInit method of each controller.
I'm just trying to improve the performance of the application. Is there a way to load only the initial detail view and it's data on startup and the other only on request?
Thanks for the advise! The problem was that i defined all detail views in the XML-View inside the tag, like this:
<SplitApp mode="ShowHideMode" height="auto" >
<masterPages>
<mvc:XMLView viewName="de.test.view.Master" />
</masterPages>
<detailPages>
<mvc:XMLView viewName="de.test.view.Detail01" />
<mvc:XMLView viewName="de.test.view.Detail02" />
<mvc:XMLView viewName="de.test.view.Detail03" />
...
</detailPages>
</SplitApp>
Now i load each detail-view when it is requested for the first time and make use of the addDetailPage function of the SplitApp control.
Have you tried to add ``async="true"` property to your XMLView?
There are also some articles how you can improve performance of your app:
https://blogs.sap.com/2016/10/29/sapui5-application-startup-performance-best-practices/
https://blogs.sap.com/2016/11/19/sapui5-application-startup-performance-advanced-topics/
https://blogs.sap.com/2013/12/21/asynchronous-load-of-sapui5/
We are on SAPUI5 library version 1.36.1.
We have a responsive popover to display messages to the user.
When creating & loading the Popover to the view we are getting the below message.
Element sap.m.Text is not valid for aggregation "_headerTitle" of
Element sap.m.NotificationListItem
I couldn't find what's the reason as when I try it in WEB-IDE I could see it in layout editor working fine, checked if version is the issue none found.
Below is my fragment for reference:
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns:f="sap.ui.layout.form" xmlns:me="sap.me" xmlns="sap.m">
<Popover class="sapUiContentPadding" showHeader="false" placement="Auto">
<List items="{staffXMLErrors>/}">
<NotificationListItem title="{staffXMLErrors>Message}"
tooltip="{i18n>overview.words.click_a_message_to_navigate}"
showCloseButton="false"
priority="{path:'staffXMLErrors>Type',formatter:'._Formatters.formatNotificationPriority'}"
press="onStaffXMLErrorMessagePress" />
</List>
</Popover>
</core:FragmentDefinition>
As found out, the developer is loading all ui5 components explicitly in component.js like "sap.m.Text", "sap.m.label" ,"sap.m.NotificationListItem" etc., also there were several utilities included, as a trail I commented out all these and it worked fine.
so finally after removing all unwanted libraries, it worked fine.
At this point we could only avoid the issue but couldn't figure out what's exactly the reason is.
im newbie in zk´s world, so i have a doubt... i read already zk 8 documentation (almost all). At the office some partners are using ViewModel but inside some components are using Composer (selectorComposer) to bind some elements like this:
<div apply="org.zkoss.bind.BindComposer" viewModel="#id('vm') #init('com.some.package.SomeViewModel')">
<vbox>
... SOME ANOTHER ELEMENTS ....
<div apply="com.some.package.SomeComposer">
<hbox>
<vbox>
<checkbox ... more code...
</checkbox>
</vbox>
</hbox>
</div>
</vbox>
</div>
i read that if you apply SelectorComposer you lost coupling... so what is the reason of taking SelectComposer within a ViewModel? or how it works?
Thanks a lot for any help.
From my point of view SelectComposer allow you to reuse java code in a very traditional way. For example you can defined an AbstractController with functionality that will be reused in other controls of the same type with an slightly different functionality and extend the AbstractController. In this approach you can control the lifecycle of the componente by implemented the methods of SelectComposer like doAfterCompose.
But actually you can do the same thing with pure MVVM, but instead of implement methods of SelectComposer you should use the annotations like #AfterCompose or #Init and you can extend the base class as well, to use your view you just have to change the tag in the zul file with something like:
<include src="/artifacts/componente_to_reuse.zul"/>
I think is just a matter of preferences, I preferred (and I always recommend) to use pure MVVM since it was available, and I haven't found any functionality that I couldn't reuse with MVVM approach.
References:
Include,
Zk annotations
Can someone explain in brief or re-direct me to appropriate link to understand the difference between core:view and mvc:view in XML view of SAPUI5/Fiori application?
When we start an application in Eclipse and create XML view using sap.m library we see core:view, but in sample applications in SAPUI5 SDK - Demo Kit, we are seeing mvc:view. Please help us understanding when to use what.
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="splitapptest.Master" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Title">
<content>
</content>
</Page>
</core:View>
The View control is in sap.ui.core.mvc: see Class sap.ui.core.mvc.View in the API documentation. Therefore, the namespace for a View element in an XML view definition is sap.ui.core.mvc.
This usually translates to something like:
<mvc:View xmlns:mvc="sap.ui.core.mvc"…>
but of course the prefix is arbitrary and you could just as well have:
<banana:View xmlns:banana="sap.ui.core.mvc"…>
The point is that it's the namespace that's important, at least technically. The confusion probably arises because the XML processor is rather lenient on the namespace specified for the root View element.
So to answer your question specifically, while core:View might be "correct" if you crazily specified xmlns:core="sap.ui.core.mvc", it would be very confusing, so the best way to express it is
<mvc:View xmlns:mvc="sap.ui.core.mvc"…>
You can try with:
<a xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="splitapptest.Master" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Title">
<content>
</content>
</Page>
</a>
it will also work. The declaration does not matter. XMLTemplateProcessor will not parse this element.