How to add Unit Annotations in SAP UI5 Table

The unit of measure for a quantity can be displayed using the Unit Annotations. The Unit annotations in the metadata are represented as below.

                        <EntityType Name="CustomerType"
                            sap:label="Customers"
                            sap:content-version="1">
                            <Key>
                                <PropertyRef Name="Id" />
                            </Key>

                            <Property Name="Id"
                                Type="Edm.String"
                                Nullable="false"
                                MaxLength="10"
                                sap:visible="true"
                                sap:label="Customer ID"
                                sap:creatable="false"
                                sap:text="Name" />
                            <Property Name="FC"
                                Type="Edm.Byte"
                                sap:label="Field control" />
                            <Property Name="Name"
                                Type="Edm.String"
                                MaxLength="70"
                                sap:field-control="FC"
                                sap:creatable="false"
                                sap:updatable="true"
                                sap:label="Customer Name" />
                            <Property Name="Weight"
                                    Type="Edm.Double"
                                    sap:label="Weight"
                                    sap:unit="Unit" />
                            <Property Name="Unit"
                                  Type="Edm.String"
                                  MaxLength="512"
                                  sap:semantics="unit-of-measure" />
                        </EntityType>

The http Response will look like below

            {"d": {
                            "__count": "3",
                            "results": [
                                {
                                    "__metadata": {
                                        "id": "Customer_Odata_Service.CustomerSet/CustomerSet('1000')",
                                        "uri": "Customer_Odata_Service.CustomerSet/CustomerSet('1000')",
                                        "type": "CustomerNamespace.CustomerType"
                                    },
                                    "Id": "1000",
                                    "Name": "Mani",
                                    "FC": 1,
                                    "Weight": "70",
                                    "Unit": "Kg"
                                },
                                {
                                    "__metadata": {
                                        "id": "Customer_Odata_Service.CustomerSet/CustomerSet('1001')",
                                        "uri": "Customer_Odata_Service.CustomerSet/CustomerSet('1001')",
                                        "type": "CustomerNamespace.CustomerType"
                                    },
                                    "Id": "1001",
                                    "Name": "Raju",
                                    "FC": 1,
                                    "Weight": "70",
                                    "Unit": "Kg"                                    
                                },
                                {
                                    "__metadata": {
                                        "id": "Customer_Odata_Service.CustomerSet/CustomerSet('1002')",
                                        "uri": "Customer_Odata_Service.CustomerSet/CustomerSet('1002')",
                                        "type": "CustomerNamespace.CustomerType"
                                    },
                                    "Id": "1002",
                                    "Name": "Jack",
                                    "FC": 3,
                                    "Weight": "70",
                                    "Unit": "Kg"                                    
                                }                                 
                            ]
                }
            }

With the Metadata unit annotations and the corresponding http response will result in rendering a SAP UI5 Smart Table with values (Weight along with the unit) like below

Unit Annotations in SAP UI5 Table

XML vs HTML sitemap

XML sitemapHTML sitemap
XML sitemaps are for search enginesHTML sitemaps are for humans
A structured text file containing URLs of pages of a website for web crawlersWebpage containing links facilitating user navigation on a website
Never displayed to usersDisplayed in webbrowser
Read by webcrawlers onlyVisited by users and web crawlers
Used for faster page indexing and avoiding content duplicationUsed for better website navigation, interlinking opportunities and improved crawling

Google prefers XML sitemaps

What is a Sitemap?

If you are like me trying to understand the errors in google search console, you would have seen the word sitemap. In todays post we will see about sitemap. Why we need them? Benefits etc.,

Sitemap is like a guide with hierarchical diagram that allows you to visualize the structure of a website. It is a file that provides information about pages, videos and other files on our website and relationship between them .

It is a list of pages of a website within a domain. Sitemap is important part of SEO. It helps google discover pages faster and more efficiently.

Why Sitemap?

Sitemap is important for understanding your website structure and helps search engines like google to navigate faster. Its like a blueprint of your website. Its essential for SEO ranking. Organizing website. First step in creating a new or updated website. Helps in fixing poor internal linking. Gives a better view of our website to search engines. Acts as a reference point.

Sitemap is beneficial when?

Website is

  • Big
  • New
  • Lesser backlinks
  • bad interlinking strategy.
Sitemaps are useful to
  • Show navigation structure
  • Identify top-level unique page types
  • Relationship between different pages.
Sitemaps are not for
  • Indicating website design
  • Identify user paths
  • list all website content

Difference between page and post in wordpress

Two options to publish contents in wordpress are

  • Post
  • Page

Combining these two is making wordpress more powerful in building websites.

Post:

WordPress is mainly used for blogging and a post is a single blog entry. Posts are based on timestamp that means its always associated with a month and year. It is always in reverse chronological order. Posts are dynamic.

Page:

Pages are timeless and static. It includes only static information example about me or contact us page.

Post vs Page:

PostPage
DynamicStatic
reverse chronological orderchronological order
timelytimeless
Posts can be categorizedpages are hierarchical
Have custom format optionDo not have custom format option
RSS feed supportedDo not have RSS feeds
Allows comments and feedbacksDo not allow comments and feedbacks

HTTP vs HTTPS

Both HTTP and HTTPS are protocols for communicating over the internet. If you have a website or probably used a website might have come across these things namely http:// or https://

What is HTTP ?

Hyper Text Trasfer Protocol is a set of rules defining how information is transfered over internet. It is a stateless protocol built on top of TCP protocol in application layer. User connects to your site are through a insecure connection vulnerable to security attacks. Here plain text is transmitted as it is without encryption.

What is HTTPS?

Hyper Text Transfer Protocol Secure is a advanced and secured version of HTTP. Here everything is encrypted with SSL/TLS protocol. Protects sensitive data from being stolen. It requires SSL certificate.

HTTP vs HTTPS

How to ask for directions in German?

First we will know the basic directions in German

4 Directions:

die Richtung – directions

der Norden – north

der Süden – south

der Osten – east

der Westen – west

Now we will get into asking directions for places like railway station, supermarket, busstop etc.,

Asking directions:

Entschuldigung, wo ist …? – Excuse me, where is …?

In welcher Richtung ist die …? – Ich which direction is …

Wie komme ich zu …? – How to reach …?

Können Sie mir sagen wo … ist? – Could you tell where is …?

Entschuldigung, wo ist die Bushaltestelle? – Excuse me, where is the busstop?

Wie weit sind wir von der Bahnhof? – How far are we from railwaystation?

Entschuldigung, wie komme ich zum Flughafen? – Excuse me, how do I get to the airport?

Replying to directions:

We need to know some wortschatz for answering to direction questions.

Gehen Sie geradeaus – Go straight

Gehen Sie in die Kirchstraße entlang – Go along the Kirchstraße

Gehen Sie um die Ecke – Go around the corner

Biegen Sie nach rechts ab – Turn right

Biegen Sie nach links ab – Turn left

An der ersten Verkehrs-Ampel biegen Sie links ab – Turn left at the first signal.

Daily routine in German

Today we will see some common day-to-day activities in german.

der Tagesablauf – daily routine

Um 6Uhr stehe ich auf – I wake up at 6 am.

Ich putze meine Zähne – I brush my teeth

Ich nehme eine Dusche – I take bath

Ich ziehe mich – I change myself

Um 7 Uhr frühstücke mich – I eat breakfast at 7 am

Um 7:30 Uhr gehe ich zur Schule – I go to school at 7:30 am

Am abends spiele ich mit mein Freund – I play with my friend in evening.

Nach der Schule mache ich Hausaufgaben – After school I do homework.

Um 20 Uhr gehe ich ins Bett – I go to bed at 8 pm

How to use CSS class?

A CSS class is an attribute used to define a group of HTML elements a unique styling and formatting. Class is a group of elements that are similar or unique. For example, when we want to add blue text to a set of paragraphs, or bold red text to set of headings in our website we use CSS class.

How to add a class to your HTML element?

<div class=”class1”>

<p class=”class1”>This is a paragraph</p>

Each HTML element can have multiple classes.

<div class=”class2”>

How to use a class in CSS?

.class1{

width: 50px;

height: 50px;

background: blue;

}

Example:

OUTPUT:

Where can you add CSS classes in HTML?

CSS classes can be added to any HTML elements. Some of the most common ones are:

  • <p> paragraph
  • <body>
  • <h1>, <h2>, …<h6> headings
  • <title>
  • <blockquote>
  • <span>
  • <div>
  • <img> images
  • <button>
  • <a>
  • <links>
  • <embed>
  • <table>

and much more.

How to use CSS selectors

To apply CSS to an element we need to select it. It is used to select the content you want to style

What is CSS selectors?

          CSS selectors define the elements to which a specific set of rules apply. It is the first part of CSS rule. It is a pattern of elements and other terms that tell the browser which HTML elements should be selected to have the CSS property values inside the rule applied to them. The element or elements which are selected by the selector are referred to as the subject of the selector.

Syntax:

Selector{

          propertyName: value;

          propertyName: value;

          }

Types of Selectors:

  • Element
  • ID
  • Universal
  • Class
  • Attribute

Element Selector:

This selects HTML elements based on the element tag name like <p>, <h1> etc.,

p {
  text-align: center;
  color: red;
}

Universal selector

Selects all elements. Optionally, it may be restricted to a specific namespace or to all namespaces.
Syntax: * ns|* *|*
Example: * will match all the elements of the document.

* {
  text-align: center;
  color: blue;
}

Type selector

Selects all elements that have the given node name.
Syntax: elementname
Example: input will match any <input> element.

Class selector

Selects all elements that have the given class attribute.
Syntax: .classname
Example: .index will match any element that has a class of “index”.

.index {
  text-align: center;
  color: red;
}

To specify only specific HTML elements of a class to be affected

p.index {
  text-align: center;
  color: red;
}

Here only elements with tag <p> are affected in class index.

ID selector

Selects an element based on the value of its id attribute. There should be only one element with a given ID in a document.
Syntax: #idname
Example: #p1 will match the element that has the ID “p1”.

#p1 {
  text-align: center;
  color: red;
}

Attribute selector

Selects all elements that have the given attribute.
Syntax: [attr] [attr=value] [attr~=value] [attr|=value] [attr^=value] [attr$=value] [attr*=value]
Example: [autoplay] will match all elements that have the autoplay attribute set (to any value).

a[target] {
  background-color: yellow;
}

CSS Grouping Selector

Grouping Selector selects all HTML elements with same style definitions.

To group selectors , we separate with comma ,

h1, h2, p {
  text-align: center;
  color: red;
}

How to select the default columns for Smart table in SAP UI5

‘initiallyVisibleFields’ property of the SAP UI5 Smart table is used to select the default columns for the smart table.

initiallyVisibleFields=”Id,Name”

As you see above, the fields(columns) of the smart table are separated by Comma. The columns will be visible in the same order as mentioned above with customer Id as first column and Customer Name as second column.

Important points to keep in mind while using this Property

  • The ‘initiallyVisibleFields’ Property must be used only if the CDS view is created without the Line Item Annotations. So there should not be any Line Item Annotations in the metadata generated.
  • Only during the initialization, the ‘initiallyVisibleFields’ Property of Smart Table can be used. It cannot be modified after the Smart table control is initialized.
  • The Property is not Validated. So if the fields are not mentioned properly, then it will not work. Like if spaces exists additionally or if there is any special symbols, then the columns will not be displayed properly.

            <core:View xmlns:core="sap.ui.core" controllerName="initialView.controller"
                xmlns="sap.m"
                xmlns:smart="sap.ui.comp.smarttable"
                xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
                height="100%">
                <Page id="page1" title="Customers1">
                   <VBox fitContainer="true">
                       <smart:SmartTable id="smartTable1" entitySet="CustomerSet"
                           tableType="ResponsiveTable"
                           showFullScreenButton="true" header="Customers" showRowCount="true"
                           editTogglable="true"
                           customData:useSmartField="true"
                           useTablePersonalisation="true"
                           initiallyVisibleFields="Id,Name"
                           enableAutoBinding="true">
                       </smart:SmartTable>
                   </VBox>
                </Page>
            </core:View>

The priority in which the columns are displayed in the following

  1. Initially if the XML View contains some fields, then these fields are displayed first. This takes the highest priority.
  2. If the LineItem Annotations are present in the metadata, then these fields are displayed second.
  3. Atlast, the initiallyVisibleFields are taken in to consideration. It appears at the end in the display.