Comments (4)
Hi,
defining a Dialog (or other popups) inside a View is indeed problematic because when the popup is opened, it is moved away from the View into a special area for popups. The connection to the View is then removed and the rendering (and data binding!) is independent then.
When one recommendation - using Fragments - cannot be used because Fragments do not have their own controller, you can since 1.20 use the "dependents" aggregation. In Views this is like a special area for defining popups that "belong to" the View and want to use the same controller - like this:
<View>
<Button...>
<dependents>
<Dialog...>
</dependents>
</View>
This will help avoid issues.
However, onAfterRendering of the controller is only called when the View itself is rendered, which does not happen, as Jiawei explained. When you are interested in the rendering of a control, you can add an event delegate to it.
https://sapui5.hana.ondemand.com/sdk/docs/api/symbols/sap.ui.core.Element.html#addEventDelegate
There should also be examples how this is used with afterRendering.
The validation things could also be caused by the above, so I'd close this ticket for now. If you still encounter issues after fixing the code, a runnable example would be very helpful. Even in jsbin you can declare XMLViews inline (e.g. http://jsbin.com/openui5-customdata-xmlview/1/edit), otherwise you can prepare a Gist. http://scn.sap.com/docs/DOC-50988
Regards
Andreas
from openui5.
Hi guys,
thanks for all the help!
The evil part was having Dialog as part off the view.
Also attaching a controller to the fragments does not really work because controller standalone wll not behave as expected (so controller is more a ViewController only).
For best flexibility my final solution Finally my solution follows Jiawei.
I am using a SelfregistrationDialog.fragment.xml
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc" >
<Dialog title="{i18n>UME_SELFREGISTRATION_TITLE}" icon="sap-icon://activity-individual"
contentWidth="96%" contentHeight="96%" stretchOnPhone="true">
<content>
<mvc:XMLView id="login-selfregistration" viewName="view.login.Selfregistration"></mvc:XMLView>
</content>
<beginButton>
<Button text="{i18n>REGISTER}" icon="sap-icon://accept" press="onDialogSubmitButton" />
</beginButton>
<endButton>
<Button text="{i18n>CANCEL}" icon="sap-icon://sys-cancel" press="onDialogCancelButton" />
</endButton>
</Dialog>
</core:FragmentDefinition>
that references the used view "view.login.Selfregistration".
Now i can user the DialogFragment inside rootView
this._getFragment("SelfregistrationDialog").open();
where fragments are resolved
_getFragment : function(sName, oController) {
var aViewName = this.getView().getViewName().split("."); // view.login.Login
aViewName.pop();
var sViewPath = aViewName.join(".") + "."; // view.login.
if (!this._fragments[sName]) {
if (oController && typeof oController === "string") {
oController = sap.ui.controller(sViewPath + oController);
} else {
oController = this;
}
this._fragments[sName] = sap.ui.xmlfragment(
sViewPath + sName,
oController
);
// version >= 1.20.x
this.getView().addDependent(this._fragments[sName]);
}
return this._fragments[sName];
}
Doing it this way, all my needs are fullfilled ;-)
- i can use the Selfregistration Dialog as a Standalone Page or as a Dialog out-of-the-box
- the logic is separated inside custom controller
- the global core models are attached to the view
- the view specific models are working as expected
- controller onInit and onAfterRendering are fired as expected
- ValidationErrors are fired on view input fields
Thanks for the needed background infos to get a deeper understanding of the core behavior especially for the internal dialog handling.
Also thanks to Andreas to forward me how to include xml view content in JSBIN. I will prepare my custom error template for future issues so that you quickly are able to find out if it is a bug or not without addtional overhead. (but i will also documentate such things on my blog to make it easier for others to do something similar).
Cheers Holger
from openui5.
Hi,
I can explain why the onAfterRendering function isn't called. The view is instantiated with sap.ui.xmlview and that's why its init method is called. However, this XMLView is never rendered. The Dialog is fetched from the view instance via id which is rendered when open method is called. But the view itself is only instanciated but never rendered because it doesn't have a parent and also not placed at some dom element by calling placeAt method. This is why the onAfterRendering isn't called.
If you want to attach a separate controller to the content of the dialog, please try to put the content of the dialog into a view and add this view to dialog. This view can have its own controller and dialog can be declared inside a fragment.
I have for now no idea why the input validation handler isn't called. It may be also solved by putting the content of dialog into a separate view and keeping the dialog in a fragment.
Best regards,
Jiawei
from openui5.
For future reference: an XMLView cannot have as direct children, as it interprets all child nodes as content of its default aggregation. See the API doc for this hint as well. So ther eneeds to be some content, to which the tag is added.
from openui5.
Related Issues (20)
- OData List binding error "Failed to enhance query" HOT 3
- JsDoc: QuickView.openBy incomplete parameter documentation / generated TypeScript type HOT 2
- JQuery Bug 878/1799 within JSONModel.loadData prevents from sending "??" HOT 7
- [SF][List]: Unnecessary tab focus going to noninteractive element (No data text) HOT 2
- How to mock module in qunit test HOT 9
- Proper TypeScript Type for TableSelectDialog$ConfirmEvent getParameter("selectedContexts") HOT 2
- Disregard this issue
- showShare property of SmartVariantManagementBase does not do anything HOT 1
- Minimal UI5 project throws multiple errors HOT 1
- sap.f.FlexibleColumnLayout changes height to 100% on resize event HOT 2
- [Documentation] Wrong Types for sap.m.upload.UploadSet.uploadCompleted parameters HOT 1
- sap.f.SidePanel - Unable to hide single side panel action item HOT 1
- `sap.ui.qunit.utils.nextUIUpdate` and `waitForThemeApplied` recommended as replacements, but not exposed HOT 2
- ObjectStatus: inverted text causes vertical misalignment HOT 1
- sap.m.MultiComboBox Search for secondary values does not work HOT 3
- sap.m.DynamicDateRange: format implementation generates error logs for missing operators. HOT 2
- showClearIcon on MultiComboBox does not work HOT 4
- PlanningCalendarRow cannot be given id HOT 2
- OverviewPage Fiori Element oData V4 problem HOT 2
- Busy property doesn't work for sap.m.ColumnListItem HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openui5.