✒️SAP BTPFIORI / La utilización de los controles en la UI Por Jaime Gomez Arango

Selector Alummnos / Empresas

SAP BTPFIORI La utilización de los controles en la UI

SAP BTPFIORI La utilización de los controles en la UI

1 | SAPUI5 UI Controls

What are SAPUI5 Controls?

SAPUI5 controls are user interface elements used for interactive operations, either passively or actively. Each control defines how a specific area of the screen appears and behaves.

Overview of SAPUI5 Controls

In SAPUI5, controls are categorized into mobile-focused UI controls and desktop-centric UI controls. It's recommended to use mobile-focused controls as desktop controls in the sap.ui namespace are deprecated.

Key Components of Controls:

  • Control Name: Each control has a name consisting of a library name and control name, like sap.m.Table for creating a table.
  • Control Metadata: Defines properties, events, aggregations, and associations of a control. Properties modify appearance or data relations. Controls are defined by their metadata, which forms the control's public API.
  • Aggregations: Controls can contain other controls or elements. Aggregations serve as containers or layout controls where secondary controls can be added.
  • Associations: These connect controls using IDs rather than references. Associated controls are not part of or child elements of an aggregation.
  • Events: Higher-level semantic events tied to control functionality, distinct from browser-level events like click. For example, press event for a button.
  • Elements: Configurations within controls, not independently usable, without their renderer.

2 | Creating a SAPUI5 Table Control

In SAPUI5, tables are essential for displaying structured data effectively. They provide a clear and organized way to present information, making them a cornerstone in user interfaces. The recommended table control for responsive applications is sap.m.Table, as opposed to sap.ui.table.Table, which is not responsive.

Elements of SAPUI5 Table Controls

  • Columns Aggregation: Tables in SAPUI5 consist of columns defined within the columns aggregation. Each column determines the structure and appearance of the data displayed in the table. Columns can include various properties and configurations, such as width and visibility settings.
<Table id="myTable" items="{/Products}">
<columns>
<Column>
<Text text="Product Name"/>
</Column>
<Column>
<Text text="Price"/>
</Column>
<!-- Additional columns as needed -->
</columns>
</Table>

  • Data Binding: Data binding is fundamental for dynamically populating tables with data fetched from models. It allows seamless synchronization between the data source and the UI controls, ensuring that any changes in the data reflect immediately in the table.

// Setting model and binding
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData("path/to/products.json");
this.getView().setModel(oModel);

// Binding items to the table
var oTable = this.getView().byId("myTable");
oTable.bindItems({
path: "/Products",
template: new sap.m.ColumnListItem({
cells: [
new sap.m.Text({ text: "{ProductName}" }),
new sap.m.Text({ text: "{Price}" })
// Additional cells for other properties
]
})
});

  • Responsive Design: SAPUI5 provides responsive features out-of-the-box, ensuring that tables adapt fluidly to different screen sizes and orientations. This is achieved by setting properties like responsive and fullScreenOptimized to true in controls such as ObjectHeader.

Example: Creating a JSON Model

In SAPUI5 applications, models serve as data sources for binding to UI controls. JSON models are commonly used for smaller data sets due to their simplicity and ease of integration.

  • Model Loading: JSON models are typically loaded during the initialization phase (init() method) of the controller. This ensures that data is available when the view is rendered.
  • Manifest.json Configuration: To streamline model loading, configuration in manifest.json defines the model's data source (dataSource) and type. This setup automates model loading, minimizing explicit implementation.
{
"sap.app": {
"dataSources": {
"products": {
"uri": "path/to/products.json",
"type": "JSON"
}
}
},
"sap.ui5": {
"models": {
"products_json": {
"dataSource": "products",
"type": "sap.ui.model.json.JSONModel"
}
}
}
}


3 | Using Models in SAPUI5

Models in SAPUI5 facilitate seamless data binding between backend data sources and UI controls. They ensure that changes in data are reflected instantly in the application's interface, providing a robust foundation for interactive applications.

Data Binding Essentials

  • Model Attachment: Models can be attached at different levels within the application hierarchy:
    • Application Level: sap.ui.getCore().setModel(model);
    • View Level: this.getView().setModel(model);
    • Control Level: sap.ui.getCore().byId("__xmlview0--Table1").setModel(model);

The closest model to a control takes precedence, ensuring targeted data binding.

  • Event Handling: SAPUI5 models support events such as attachRequestCompleted, enabling applications to react to model loading events asynchronously. This ensures UI responsiveness and data integrity.
  • Usage of Models: Models are retrieved in views using this.getOwnerComponent().getModel("products_json"), leveraging predefined models for seamless data integration.

Example: Binding Models in Views

In the view, binding models involves specifying the model name and property paths to synchronize UI controls with data.

<Table id="__xmlview0--Table1" items="{products_json>/Products}">
<columns>
<Column>
<Text text="Product Name"/>
</Column>
<Column>
<Text text="Price"/>
</Column>
<!-- Additional columns as needed -->
</columns>
</Table>

4 | Creating Controls

Creating the Input Control

Examples of the Input Control: We can find an example of this control at the following URL:

sapui5.hana.ondemand.com/sdk/#/entity/sap.m.Input

The API details can be viewed at: sapui5.hana.ondemand.com/sdk/#/api/sap.m.Input

To use the Input control in our view, we must include the "sap.m" reference.

The properties of this control are documented in the SAP API. Let's focus on those used in this example:

  • id attribute: Specifies a unique identifier for an HTML element, used for CSS styling and JavaScript DOM manipulation.
  • value attribute: Specifies the value of an element.
  • maxLength attribute: Sets the maximum length allowed for input.
  • class attribute: Assigns a CSS class for styling purposes.
  • placeholder attribute: Provides a hint to the user about what to enter.
  • showSuggestion attribute: Enables dynamic suggestions based on user input.
  • suggestionItems attribute: Specifies which field of the model provides suggestions.

Creating the Select Control

The SAPUI5 Select control displays a menu of options.

You can explore the control in the SAP API reference:

sapui5.hana.ondemand.com/sdk/#/entity/sap.m.Select

Let's analyze the properties used in our example:

  • selectedKey attribute: Stores the value of the selected item.
  • items attribute: Defines the values displayed in the dropdown menu.
  • forceSelection attribute: Specifies if selection is restricted to list items.
  • visible attribute: Controls the visibility of the control.

Creating the Label Control

The Label control serves as a tag for a UI element. It can be associated with another control using the 'for' attribute or by nesting it.

Explore the Label control in the SAP API:

sapui5.hana.ondemand.com/sdk/#/entity/sap.m.Label

To associate a label, use the 'labelFor' property.

Creating the Button Control

The Button control is used to create buttons in the user interface.

Explore the Button control in the SAP API:

sapui5.hana.ondemand.com/sdk/#/entity/sap.m.Button

Buttons can be associated with events in the view's controller. For example, handling user clicks to filter or reset data.

5 | Events

Events are the execution of functions in response to an action and are sent to notify the code of interesting things that have happened. The function is commonly referred to as a "listener" or a "handler," with both terms used interchangeably.

Custom Event Handling

This pattern can be easily followed using completely customized code. In this case, we will add an event when the user clicks the button to search for records that meet the filter criteria, and another event when we clear the filter.

Implementing Event Logic

Using the Button control, let's explore the event logic for filtering when the user enters a product name or a currency. First, we retrieve the model data using this.getView().getModel().getData(). Then, we check if the CurrencyCode field is filled. If so, we create a filter using the "EQ" operator for equality and compare it with the entered value in the UI. For the description field, we use the "Contains" operator to match the string entered, removing white spaces with the JS trim() method.

Using Filters

To apply filters, we need to include two libraries in our project within sap.ui.define:

sap.ui.define([
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator"
],

Case Sensitivity in OData Filters

Filters in OData services are case-sensitive. If a case-insensitive search is preferred, it can be implemented in the controller logic.

Debugging Model Data

In the debug console, we can observe how getModel(ModelName).getData() returns the model data.

Binding and Filtering

To obtain and filter list data, we use this.getView().byId("idProductoTable") to get the table control by its XML view ID. The binding information for the table rows is obtained using getBinding("items").

Applying Filters

Filters are applied to the table using oBinding.filter(filters). For example, filtering by a product and its currency yields specific results.

Clearing Filters

To clear filters, we also have a press event on the button to perform that action. The button logic involves using setProperty to set model-bound fields to blank, effectively clearing the view.

6 | Context and Messages

Context Context is a pointer to an object in the model data. Each function invocation has a scope and an associated context. Scope primarily deals with function-based access to variables, unique to each invocation. Context always refers to the value of the this keyword, which points to the object that "owns" the currently executing code.

The method getBindingContext() provides us with the binding context applied to an element's control. When we bind elements (context binding) to a control, using getBindingContext() returns the specific context details applied to that control.

In our ongoing example using the table control, the data table we're passing results in multiple rows. Internally, SAPUI5 APIs perform context binding for each generated row. Therefore, when we use the event handler method on item click, we can call item.getBindingContext(), which gives us the binding context for that object within the given model name. Additionally, item.getBindingContext().getObject() allows access to the data.

For an example, let's code the click event of a table item. Upon clicking, we'll display a message with object data, as shown in the following:

To display a message with the supplier's name, we use the sap.m.MessageToast library with the show method. MessageToast is a small, non-disruptive pop-up window for success messages that automatically disappears after a few seconds.


 

Escanear / Compartir

 

 


Sobre el autor

Publicación académica de Jaime Eduardo Gomez Arango, en su ámbito de estudios para la Carrera Consultor SAP BTP Fiori.

SAP Expert


Jaime Eduardo Gomez Arango

Profesión: Ingeniero de Sistemas y Computación - España - Legajo: SW34C

✒️Autor de: 149 Publicaciones Académicas

🎓Egresado de los módulos:

Disponibilidad Laboral: FullTime

Presentación:

Ingeniero de sistemas y computación con 8 años de experiencia el desarrollo frontend & backend (react/node) y en cloud (aws), actualmente desarrollando habilidades en sap btp, ui5, abap y fiori.

Certificación Académica de Jaime Gomez

✒️+Comunidad Académica CVOSOFT

Continúe aprendiendo sobre el tema "La utilización de los controles en la UI" de la mano de nuestros alumnos.

SAP SemiSenior

La utilización de los controles en la UI 1. Introducción En SAPUI5, la utilización de los controles en la interfaz de usuario representa uno de los pilares fundamentales del diseño y la construcción de aplicaciones SAP Fiori. Cada control cumple una función específica dentro de la UI y debe ser implementado siguiendo las guías de diseño Fiori para garantizar uniformidad, usabilidad y coherencia visual. El desarrollador o consultor Fiori debe conocer los diferentes tipos de controles disponibles y aplicar buenas prácticas para mantener una interfaz limpia, intuitiva y adaptable a distintos dispositivos. 2. Clasificación de los controles según su función...

Acceder a esta publicación

Creado y Compartido por: Jose Rodrigo Baz Suarez / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master

La utilizacion de los controles UI Tipos de controles de interfaz de usuario Simple Controls Value Holders Layouts Complex Controls UX3 Controls Controles para escritorio sap.ui-namespace El nombre de control: sap.m.Table El control de metadatos: Es un objeto interno que define las propiedades, agregaciones, asociaciones y eventos del control. Esto permite al framework (y a ti como desarrolladora) saber cómo usar el control, qué atributos tiene, cómo se renderiza y cómo interactúa con otros controles. Los elementos: sap.ui.core.Element es la clase base de sap.ui.core.Control Los metodos: en los controles SAPUI5 son funciones que te permiten interactuar, modificar o recuperar...

Acceder a esta publicación

Creado y Compartido por: Claudia Bibiana Monsalve Lopez

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

1. LOS CONTROLES DE UI Tipos de controles SAPUI5 Simple Controls Value Holders Layouts Complex Controls Dialos UX3 Controls > Se recomienda usar controles de interfaz de usuario movil en lugar de los de escritorio Los controles consisten en: nombre del control: nombre_de_biblioteca.nombre_control metadatos de control: Los controles estan definidos por los metadatos de control, que es la API publica del control. propiedades eventos agregaciones asociaciones Los elementos: partes o paquetes de configuracoin para parte de controles. los metodos CLASE BASE DE TODOS LOS CONTROLES es sap.ui.core.Control Dos de las librerias mas usadas en SAPUI5 a....

Acceder a esta publicación

Creado y Compartido por: Roberto Hernan Santucho

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


Las aplicaciones desarrolladas con SAP GUI 5 presentan una experiencia de usuario consistente y responden a navegadores de cualquier dispositivo móvil los controles de interfaz de usuario se adaptan automáticamente a las capacidades de cada dispositivo. SAP GUI 5 usa el databinding para unir dos fuentes de datos o fuentes de información para mantener la sincronía, todos los cambios de una fuente también se reflejan en la otra, para el enlace de datos necesitamos un modelo y una instancia de enlace. La instancia del modelo contiene los datos y proporciona métodos para establecer los datos o para recuperarlos de un servidor.

Acceder a esta publicación

Creado y Compartido por: Jose Medina / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


1 | SAPUI5 UI Controls What are SAPUI5 Controls? SAPUI5 controls are user interface elements used for interactive operations, either passively or actively. Each control defines how a specific area of the screen appears and behaves. Overview of SAPUI5 Controls In SAPUI5, controls are categorized into mobile-focused UI controls and desktop-centric UI controls. It's recommended to use mobile-focused controls as desktop controls in the sap.ui namespace are deprecated. Key Components of Controls: Control Name: Each control has a name consisting of a library name and control name, like sap.m.Table for creating a table. Control Metadata: Defines properties, events, aggregations, and associations of a control. Properties modify appearance or...

Acceder a esta publicación

Creado y Compartido por: Jaime Eduardo Gomez Arango / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

DATA BINDING En SAPUI5, el concepto de data binding (vinculación de datos) es fundamental para conectar y sincronizar los datos entre el modelo de datos y la interfaz de usuario. La vinculación de datos permite actualizar automáticamente la interfaz de usuario cuando los datos subyacentes cambian, y viceversa. Esto facilita la creación de aplicaciones web dinámicas y reactivas. A continuación, se describen los aspectos clave de la vinculación de datos en SAPUI5: Modelo de Datos: SAPUI5 sigue el patrón de diseño MVC (Modelo-Vista-Controlador), donde el modelo de datos representa la capa de datos de la aplicación. Puedes utilizar...

Acceder a esta publicación

Creado y Compartido por: Claudio Marcelo Hermann / Disponibilidad Laboral: FullTime

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

Los controles de UI El texto habla sobre los controles de UI en SAPUI5, que son elementos de interfaz de usuario utilizados para definir la apariencia y el comportamiento de las áreas en la pantalla. Los controles tienen propiedades como texto o ancho que modifican la apariencia o se relacionan con los datos mostrados. SAPUI5 proporciona diferentes tipos de controles de interfaz de usuario, y se recomienda utilizar los controles móviles en lugar de los centrados en el escritorio. Los controles constan de un nombre y metadatos que definen sus propiedades, eventos, agregaciones y asociaciones. Los controles pueden tener agregaciones, que son controles secundarios que se agregan al control principal, y asociaciones, que están...

Acceder a esta publicación

Creado y Compartido por: Nilson Parra Martinez / Disponibilidad Laboral: PartTime

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP SemiSenior

Resumen Unidad 3 capitulo 5 1. Ejemplo de generacion de una fuente de datos Databinding: asociar dos instancias de información, un modelo y una vista de modo tal que queden sincronizados Ejemplo: a. Crear un archivo products.json y agregarlo a la carpeta mockdata del proyecto b. Modificar manifest.json. 2.1 En la sección "dataSources", agregar "productos": { "uri": "./mockdata/products.json", "type" : "JSON" } 2.1 En la sección "models", agregar "products_json": { "type": "sap.ui.model.json.JSONModel", "dataSource": "productos" } c. En return Controller.extend("ns.controles.controller.View1",...

Acceder a esta publicación

Creado y Compartido por: Cristian Cash

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

Apunte Creado OK - Iniciar Edición Los controles UI: son los elementos de interfaz de usuario con los que se va llevar a cabo la interacción Los controles consisten de: Nombre del control El control de metadatos Los elementos Los métodos Los controles son clases definidas por SAP que representan definición de los elementos que se mostraran en las vistas Data Binding: enlaza la agregación item con un modelo Modelo con Json : es un modelo del lado del cliente que se recomienda para conjunto de datos pequeños

Acceder a esta publicación

Creado y Compartido por: Detriana Barrios / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master


Los controles de UI Los controles se utilizan para definir la apariencia y el comportamiento de las áreas en la pantalla. Normalmente los controles tienen propiedades como texto o ancho que modifican la apariencia o se relacionan con los datos mostrados por el control. SAPUI5 proporciona diferentes tipos de controles de interfaz de usuario. Hay más controles de interfaz de usuario centrados en el escritorio en el framework SAPUI5. Lo recomendable es utilizar los controles de la interfaz de usuario móvil. Los controles centrados en el escritorio de sap.ui-namespace están en desuso. Los controles consisten en: El nombre de control: es una cadena que consta del nombre de la biblioteca y el nombre del control, separados...

Acceder a esta publicación

Creado y Compartido por: Gerber Geovanni Lopez Hernandez / Disponibilidad Laboral: FullTime

 


 

👌Genial!, estos fueron los últimos artículos sobre más de 99.000 publicaciones académicas abiertas, libres y gratuitas compartidas con la comunidad, para acceder a ellas le dejamos el enlace a CVOPEN ACADEMY.

🔎Buscador de Publicaciones:

 


 

No sea Juan... Solo podrá llegar alto si realiza su formación con los mejores!