Project Training
Project Training
1
Copyright © 2018. BluePrint Technologies. All rights reserved.
Document Statistics:
DOCUMENT IDENTIFICATION
The following is current information about the document: (Maintain all relevant section)
Object ID
Version 1.0
Level ID
Process Team
Area/Sub Module
Technical Contact
Author
Development Type
FSD Name
REVISION HISTORY
The following is a history log of revisions to the document:
2
Copyright © 2018. BluePrint Technologies. All rights reserved.
Table of Contents
3
Copyright © 2018. BluePrint Technologies. All rights reserved.
1.0 Introduction to HTML5
HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0,
and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide
Web.HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web.
Hypertext Application Technology Working Group (WHATWG).The new standard incorporates
features like video playback and drag-and-drop that have been previously dependent on third-party
browser plug-ins such as Adobe Flash, Microsoft Silverlight, and Google Gears.
4
Copyright © 2018. BluePrint Technologies. All rights reserved.
1.3 Basic Framework
An HTML document has two main parts:
Head.
o The head element contains title and Meta data of a web document.
Body.
o The body element contains the information that you want to display on a web page.
In a web page, the first tag (specifically, <html>) indicates the markup language that is being
used for the document. The <head> tag contains information about the web page. Lastly, the content
appears in the <body> tag.
Element of structure of a document (for example, paragraph, web page title, etc.).
element in the sense of a tag (for example, <p>, <title>)
Because of the different meanings of the word "element", it can be confusing what the word
"element" means in a particular context. The following discussion may help you to understand
the differences in the meaning. When we talk about the element in the sense of element of
structure of a document, we are referring to the structure of the document; for example,
document's header information (head), title, body, etc. When, however, we use the word
element to refer to a tag, we are talking about a specific HTML instruction that uses angled
brackets like <>. As the following table shows,
5
Copyright © 2018. BluePrint Technologies. All rights reserved.
Table 1.4 Element Representation in different ways
An element becomes a tag when we use the angled brackets around it. To create a web page, we use
tags. A tag instructs the browser what specific instruction to execute. Assume in your web page you
want to emphasize some text as bold. To do this, HTML requires three pieces of information from you:
With what tag do you want to emphasize the text? (Answer to this question determines
what and where a specific HTML instruction will begin. In other words, this starts an HTML
instruction.)
What text do you want to make bold?
Where do you want to stop the instruction? (An instruction should be ended with the same
tag that started the instruction. See below.)
So how would be write the necessary markup? Begin by answering to the three questions listed above.
Here are the answers to each corresponding question:
We will use the <b> tag. Think of this as turning ON the bold feature in HTML.
We want to display "World Wide Web Consortium" as bold. Remember this text must be
immediately following the <b> tag.
Stop the instruction with </b> tag. This will turn OFF the bold feature of HTML.
So our HTML markup will become:
The <b>World Wide Web Consortium</b> (W3C) is a rule-making body for the Web.
Important Points
Every element has a name such as head, title, p, b, and I.
A tag is the element name surrounded by the angled brackets. This refers to a start tag
such as <p>, <title>, and <i>. A start tag starts a particular HTML instruction.
An end tag is the same as a start tag except the end tag has a forward slash between the
< and the element name. An end tag stops a particular HTML instruction.
Most elements have content, which is placed between the start and the end tags. Example,
this is <b>bold</b>.
Some elements have no content. Such elements/tags are known as empty tags.
Some elements have no end tags. These are referred to as one-sided tags. A tag that has
an opening and closing tag is referred to as two-sided tag.
6
Copyright © 2018. BluePrint Technologies. All rights reserved.
for that attribute. Therefore, if you are going to use an attribute, you will need to have value for that
attribute.
Let us go over the actual HTML, for example
Align="right" is an example of attribute-value pair. The word align is the attribute. The value of this
attribute is right. A value of an attribute is enclosed in double quotation marks.
The following shows the HTML code for the top paragraph:
<p align="right">This is my paragraph. Normally, text and other object on a web page are left-aligned.
Because this paragraph has an extra instruction (align="right") to start this particular paragraph from
the right, the paragraph is right-aligned.</p>
Some attributes have predefined values. For example, for the align attribute, possible
values include, left, center, justify and right. So if you use the align attribute, you should
use one of these acceptable values.
Some attributes accept numerical values. For instance, for the width attribute, you can
specify a numerical value such as 5 (which indicates 5 pixels), or 20% (which indicates
20% of the screen width).
Main points to remember for attributes:
Attributes are specific to tag names. For example, for the <p> tag, you can use the align
attribute but not the width attribute. The width attribute can only be used with tags such as
<table>, <td>, and <img>.
Attributes have values. Make sure to use the correct value for the correct attribute. For
instance, you should not use colour="20", or align="brown"; instead use, color="red", and
align="justify".
Attribute values needs to be enclosed in double quotation marks. This is true especially if
the value contains one or more spaces, for example, face="Times New Roman".
Attribute values could come from a predefined list (such as color names red, green, blue,
etc.) or from you (width of a table 50% or 800 pixels.)
7
Copyright © 2018. BluePrint Technologies. All rights reserved.
As the web page shows, the content of the title tag is displayed on the top of the web page in
the blue bar of Internet Explorer. If you wanted to have "My First Web Page" appear in the title bar,
your title tag will look like :
<title>My First Web Page</title>
Next, figure 1 shows the location of the web page. The address box shows the web page is located at
"C:\HTMLExamples\basic-page.htm". But why is it important to know where a web page is located?
So you can view the web page in a browser. In this example, the webpage is saved to a local C drive
in the HTML Examples folder. To access the web page, first you would open the c drive and then the
HTML examples folder. Finally, you will click on the web page file you want to open.
Finally, the web page shows the content that is placed inside the body tag. Suppose you want to
display the following text (with a white background) on a web page:
Before a webpage can be viewed in a browser, it must be saved.
To display that text your body tag will look something like this:
In HTML, a comment begins with <!-- and ends with -->. Any text you place after <!-- is comment.
Browsers ignore comment text.
8
Copyright © 2018. BluePrint Technologies. All rights reserved.
Example of a single line comment:
<!--This is a small comment-->
Example of a multi-line comment:
<!--This comment is long. It is displayed on more than one line. Adding multi-line comments in HTML
is easy as adding a single line comment. Whether the comment is single line or multi-line, it starts
with <-- and ends with -->-->.
Important points about comments:
Add comments to major parts of your code; or for parts, that you are unsure of.
Use of comments is a great way to communicate with other people working on the same
web page.
Reading and understanding this code is difficult because it is so disorganaized. Becuase extra
white space is ignored by the browsers, you can use that to your advantage to orgnaize your code.
Use of white space to seperate tags helps you better understand and maintain your pages. The
following shows the updated code with the approriate amount of space:
<!DOCTYPE html>
<html>
<body>
<section>
<h1>WWF</h1>
<p>The World Wide Fund for Nature (WWF) is an international organization working on issues
regarding the conservation, research and restoration of the environment, formerly named the World
Wildlife Fund. WWF was founded in 1961.</p>
</section>
9
Copyright © 2018. BluePrint Technologies. All rights reserved.
<section>
<h1>WWF's Panda symbol</h1>
<p>The Panda has become the symbol of WWF. The well-known panda logo of WWF originated
from a panda named Chi Chi that was transferred from the Beijing Zoo to the London Zoo in the same
year of the establishment of WWF.</p>
</section>
</body>
</html>
Reference:1 https://www.w3schools.com/html/default.asp
Reference 2 http://www.scriptingmaster.com/html/html.asp
10
Copyright © 2018. BluePrint Technologies. All rights reserved.
2.0 Introduction to CSS3
Cascading Style Sheets (CSS) is a style sheet language used for describing the look and
formatting of a document written in a markup language.CSS3 is a latest standard of css earlier
versions (CSS2).The main difference between css2 and css3 is follows
Media Queries
Namespaces
Selectors Level 3
Color
2.1 CSS3 modules
CSS3 is collaboration of CSS2 specifications and new specifications, we can called this
collaboration is module. Some of the modules are shown below
Selectors
Box Model
Backgrounds
Image Values and Replaced Content
Text Effects
2D Transformations
3D Transformations
Animations
Multiple Column Layout
User Interface
CSS3 Rounded corners are used to add special colored corner to body or text by using the
border-radius property.A simple syntax of rounded corners is as follows –
#rcorners7 {
border-radius: 60px/15px;
background: #FF0000;
padding: 20px;
width: 200px;
height: 150px;
11
Copyright © 2018. BluePrint Technologies. All rights reserved.
The following table shows the possible values for Rounded corners as follows
Table 2CSS options for rounded corner
Values Description
border-top-left-radius Use this element for setting the boarder of top left
corner
border-top-right-radius Use this element for setting the boarder of top right
corner
Let’s consider the following example of how we can use css in html
<html>
<head>
<style>
#rcorners1 {
border-radius: 25px;
background: #8AC007;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners2 {
border-radius: 25px;
border: 2px solid #8AC007;
padding: 20px;
width: 200px;
height: 150px;
}
12
Copyright © 2018. BluePrint Technologies. All rights reserved.
</style>
</head>
<body>
#borderimg {
13
Copyright © 2018. BluePrint Technologies. All rights reserved.
The most commonly used values are shown below −
Values Description
border-image-source Used to set the image path
border-image-slice Used to slice the boarder image
border-image-width Used to set the boarder image width
border-image-repeat Used to set the boarder image as rounded, repeated
and stretched
Example
<html>
<head>
<style>
#borderimg1 {
padding: 15px;
border-image-source: url(/https/www.scribd.com/css/images/border.png);
border-image-repeat: round;
border-image-slice: 30;
border-image-width: 10px;
</style>
</head>
<body>
14
Copyright © 2018. BluePrint Technologies. All rights reserved.
<p id="borderimg3">This is image boarder example.</p>
</body>
</html>
Values Description
15
Copyright © 2018. BluePrint Technologies. All rights reserved.
Multi background Size
Multi background property is accepted to add different sizes for different images. A sample
syntax is as shown below −
#multibackground {
background: url(/https/www.scribd.com/css/imalges/logo.png) left top no-repeat, url(/https/www.scribd.com/css/images/boarder.png) right
bottom no-repeat, url(/https/www.scribd.com/css/images/css.gif) left top repeat;
background-size: 50px, 130px, auto;
}
As shown above an example, each image is having specific sizes as 50px, 130px and auto size.
RGBA color
HSL color
HSLA color
Opacity
RGBA stands for Red Green Blue Alpha. It is an extension of CSS2,Alpha specifies the opacity of
a color and parameter number is a numerical between 0.0 to 1.0. A Sample syntax of RGBA as
shown below −
HSL stands for hue, saturation, lightness. Here Huge is a degree on the color wheel, saturation
and lightness are percentage values between 0 to 100%. A Sample syntax of HSL as shown below −
HSLA stands for hue, saturation, lightness and alpha. Alpha value specifies the opacity as shown
RGBA. A Sample syntax of HSLA as shown below −
16
Copyright © 2018. BluePrint Technologies. All rights reserved.
#g3 {background-color: hsla (120, 100%, 25%, 0.3) ;}
Opacity is a thinner paints need black added to increase opacity. A sample syntax of opacity is as
shown below −
Reasons to validate
There are a number of reasons why you should validate your code. However, major ones are as
follows
Reference1 : https://www.w3schools.com/css/
Reference 2: https://www.quackit.com/css/
17
Copyright © 2018. BluePrint Technologies. All rights reserved.
3.0 Introduction to JavaScript
JavaScript is an object-based scripting language that is lightweight and cross-platform.
JavaScript is not compiled but translated. The JavaScript Translator (embedded in browser) is
responsible to translate the JavaScript code.
Client-side validation
Dynamic drop-down menus
Displaying data and time
Displaying popup windows and dialog boxes (like alert dialog box, confirm dialog box and prompt
dialog box)
Displaying clocks etc.
JavaScript Java
Easy to learn and use Complicated to learn and use
Useful for simple tasks Useful for complex tasks
No developer's kit required Requires Java Developer Kit to create applets
JavaScript code is written directly in HTML Java programs are saved in separate files and
and it does not require compiling must be compiled before they can be run
After Netscape introduced JavaScript in 1995, Microsoft introduced its own form of JavaScript
called JScript for its browser: Internet Explorer. As time progressed, major browser vendors included
support for different brands of JavaScript. Table 4 lists different versions of JavaScript and how
Netscape and Internet Explorer support them.
18
Copyright © 2018. BluePrint Technologies. All rights reserved.
3.3 Basics of JavaScript
If you already are not aware, with HTML you can only create static web pages. A static web
page simply is a page whose content or layout will not change. A dynamic page, on the other hand, is
interactive and whose content changes according to the scripting instructions specified. To create a
dynamic web page, you simply write a small program using a web programming language like Active
Server Pages, JavaScript, Perl, PHP, etc.
JavaScript code is placed between the <script> and </script> tags. In addition, the JavaScript
code inside the <script> tag can be placed directly in an HTML document. You may also link external
JavaScript files to an HTML document. By doing that, you can share your JavaScript across multiple
web pages.
Thus, both statements would be interpreted the same way. You might be asking be yourself
why is whitespace important? Because whitespace is ignored in JavaScript, you can use it to benefit
yourself by writing code that is more readable and understandable. The importance of whitespace
though may not be realized in a smaller program. Suppose you had the following JavaScript code:
If (a > b) {document.write ("a is greater than b.") ;} else {document.write ("a is not greater than b"); }
As a programmer, the above code may be harder for you to follow but for the computer (specifically
the interpreter) it is more beneficial as much of the unnecessary space characters are eliminated. In
19
Copyright © 2018. BluePrint Technologies. All rights reserved.
the following code, however, we use reasonable amount of space for readability and understand
ability:
If (a > b)
{
document.write ("a is greater than b.");
}
else
{
document.write ("a is not greater than b");
}
From our above discussion, do not assume JavaScript ignores all excessive whitespace. The
exception is to our rule is use of whitespace in strings. In strings, whitespace is preserved, as in:
var AString = "Thisis a string";
In JavaScript, statements can also be terminated with a line break character, for example,
var x
x = 60
document.write (x)
The above three lines are treated as three separate statements as:
var x;
x = 60;
document.write (x);
To avoid ambiguity and any unintended results, use a semicolon to mark end of a statement instead
of relying on an implicit semicolon insertion (or a linebreak character).
In JavaScript the case sensitivity does not just apply to variable names but also to JavaScript
keywords, event handlers, and object properties or methods. Keywords in JavaScript are all
lowercase, for example, while, for, if, else, and so on. On the other hand, methods (properties) use
20
Copyright © 2018. BluePrint Technologies. All rights reserved.
"camel-back" naming convention (first word is in lowercase and each successive first letter of each
word is capitalized), for example, toArray(), lastModified(), and so on.
counter=0;
while(counter<10)
{
documents.write(“counter=”+ counter + “<br>”);
counter++
}
A code block can also be created with statements grouped in a condition:
if(counter == 15)
{
break
}
Finally statements grouped in a function also create a code block:
function Count(counter)
{
counter=counter+1;
return counter;
Because you can insert JavaScript code inside an HTML file, it needs to be distinguished from
the rest of the text or code on the page. To separate your JavaScript commands from HTML
21
Copyright © 2018. BluePrint Technologies. All rights reserved.
commands or regular text on the page, insert your JavaScript code inside the opening <script> and
closing </script> tag. For example,
<script language="JavaScript">JavaScript commands</script>
Because there are different client-side languages, we need to indicate to the browser which
language we are using in our scripts. To indicate the scripting language, we added the language
attribute to the <script> tag. Since we are using JavaScript, we set the language tag to JavaScript. If
you omit the language tag from your <script> tag, the browser will assume that your code is written in
JavaScript.
If you place your scripting code outside of the HTML page, you still use the <script> tag but
then just add the src attribute. The value of src attribute tells the browser where your JavaScript code
is located. For instance,
<script language="JavaScript" src="JavaScript/displayDate.js"></script>
Indicates that we are using JavaScript language and the JavaScript commands are located in a folder
called JavaScript and a file called displayDate.js. A ".js" file extension indicates a JavaScript file.
primitive types
composite types
numbers
strings
Booleans
undefined and null
Numbers
As the name implies, a number type refers to numerical values. Numbers can be divided into two
groups:
floating-point — are fractional numbers such as 2.45, -3.58, and .97
Strings
A string type refers to one or more characters of text. In JavaScript, a string is enclosed inside
single or double quotes. The following, for example, represents an invalid string:
"This is not a valid string.'
“This is a valid string”
Boolean
22
Copyright © 2018. BluePrint Technologies. All rights reserved.
In JavaScript, Boolean logic allows your program to make decisions. A Boolean logic
statement consists of a condition that evaluates to either true or false. You can think of the condition as
a question that has one of two possible answers:
yes or no,
ON or OFF, or
positive or negative
true or false
declares a variable called iAge. Its type is undefined; it can be confirmed by simply outputting its
type using the typeof operator:
So as long as no value is assigned to a variable, its type is undefined. Once a value is assigned, it
will no longer be of type undefined but rather one of other types supported in JavaScript: numbers,
strings, Boolean, or Null.
23
Copyright © 2018. BluePrint Technologies. All rights reserved.
Null type
The null type indicates an empty value. When a variable is assigned the value null, its type
becomes null. A null type variable is a placeholder that represents nothing. The following shows an
example of a variable of type null:
From these basic data types, more complex data type (also known as composite types) is
derived. Although JavaScript supports five primitive data types, we actually use only numbers, strings,
and Booleans to store data. The undefined and null types arise under certain circumstances in
programming.
called age. With the above command, computer will reserve some memory and allow you to store to
or retrieve from that memory with the name you chose, age. Remember at this point our variable aegis
null or has a garbage value–whatever computer's memory slot happens to hold.
24
Copyright © 2018. BluePrint Technologies. All rights reserved.
You can declare more than one variable by separating each with a comma and still use one var
command, as:
var state, city, zip, country;
When you declare a variable, keep the following JavaScript restrictions in mind to a variable name:
A variable name cannot be one of the reserved words in JavaScript. Examples of reserved words
in JavaScript include var, or document.write. Reserved words have a specific purpose in
JavaScript; they cannot be used as a variable name.
The first letter of a variable name must be a letter or an underscore (_). Age, year, _month are all
valid variable names. However, 11month, 9_ are not valid variable names.
A variable name cannot contain any space characters. If your variable consists of more than one
word, separate each word with a underscore (i.e., first_name, last_name) or make the first letter
of each word a capital letter (i.e., FirstName, LastName).
var age;
age = 55;
25
Copyright © 2018. BluePrint Technologies. All rights reserved.
The first line declares a variable called age. The second line stores the number 55 to our variable age.
If you want, you could also combine those two lines, as:
age = 55;
In this one line above, we declare a variable called age when we assign the value 55. In this case, the
value is declared implicitly; to explicitly declare a variable, use the command var before a variable
name.
Consider the following example:
<script language="javascript">
var fName, age;
fName = "John";
age = 23;
document.write (fName);
document.write ("is");
document.write (age);
</script>
The following shows the output of the above code.
Johnis23
To print "Johnis23" as "John is 23", simply add a space character around the word "is", as
<script language="javascript">
var fName, age;
fName = "John";
age = 23;
document.write (fName);
document.write (" is ");
document.write (age);
</script>
That will print:
John is 23
26
Copyright © 2018. BluePrint Technologies. All rights reserved.
3.6 Operators in JavaScript
An operator is a method implemented to replace, modify or combine values represented by
variables. With operators, we can evaluate expressions–JavaScript commands that assign values to
variables. In the following expression,
totalAmountDue = totalBeforeTax + (totalBeforeTax * .05);
=, +, * are operators. An expression, as shown above, always has an assignment operator (= sign).
An expression can also contain other operators (like +, *, -, /, etc.).
We have five types of operators and they are as follows,
Arithmetic operators
Assignment operators
Conditional statements
o Logical operators
27
Copyright © 2018. BluePrint Technologies. All rights reserved.
Table 6Unary Arithmetic operators in JavaScript
Very often, when you write code, you want to perform different actions for different decisions.
28
Copyright © 2018. BluePrint Technologies. All rights reserved.
In JavaScript, we have the following conditional statements:
IF Statement
Use the if statement to specify a block of JavaScript code to be executed if a condition is true.
Syntax
if (condition) {
block of code to be executed if the condition is true
}
Else Statement
Use the else statement to specify a block of code to be executed if the condition is false.
if (condition) {
block of code to be executed if the condition is true
} else {
block of code to be executed if the condition is false
}
Else if Statement
Use the else if statement to specify a new condition if the first condition is false.
if (condition1) {
block of code to be executed if condition1 is true
} else if (condition2) {
block of code to be executed if the condition1 is false and condition2 is true
} else {
block of code to be executed if the condition1 is false and condition2 is false
}
Switch Statement
Use the switch statement to select one of many blocks of code to be executed.
Syntax
switch (expression) {
case n:
code block
29
Copyright © 2018. BluePrint Technologies. All rights reserved.
break;
case n:
code block
break;
default:
code block
}
Break
When JavaScript reaches a break keyword, it breaks out of the switch block.
This will stop the execution of more code and case testing inside the block.
Default
The default keyword specifies the code to run if there is no case match:
Operator Description
30
Copyright © 2018. BluePrint Technologies. All rights reserved.
3.6.5 Comparison operators
Comparison operators are also called relational operators. These operators are used to
construct and test conditions. To use the operator, we need left-hand-side and right-hand-side. The
sides represent the values we want to compare and the comparison operator is placed between the
values. See the following as an example:
Operator Description
== Returns true if both sides are equal. Note the mathematical equal sign (=) is
interpreted as an assignment operator in JavaScript. So, in JavaScript, use two
equal symbols (==) when you want to find out if one variable is equal to another.
!= Returns true if variables are not equal
> Returns true if the variable on the left is greater than the variable on the right
< Returns true if the variable on the left is less than the variable on the right
>= Returns true if the variable on the left is greater than or equal to the value of
the variable on the right
<= Returns true if the variable on the left is less than or equal to the value of the
variable on the right
<script language="javascript">
document.write (1 + "<br>");
31
Copyright © 2018. BluePrint Technologies. All rights reserved.
document.write (2 + "<br>");
document.write (3 + "<br>");
document.write (4 + "<br>");
document.write (5 + "<br>");
</script>
Before we do this same example with a loop control structure, let us first point out that there
are four types of loops
For Loop
The for loop is often the tool you will use when you want to create a loop.
Statement 2 defines the condition for running the loop (the code block).
Statement 3 is executed each time after the loop (the code block) has been executed.
For/in Loop
The JavaScript for/in statement loops through the properties of an object:
<script>
32
Copyright © 2018. BluePrint Technologies. All rights reserved.
var x;
for (x in person) {
document.getElementById("demo").innerHTML = txt;
</script>
JavaScript Loops
John Doe 25
while (condition) {
JavaScript statements that you want to execute repeatedly
}
where
condition = a Boolean expression that can be true or false. While the Boolean expression is true, the
JavaScript code inside the while loop is executed.
<script language="javascript">
var i = 1;
while (i <= 5) {
document.write (i + " ");
i++;
}
</script>
Note that for a while loop we initialize our counter variable, i, before the loop starts. Note also the
counter variable is updated inside the while loop. This while loop prints:
12345
33
Copyright © 2018. BluePrint Technologies. All rights reserved.
Table 10JavaScript While Loop Sample code
where
JavaScript commands = commands that run when the function is called or used
A function starts with the keyword function. All the commands that belong to a function must
be placed inside the curly braces { }. The set of commands placed inside the curly braces is referred
to as a commands block. The commands block combined with the function name is referred to as
a function definition. In other words, a function definition tells you what the function is and what it
does.
34
Copyright © 2018. BluePrint Technologies. All rights reserved.
Before you start creating your own JavaScript functions, keep in mind that JavaScript function
name must begin with a letter or underscore (_). The function name cannot contain any spaces. In
addition, like variables, function names are case-sensitive. Thus, calculateSalary and CalculateSalary
are considered different function names. For the function parameters, there is no limit in the number
of function parameters a function contains. The function parameters must be placed inside the
parentheses, following the function name, and a comma must separate each parameter.
<script language="javascript">
function DisplayMessage () {
document.write ("Learn JavaScript from the Scripting Master!");
}
document.write ("Calling the function....<br>");
DisplayMessage ();
document.write ("<br>..Done!");
</script>
The execution of this script will begin on line five and that prints the "Calling the function...”
Remember that a function is executed only when you call the function. We call the function on line 6.
When the function is called, the code inside the function will be executed. So after line 6, line 2 will be
executed that states the name of the function and indicates that it takes no parameters because of the
empty parentheses. Next, line 3 will be executed to print the "Learn JavaScript from the Scripting
Master!" Line 4 ends our function. Finally, line 7 will be executed to print ".Done!" The following shows
the output of the above JavaScript code:
Calling the function....
Learn JavaScript from the Scripting Master!
..Done!
35
Copyright © 2018. BluePrint Technologies. All rights reserved.
As you may have noticed, when we use functions we are changing the order in which the statements
in our scripts are executed. In other words, your statements may not run in the order they are listed in
your program. This type of control structure is referred to as non-linear (non-sequential) execution. In
our JavaScript code above, lines 2, 3, and 4 were executed after line 6.
With this one example, do not feel that functions make you write extra code. Remember the idea
behind using functions is to reuse code. For instance, let us say we wanted to print a long welcome
message in five different places of our program. For that example, we would define a function that
contains our welcome message. Anytime we need to print that message we just simply call the
function. You do not have to write five different document.write () methods for the welcome message
at five different locations in your program!
36
Copyright © 2018. BluePrint Technologies. All rights reserved.
and the third parameter expects the pay rate for an individual. The following shows the output of this
example:
Steve, your salary for this week is: $750
John, your salary for this week is: $1600
37
Copyright © 2018. BluePrint Technologies. All rights reserved.
Even numbers: 2 4 6 8 10 12 14 16 18 20
Reference 1 : https://www.w3schools.com/js/
Reference 2: https://www.codeschool.com/learn/javascript
38
Copyright © 2018. BluePrint Technologies. All rights reserved.
4.0 Introduction to SAPUI5
SAP UI5 apps has rich user interfaces for modern Web business applications, responsive
across browsers and devices, based on HTML5.
Reference:https://sapui5.hana.ondemand.com/1.46.10/#docs/guide/95d113be50ae40d5b0b
562b84d715227.html
4.1 Versioning
SAPUI5 uses a 3-digit version identifier, for example 1.48.8. The digits have the following meaning:
The first digit (1) specifies the release number (major version).
The second digit (44) specifies the version number (minor version).
Reference:https://sapui5.hana.ondemand.com/#/topic/91f021426f4d1014b6dd926db0e9107
0
39
Copyright © 2018. BluePrint Technologies. All rights reserved.
4.2 SAPUI5 Architecture Overview
In SAP UI5 architecture, you have three layers −
At the top, is the presentation layer, where devices like mobile, tablets, and laptops consume UI5
components.
At the middle layer, is the application clients that includes SAP UI5 libraries for theming and
controls. UI5 control libraries include
o Sap. Viz
o Sap.ui.ux3
At the bottom, Application Server component. This includes SAP NetWeaver Application Server
for ABAP/Java, SAP backend, HANA XS engine for development or database.
Reference: https://www.tutorialspoint.com/sap_ui5/sap_ui5_architecture.htm
40
Copyright © 2018. BluePrint Technologies. All rights reserved.
4.3 Model View Controller
Model, view, and controller are assigned the following roles:
The controller reacts to view events and user interaction by modifying the view and model.
The purpose of data binding in the UI is to separate the definition of the user interface (view), the data
visualized by the application (model), and the code for the business logic for processing the data
(controller). The separation has the following advantages: It provides better readability, maintainability,
and extensibility and it allows you to change the view without touching the underlying business logic
and to define several views of the same data.
Views and controllers often form a 1:1 relationship, but it is also possible to have controllers without a
UI, these controllers are called application controllers. It is also possible to create views without
controllers. From a technical position, a view is a SAPUI5 control and can have or inherit
a SAPUI5 model. View and controller represent reusable units, and distributed development is highly
supported.
Reference:https://sapui5.hana.ondemand.com/#/topic/91f233476f4d1014b6dd926db0e9
1070
41
Copyright © 2018. BluePrint Technologies. All rights reserved.
4.4 Controls and Libraries
4.4.1 Controls
Controls can be used to define appearance and behavior of parts of the screen. Controls
consist of:
Control name
The control name is a string that consists of the library name and the control name, separated by
a dot.
The library name should be omitted if there is no need to assign the control to a library. It is
possible, for example, to use Square as control name.
For controls that are reused by others, we recommend to use a unique library name, for
example sap.byd.Square.
Control metadata
The metadata defines the properties, events, aggregations and associations of a control.
Elements
Elements are parts of controls or rather configuration packages for parts of controls.
Elements cannot be used standalone and do not have their own renderer.
Instead, the control that uses the element does the rendering: The List Box control, for example,
renders the List Item elements.
Methods
By convention, methods are public, unless their name starts with an underscore or if it is one of
the special method types.
When developing control libraries. The public methods has to be annotated with @public in the
JSDoc, and private methods with @private.
The generated getter/setter methods for properties are also public methods.
We can add methods to a new control by simply providing the implementation. Iis not necessary
to add the method to the metadata
Other controls and the application must only call public methods and the control ensures that they
remain compatible.
There are no technical rules that prevent the call of private methods, but as a good practice it is
not allowed
Reference:https://sapui5.hana.ondemand.com/#/topic/ddbceecd7d3d42eea9cf78a820a2
38fb
42
Copyright © 2018. BluePrint Technologies. All rights reserved.
4.42 Libraries
SAPUI5 provides a set of JavaScript and CSS libraries, which can be combined in an
application using the combinations that are supported.
Deprecated Libraries
sap.ui.commons
o Deprecated as of version 1.38.
sap.ui.ux3
o Deprecated as of version 1.38.
sap.ca
o Deprecated as of version 1.22.
sap.me
o Deprecated as of version 1.34.
sap.makit
o Deprecated as of version 1.38.
Reference:https://sapui5.hana.ondemand.com/#/topic/363cd16eba1f45babe3f661f321a7820
43
Copyright © 2018. BluePrint Technologies. All rights reserved.
4.5 Types of Views, Model, Bindings Commented [RA1]: 1.Add Navigation and Routing after
this topic
4.5.1 Views 2. Fragments
The view in the Model View Controller concept is responsible for defining and rendering the 3. Formatters
UI. SAPUI5 supports predefined view types.
XML view. The user interface is defined in an XML file or string. The XMLView type supports a
mix of XML and plain HTML.
JSON view. The user interface is defined in a file or string in JSON format.
JS view. The user interface is constructed in a traditional manner that is in JS format.
HTML view. The user interface is defined in an HTML file or string.
Reference:https://help.sap.com/saphelp_nw74/helpdata/en/91/f0df546f4d1014b6dd926d
b0e91070/frameset.htm
4.5.2 Model
A model in the Model View Controller concept holds the data and provides methods to retrieve
the data from the database and to set and update data.SAPUI5 provides the following predefined
models.
The JSON model can be used to bind controls to JavaScript object data, which is usually
serialized in the JSON format. The JSON model is a client-side model and, therefore, intended for
small datasets, which are completely available on the client. The JSON model supports two-way
binding.
The XML model is a client-side model intended for small datasets, which are completely
available on the client. The XMLModel does not contain mechanisms for server-based paging or
loading of deltas
The Resource model is designed to handle data in resource bundles, mainly to provide texts
in different languages.
The OData model enables binding of controls to data from OData services. The OData model
is a server-side model: the dataset is only available on the server and the client only knows the
currently visible rows and fields. This also means that sorting and filtering on the client is not possible.
For this, the client has to send a request to the server.
Reference:https://help.sap.com/saphelp_nw74/helpdata/en/91/f0df546f4d1014b6dd926db0e
91070/frameset.htm
44
Copyright © 2018. BluePrint Technologies. All rights reserved.
Binding Types
One Way: One-way binding means a binding from the model to the view; value changes in
the model update all corresponding bindings and the view
Two Way: Two-way binding means a binding from the model to the view and from the view to
the model; value changes in the model and in the view update all corresponding bindings and
the view and model, respectively
One Time: One-time binding means from model to view once.
45
Copyright © 2018. BluePrint Technologies. All rights reserved.
5.0 Introduction to SAPUI5 Controls and API
5.1 Controls in SAP UI5:
By opening this URL https://sapui5.hana.ondemand.com/#/controls we will get a page similar
to the one shown in figure 11.
As shown in the figure 11 we can do search for a control, one can be able to see the control
sample, and how it can be used.
46
Copyright © 2018. BluePrint Technologies. All rights reserved.
Next we need to click on the control name shown on the right side of the page , which shows
how the controls looks when implemented in SAP UI5 application. The figure 13 depicts the same.
Click on this icon available on the top right of the page to reveal the code as shown in figure 13
We can also download the code and import it to our webide for our own study.
47
Copyright © 2018. BluePrint Technologies. All rights reserved.
5.2 API Reference:
SAP provides a huge collection of API that can be consumed in to our application. To open
API reference please click on this link https://sapui5.hana.ondemand.com/#/api
As shown in figure 16 we can search for an API and the right side of the page gives us the
Overview, constructor properties events and Methods of the selected API.
48
Copyright © 2018. BluePrint Technologies. All rights reserved.
6.0 Exercises
6.1 SAP HCP URL
Register: https://accounts.sap.com/saml2/idp/sso/accounts.sap.com
Login:https://accounts.sap.com/saml2/idp/sso?sp=sp.accounts.sap.com&RelayState
=https://accounts.sap.com/ui/protected/profilemanagement
Reference: https://www.sap.com/developer/tutorials/hcp-create-trial-account.html
49
Copyright © 2018. BluePrint Technologies. All rights reserved.
6.2 WEB IDE Configuration
Open your SAP Cloud Platform account (if you have a free developer account, click HERE to
open the console.)
After signing in using the SAP HCP credentials .You should now be in the SAP Cloud Platform
Cockpit, as shown below. Click on the Services menu item on the left
50
Copyright © 2018. BluePrint Technologies. All rights reserved.
Next, click on the SAP Web IDE box as shown in figure 20. You may need to scroll down to
find this box.
In the SAP Web IDE screen, you will see a paragraph called Service Description. At the
bottom of the paragraph, there is a link called Open SAP Web IDE as in figure 21. Click this link
51
Copyright © 2018. BluePrint Technologies. All rights reserved.
A new tab (or window) will open, and the Web IDE will load as shown in figure 22
Bookmark this page! If you create a bookmark to this page, it is easy to get back to the
Web IDE later.
Reference:https://www.sap.com/india/developer/tutorials/sapui5-webide-open-webide.html
52
Copyright © 2018. BluePrint Technologies. All rights reserved.
6.3 Configuring ODATA Services in Web IDE
Log into SAP Cloud Platform
Next step, Select the Destinations tab on the left side, and then click on New
Destination to open a new destination configuration form.
53
Copyright © 2018. BluePrint Technologies. All rights reserved.
Confirm data
Enter/confirm all fields in the Destination configuration section with the information below.
Name Northwind
Type HTTP
URL http://services.odata.org
Authentication No Authentication
Do not use the entire path for the URL. The URL should only be http://services.odata.org
Add properties
Add three Additional Properties fields by clicking on the New Property button once for
each property.
WebIDEEnabled true
WebIDESystem Northwind_Data
WebIDEUsage odata_gen
54
Copyright © 2018. BluePrint Technologies. All rights reserved.
Figure 26Add Properties to destination
55
Copyright © 2018. BluePrint Technologies. All rights reserved.
6.4 Creating a sample project in Web IDE
56
Copyright © 2018. BluePrint Technologies. All rights reserved.
Fill in the form as follows:
57
Copyright © 2018. BluePrint Technologies. All rights reserved.
Then click on next
Reference:https://www.sap.com/india/developer/tutorials/sapui5-webide-create-project.html
Sample Program Link: https://bpterp.sharepoint.com/:u:/s/UXSmart/EZnhCe7lortPl-
F0WLebMoYBk0xDVfSdFwhUlRrFC-9tmA?e=n3gsMZ
58
Copyright © 2018. BluePrint Technologies. All rights reserved.
Sample Output
59
Copyright © 2018. BluePrint Technologies. All rights reserved.
Figure 29Mandatory Parameter Routing
60
Copyright © 2018. BluePrint Technologies. All rights reserved.
7.0 Do’s and Don’ts Commented [RA3]: Cover Fiori Implementation before
Do’s and Don’ts
7.1 JavaScript Code Issues Fiori apps library
Fiori apps extension
Don't use methods or properties that are not public Launchpad configuration
Don't use references to global names
Don't use deprecated APIs
Don't override or add control methods
Don't manipulate the DOM structure within controls
Don't attach DOM event handlers
Don't create global IDs (when running with other views or apps)
Don't forget about control lifecycle management
Don't hard code or concatenate strings that need to be translatable
Don't forget about proper "this" handling
Don't use console.log()
Don't use timeouts
Don't build apps without reasonable automated tests
Referencehttps://sapui5.hana.ondemand.com/#/topic/030fcd14963048218488048f407f8f34.html
61
Copyright © 2018. BluePrint Technologies. All rights reserved.