Thursday, December 29, 2011

Working with Placeholder Data Controls in Oracle ADF

Sometimes in Application development it is required to create UI (User Interface) before the actual database table or entities are available or you want to show someone the features / demo of your application without any database involve then what to do in this case?

Well in Oracle ADF "Placeholder Data Controls" solves this problem. You can create your data controls, define attributes manually and populate them with sample data or import the CSV file. Later when real data is available you can easily link you Data Controls to actual entities.

In this post:
- I will create a simple Data Control names "SalesDC" and create inside "SalesData" Collection.
- I will create a 3 different Graphs based on SalesData Collection




Tuesday, December 27, 2011

Monday, December 26, 2011

Creating LOV in ADF Application

Today i will cover how to create LOVs in Oracle ADF application.

Moving to Jdeveloper11g Your First ADF Form

In this Post we will create basic ADF form which is based of Oracle default HR schema's Table Employee later posts i will enhance this form by some LOVs and other stuff.

Saturday, December 24, 2011

Creating and displaying Popups in Oracle ADF

This post is about How to Create and display Popups in ADF application. In popups you can display different types of windows like Dialogs, NoteWindow,  Panel window etc
Creating and displaying Popups in Oracle ADF

Tuesday, August 9, 2011

C++ Condational Statements


  • In everyday life, we are often making decision.if the age of the person is above 60, then discount the ticket price to 40%
  • The above statement have element of decision making. E.g only if the age is above 60 reduce the       ticket by 40%. If the criteria is not matched the ticket shall not be reduced by 40%.
  • This decision making process is everywhere in our daily life.
Control Structure

Everyday programming requires three control structures:
  •   Sequence
  •   Selection
  •   Iteration

Sequence
  • Executing instructions in sequence
  • Working  down the pag
  • C / C++ follow this sequence of control until some other is specified via return, if, while, do / while, etc.
  •  Statements executed one after the other in order in which they are written    
Selection
  • The statement used for decisions in C++ language is known as the ‘if statement'
  • If statement has a simple structure and it helps  to choose among alternative courses of actions.
Structure of if statement
if (condition)
    statement (or group of statements);
The above statement means , if condition is true, then execute the statement or a group of statements.
Here the condition is a statement which explains the condition on which a decision will be made.
Example
 if ( the grade is greater than or equal to 60)
pass the student ;
We write the condition in parentheses, followed by a statement of group of statements to be executed.
We use braces { } to make a group (block) of a number of statements.
We put ‘{‘ before the first statement and ‘}’ after the last statement
Syntax
if (condition)
  {
      statement;
      statement;
       .
       .
      statement;
  }      
// if statement is only executed when the value is true
Example
Comparing the ages of two students. If the age of first student is greater than second, then display “ student 1 is older”
#include <iostream>
main()
{
   int age1, age2;
   age1 = 12;
   age2 = 10;
   if (age1 > age2)
     cout<<“Student1 is older:";
  }
 Realtional Operators
  Example
  Write a program in which users enter a number. If the user enter positive number, add one to the number else add two to the number.
 # include<iostream>
 main()
{
 int num, neg ,pos;
   cout<<“Please enter the no.”;
   cin>> num;
    if (num > 0)
    pos= pos +1;
    else
     neg= neg +2;
}
Conditional Operator
  • Closely related to if/else structure
  • ?: (Conditional Operator)
  • Only ternary operator in C/C++
  • Takes three operands
Operands with conditional operator form conditional expression
Operand 1– condition
Operand 2 – action if condition true
Operand 3 – action if condition false
Example
grade >= 60 ? “Passed”: “Failed”
Nested if Statements
Used for multiple conditions and take some actions accordingly to each condition. Example,
if (condition 1 )
                   Statement1
else  if (condition 2 )
            Statement2
            ...
else if (condition N )
            StatementN
else
            Statement N+1

EXACTLY 1 of these statements will be executed
Example of grades (if only)
  if (grade==‘A’)
    cout<<“Excellent”;
  if (grade==‘B’)
     cout<<“Very Good”;
  if (grade==‘C’)
     cout<<“Good”;
  if (grade==‘D’)
     cout<<“poor”;
  if (grade==‘F’)
     cout<<“Fail”;
    
‘if Statement” is computationally one of most expensive statements in program due to the fact that processor has to go through many cycles to execute them for a single decision.
To avoid this , and alternate of multiple if statements can be use of if/else statements.
//nested if/else
//printing remarks for each grade

    if (grade == ‘A’)
        cout<<“Excellent”;
    else
        if (grade == ‘B’)
            cout<<“Very Good”;
        else
            if (grade == ‘C’)
                cout<<“Good”;
            else
                if (grade == ‘D’)
                    cout<<“Poor”;
                else
                    cout<<“Failed”;

In the ‘nested if statements’ the nested else is not executed if the first if condition is true and the control goes out of the if block.
Switch Statement
Multiple- selection construct that is used in  multi decision  making in an efficient way and is easy to read and understand
Structure Switch Statement
switch (expression)
{
     case constant1:
        group of statements 1;
        break;
    case constant2:
        group of statements 2;
        break;
    .
    .
    .
    default:
        default group of statements 
}
How switch works?
switch evaluates expression and checks if it is equivalent to constant1, if it is, it executes group of statements 1 until it finds the break statement. When it finds this break statement the program jumps to the end of the switch selective structure
If expression was not equal to constant1 it will be checked against constant2. If it is equal to this, it will execute group of statements 2 until a break keyword is found, and then will jump to the end of the switch selective structure
Finally, if the value of expression did not match any of the previously specified constants (you can include as many case labels as values you want to check), the program will execute the statements included after the default: label, if it exists (since it is optional)
Example
// counting grades assigned
int aCount, bCount, cCount, dCount, fCount;
switch (grade)
{
    case ‘A’: case ‘a’:
        ++aCount;
    case ‘B’: case ‘b’:
        ++bCount;
    case ‘C’: case ‘c’:
        ++cCount;
    case ‘D’: case ‘d’:
        ++dCount;
    default:
        ++fCount;
}
break Statement
break statement causes program control to move to the first statement after the selection/ repetition structure
Switch cases would otherwise run togethe.

C++ DataTypes

What is a data type?

When we wish to store data in a C++ program, such as a whole number or a character, we have to tell the compiler which type of data we want to store. The data type will have characteristics such as the range of values that can be stored and the operations that can be performed on variables of that type.
  • A variable must have data type associated with it. It can have data type like integer, decimal numbers, character etc.
  • The variable of type integer stores integer values and a character type variable stores character value.
  • The primary difference between various data type is their size in memory depending on compilers.
  • These also affect the way they are displayed
  • Data types are reserve words of the language

C++ Fundamental Data Types

C++ provides the following fundamental built-in data types:
  • Boolean
  • Character
  • Integer
  • Floatin-point

Boolean Data Type

The Boolean type can have the value true or false. For example:
bool isEven = false;
bool keyFound = true;
If a Boolean value is converted to an integer value true becomes 1 and false becomes 0.
If an integer value is converted to a Boolean value 0 becomes false and non-zero becomes true.


Note that C++ also provides a string class that has advantages over the use of character arrays.

Character Type Example

charvars.cpp // demonstrates character variables

#include //for cout, etc.

void main()
{
char charvar1 = 'A'; //define char variable as character
cout << charvar1; //display character charvar1 = 'B'; //set char variable to char constant cout << charvar1; //display character }


Floating-Point Types

Floating point types can contain decimal numbers, for example 1.23, -.087. There are three sizes, float (single-precision), double (double-precision) and long double (extended-precision). Some examples:

float celsius = 37.623;
double fahrenheit = 98.415;
long double accountBalance = 1897.23;

The range of values that can be stored in each of these is defined by your compiler. Typically double will hold a greater range than float and long double will hold a greater range than double but this may not always be true. However, we can be sure that double will be at least as great as float and may be greater, and long double will be at least as great as double and may be greater.

typedef

C++ allows the definition of our own types based on other existing data types. We can do this using the keyword typedef, whose format is:

typedef existing_type new_type_name ;

where existing_type is a C++ fundamental or compound type and new_type_name is the name for the new type we are defining. For example:
1) typedef char C;
2) typedef unsigned int WORD;
3) typedef char * pChar;
4) typedef char field [50];
In this case we have defined four data types: C, WORD, pChar and field as char, unsigned int, char* and char[50] respectively, that we could perfectly use in declarations later as any other valid type:

Anonymous Unions

In C++ we have the option to declare anonymous unions. If we declare a union without any name, the union will be anonymous and we will be able to access its members directly by their member names. For example, look at the difference between these two structure declarations:

struct {
char title[50];
char author[50];
union {
float dollars;
int yen;
} price; // name price
} book;

struct {
char title[50];
char author[50];
union {
float dollars;
int yen;
}; // have no name
} book;

The only difference between the two pieces of code is that in the first one we have given a name to the union (price) and in the second one we have not. The difference is seen when we access the members dollars and yen of an object of this type. For an object of the first type, it would be:

book.price.dollars
book.price.yen

whereas for an object of the second type, it would be:

book.dollars
book.yen

Once again I remind you that because it is a union and not a struct, the members dollars and yen occupy the same physical space in the memory so they cannot be used to store two different values simultaneously. You can set a value for price in dollars or in yen, but not in both.

Data Types

Name Description Size Range
char character or small integer 1 byte signed:-128 to 127
unsigned: 0 to 255
bool Boolean values 1 byte signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
double Double precision floating point number. 8 bytes +/- 1.7e +/- 308 (~15 digits)

Now explanation with examples

Example 2


#include //This is pre-processor directive
void main ( ) //this tells the starting point of your program
{
int x ;
int y ;
int z ;
x = 10 ;
y = 20 ;
z = x + y ;

cout << " x = " ; //print the text on monitor cout << x ; cout << " y = " ; cout << y ; cout << " z =x + y = " ; cout << z ; }





Monday, August 8, 2011

C Sharp

C++ Loops

Loops are basically means to do a task multiple times, without actually coding all statements over and over again.
For example, loops can be used for displaying a string many times, for counting numbers and of course for displaying menus.
Loops in C++ are mainly of three types :-

1. 'while' loop
2. 'do while' loop
3. 'for' loop

The 'while' loop :-
Let me show you a small example of a program which writes ABC three(3) times.
01#include<iostream>
02
03int main()
04{
05  int i=0;
06  while(i<3)
07  {
08    i++;
09    cout<<"ABC"<<endl;
10  }
11}The output of the above code will be :-
ABC
ABC
ABC
The 'do while' loop :-
It is very similar to the 'while' loop shown above. The only difference being, in a 'while' loop, the condition is checked beforehand, but in a 'do while' loop, the condition is checked after one execution of the loop.

Example code for the same problem using a 'do while' loop would be :-
01#include <iostream>
02int main()
03{
04  int i=0;
05  do
06  {
07    i++;
08    cout<<"ABC"<<endl;
09  }while(i<3);} // main end






The 'for' loop :-
This is probably the most useful and the most used loop in C++.

The general syntax can be defined as :-
for(<initial value>;<condition>;<increment>)

To further explain the above code, we will take an example. Suppose we had to print the numbers 1 to 5, using a 'for' loop. The code for this would be :-
1#include<iostream>
2
3int main()
4{
5  for(inti=1;i<=5;i++)
6  cout<<i<<endl;
7}



    



















 

C++ Basic Program Construction

It is a simple C++ program 
#include <iostream>
using namespace std;

int main ()
{
 
  cout << "Every age has a language of its own: ";
  
  return 0;
}
 

C++ Variables



  • During programming we need to store data.
  • We store this data into place holders called variables.
  • Variables are location in memory for storing data.
  • In memory, there is a numerical address for each location of memory (block).
  • We give names to these locations and call them variable.
  • They are called variables because they contain different values at different times.
  • The variables in C may be started with a character or an underscore (_).Variables have to be declare and defined.Every variable has:
    • —Name
    • —Type
    • —Size
    • —Value
     
Declaration of variables:
  • In order to use a variable in C++, we must first declare it specifying which data type we want it to be.
  • The syntax to declare a new variable is to write the specifier of the desired data type. 
         datatype <variable name> 
         e.g      int x;   double y;   int  x,y,z;
     Values in  variables:
    • The variable having a name will need some value in it.  
    • To put some value in these boxes is known as assigning value to variables.
    •  In C++ language, we use assignment operator for this purpose

    Values in  variables:

    Assignment operator is a binary operator that has two operands.
    It must have a variable on left hand side and expression (that evaluates a single value) on right hand side.
    This operator takes the value on right hand side and stores it to the location labeled as the variable on left hand side.
        X=0;
    Z = x +4
    x +4 = Z   Wrong
    Caution !!!!!!!
    Don’t confuse (=) with the equal sign in Algebra …….NO

     

    Examples:
    2) int 4x = 16;
    3) bool @myBool;
    4) bool myBool;
    5) char char = 'B';
    6) char _char = 'B';
    7) double my-num = 4;
    8) double my_num = 4;
    9) int iAmNot4giving = 1231;
     Now
    (1) valid
    (2) not valid (doesn't start with a letter or an underscore
    (3) not valid for the same as (2)
    (4) valid
    (5) not valid because char is a reserved word
    (6) valid because _char is not the same as char
    (7) not valid because there is a dash within the variable name
    (8) valid
    (9) valid
    If you wish to declare a variable as constant (unchangable) put the const keyword in front of your variable declaration. This is a good idea when you want to ensure that you will not change something, even accidently. Also, you can declare global constants by using the #define keyword at the top of your program beneath the #include lines. When defining these constants you must initialize them with a value but the = sign is not needed. Also, these lines do not have semi-colons after them because they are in fact pre-processor directives, which means when your program is compiled, it finds all occurences of the constant in your code and replaces them with the number. It is an accepted rule to keep all your constants as upper case and your normal variables as mostly lower case.

    #define PI 3.141592564

    // A simple demonstration of variable usage
    #include <iostream.h>
    #include <math.h>

    #define PI 3.14159
    #define NAME "bob"

    int main(void) {
          const int hey = 3;
          int x = 0;
          char myChar = 'A';
          char myChar2 = 67;
          double blargh44 = 5.3243;
          int a = 2;
          int b = 3;
          int result = 0;
         
          cout << PI << endl;
          cout << NAME << endl;
          cout << hey << endl << endl;
          // hey = 4 // this would generate an error because hey is a       // constant
          // PI = 4.1 // this would also cause an error
         
          cout << "The value of x after initialization: " << x << endl;
          x = 42;
          cout << "The value of x after assignment: " << x << endl << endl;

          cout << myChar << endl;
          cout << myChar2 << endl << endl;

          cout << blargh44 << "\t" << blargh44 / 2 << endl;
          blargh44 = blargh44 + 4;
          cout << blargh44 << endl << endl;

          result = (int)pow(a, b);
          cout << a << " to the power of " << b << " is: " << result;
          cout << endl << endl;
         
          cout << b << endl;
          b += 3;
          cout << b << endl;
          b--;
          cout << b << endl;

          return 0;
    }

    output
    ------
    3.14159
    bob
    3

    The value of x after initialization: 0
    The value of x after assignment: 42

    A
    C

    5.3243  2.66215
    9.3243

    2 to the power of 3 is: 8

    *
    #include <iostream>
    using namespace std;
    int main()
    {
         int x = 15;
         cout << x << endl;
         return 0;
    }
    Here, int is the data type and x is the variable.



    Sunday, August 7, 2011

    C++ Basics

    Simple C++ Program
    Here is a very basic structure of a C++ program

    #include <iostream>
    using namespace std;
    int main ()
    {
    int i;
    cout << "a simple program: ";
    return 0;
    }

    Components of a program: 
    On line 1, the file is included in the file. Each time you start your compiler, the preprocessor is run. The preprocessor reads through your source
    code, looking for lines that begin with the pound symbol (#), and acts on those
    lines before the compiler runs.If your compiler is set up correctly, the angle brackets will cause the preprocessor to look for the file iostream in the directory that holds all the Header files for your
    compiler.The file iostream (Input-Output-Stream) is used by cout, which assists with writing to the screen.

    Line 3 begins the actual program with a function named main(). Every C++ program has a main() function.Function is a block of code that performs one or more actions.
    main(), like all functions, must state what kind of value it will return. The return value type for main() in the above stated program is void, which means that this function will not return any value at all.
    Comments In C++
    There are two ways for comments in C++
    1) // It is single line comment
    2) /* This is multiple line comment */
    Example
    #include <iostream>                   // include iostream for input and output
    using namespace std;
    int main ()               // main function starts
    {
    int i;                 // a variable of in type
    cout << "a simple program: ";
    return 0;
    /* it ia a multiple line comment
    * return 0 means this function
    * returns nothing at all
    */
    }
    Statements In C++
    Statement end with a semicolon(;), not with the end of a line

    Example
    Cout<<" it is a statement";

    Wednesday, June 22, 2011

    Change the Default Moodle Template

    Login the Moodle website as administrator.
    Moodle’s login links are at the top right hand side of the page or at the bottom of the Home page as shown in diagram1. Click on the Login link and Moodle’s login screen will be displayed in the Browser as shown in diagram 2.

    Diagram 1
    Enter the Administrators Login ID and Password set for the administrator at the time of installing Moodle. Then click the Login button. Alternatively, Login in as a Guest as shown in diagram 2.

    Diagram 2
    Once the Administrators Login ID and Password have been accepted the Moodle Administrator screen will be displayed in the Browser as shown in diagram 3.

    Diagram 3
    The Logout links are shown in diagram 3. Now access to all the functionality and features and Moodle will be accessible.

    Changing the default template for the Moodle installation

    In the left hand side column there is a set of Menu links as shown in diagram 4. Here is the - Menu item path - to reach the Moodle page from which the current template can be changed.

    Diagram 4
    The Menu Item path:
    Site-Administration -> Site Appearance -> Themes -> Theme Selector



    The theme selector page is in displayed in the Browser as shown in diagram 5.

    Diagram 5
    Adjacent to each theme there are two buttons as shown in diagram 6.

    Diagram 6
    Click the top button - Use for modern browsers - to install this theme to work in all modern Browsers.
    Click the bottom button - Use for old browsers - to install this theme to work in older version of Browsers.
    The button to use is normally chosen depending on which type of Browser is used by people who frequently use this Moodle website. When in doubt I suggest choosing - Use for modern browsers.
    In this case the Aavardak Lite theme was chosen. The top button - Use for modern browsers – was clicked on the theme change process with initiated and the output was as shown in diagram 7.

    Diagram 7
    The default Moodle theme was successfully changed.