<MessageStrip
text="Este formulario es provisional"
type="Warning"
showIcon="true"
showCloseButton="true"
class="sapUiMediumMarginBottom">
</MessageStrip>
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/ui/model/BindingMode", // <-- Add this library
"sap/ui/core/message/Message", // <-- Add this library
], function (Controller,JSONModel,BindingMode,Message) {
onInit: function () {
var oMessageManager, oModel, oView;
oView = this.getView();
// Register message handler
oMessageManager = sap.ui.getCore().getMessageManager();
oView.setModel(oMessageManager.getMessageModel(), "message");
oMessageManager.registerObject(oView, true);
// Create example model for input parameters
oModel = new JSONModel({
MandatoryInputValue: "",
DateValue: null,
IntegerValue: undefined,
Dummy: ""
});
oModel.setDefaultBindingMode(BindingMode.TwoWay);
oView.setModel(oModel);
_getMessagePopover : function () {
// create popover lazily (singleton)
if (!this._oMessagePopover) {
this._oMessagePopover = sap.ui.xmlfragment(this.getView().getId(),"<namespace_of_aplication>.fragments.MessageError", this);
this.getView().addDependent(this._oMessagePopover);
}
return this._oMessagePopover;
}
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<MessagePopover
items="{message>/}"
initiallyExpanded="true">
<MessageItem
type="{message>type}"
title="{message>message}"
subtitle="{message>additionalText}"
description="{message>description}"/>
</MessagePopover>
</core:FragmentDefinition>
<f:FormElement>
<f:label>
<Label text="Nombre" required="true"/>
</f:label>
<f:fields>
<Input id="Nombre" value="{ path: '/MandatoryInputValue', type: 'sap.ui.model.type.String', constraints: { minLength: 3 } }"/>
</f:fields>
</f:FormElement>
<f:FormElement>
<f:label>
<Label text="Fecha"/>
</f:label>
<f:fields>
<DatePicker id="date"
value="{ path:'/DateValue', type:'sap.ui.model.type.Date', formatOptions: { style: 'short', strictParsing: true }, constraints: { } }"/>
</f:fields>
</f:FormElement>
<f:FormElement>
<f:label>
<Label text="Valoración (0-10)"/>
</f:label>
<f:fields>
<Input id="int" value="{ path: '/IntegerValue', type:'sap.ui.model.type.Integer', constraints: { minimum: 0, maximum: 10 } }"/>
</f:fields>
</f:FormElement>
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/ui/model/BindingMode",
"sap/ui/core/message/Message",
'sap/m/MessageBox' // <--- ADD this library
], function (Controller,JSONModel,BindingMode,Message,MessageBox) {
lanzarMessageBox: function(oEvent) {
var bCompact = !!this.getView().$().closest(".sapUiSizeCompact").length;
MessageBox.confirm(
"Seguro que quieres cerrar esta ventana?", {
styleClass: bCompact ? "sapUiSizeCompact" : ""
}
);
},
<Button
text="Message Box"
class="sapUiSmallMarginBottom"
press="lanzarMessageBox"
width="250px"/>
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/ui/model/BindingMode",
"sap/ui/core/message/Message",
"sap/m/MessageBox",
"sap/m/MessageToast" // <-- Add this library
], function (Controller,JSONModel,BindingMode,Message,MessageBox,MessageToast) {
"use strict";
onInit: function () {
MessageToast.show("Hola, has iniciado el controlador 🙂 ");
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
8 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |