Showing posts with label apex tutorials. Show all posts
Showing posts with label apex tutorials. Show all posts

Sunday, 9 July 2017

Program to create picklist field in VF page using arrays in Apex

Program to create picklist field in VF page using arrays in Apex

Picklist using select option from apex:

<apex: select list size=”1”>
<apex; select option item label =” Java” item value=” scup”/>
<apex: select option item label=” SF” item value =” SDFC”/>
<apex: select list>

In the apex program we can create same select option using an object select option.

Select option op1=new select option (item value, item label);

Public class select Example {
Public select option [] my options {set; get;}
Public select Example ()
{

Select option op3=new select option (‘null’ ‘-None’);
Select option op1= new select option (‘one’ ‘Jan’);
Select option op2= new select option (‘two’ ‘Feb’);

My option=new select option [] {op3, op1, op2};
         }
  }

<apex: page controller =” select Example”>
<apex: from>
<apex: select list size=”1”>
<apex: select option value=” {! my options}”> </apex: select option>
</apex: select list>
<apex: select list size=”1”>
<apex: select option item label =” Java” item value =” Java”> </apex: select option>
<apex: select option item label =” SFDC” item value =” SF”> </apex: select option>
</apex: select list>
</apex: from>
</apex: page>

Introduction to Class Variables & Methods and Objects

Introduction to Class Variables & Methods and Objects 

Class variables: 

The variables in the class should specify the following properties when they are defined. 

1.Optional: modifiers such as public or final as well as static. 
2.Required: the data type of the variable, such as string or Boolean. 
3.Optional: the value of the variable 
4.Optional: the name of the variable    

Syntax: 
              [public |private| protected |global| final] [static]
                             Data - type variable – name 
Ex: 
           Private static final integer My-INT; 
           Private finale integer I = 1;

Class methods:

To define a method, specify the following. 
1.optional:  modifiers, such as public or protected.
2.Required:  the data type of the value returned by the method, such as string or integer. Use void if the method does not return value. 
3Required:  A list of input parameters for the method, separated by common, each preceded by its data type, and enclosed in parentheses (). If

There are no parameters, use a set of empty parentheses. 
A method can only have 32 input parameters. 

4.Required:  the body of the method, enclosed in braces {}.
All the code for the method, including any local variable declarations, is contained here.

Syntax: 
        (public |private | protected | global) [over ride] [static]   
            Data-type method- name (input parameters)
         {
         // the body of the method.
          }
Ex1: 
          Public static Integer get Int ()
 {
    return – MY INT ; 
      }
Ex2: 
        Public class example 
        {
          Public Integer Show (Integer age)
         {
           System debug (‘My age is’ tag);
             }
         }

Object:


Object is an instance of the class. This as both state and behavior.
memory for the data members our allocated only when you create an object   

Syntax: 
             Class name object name = New class name ();
                   ↓                   ↓                                            ↓
              Object        variable name                        constructor 

Ex:    
         Class example 
          {
             //code 
            }

          Example e = new example ();

Tuesday, 27 June 2017

Define A Class in Apex

Define A Class in Apex 

Class:

 Class is a collection of data members and methods.
                  Ex:  class student
                         {
                           Integer no;
                           String name;     →                    these are data members of the class
                           Public void gets Details ()
                           {
                             System. Debug (‘roll no’ +no);
                             System. Debug (‘name ‘+name);
                                       }
        }
EX2 :  class employee
          {
            Integer exp ;
            String deportment;
            Void show ()
             {
                //write the logic
               }
           }
   

To define an apex class, specify the following.


a)       Access modifiers:
                                               I.            You must use one of the access modifiers for top level class. (public or global)
                                             II.            You do not have to use access modifiers in the declaration of inner classes.
b)      Optional definition modifiers such as virtual, abstract.
c)       Required: the key word class followed by the class name.
d)      Optional extensions: AND/OR implementation
   
Syntax:
                     Private| public | global [virtual | abstract| with sharing | more]  
                      Class  class name [implements interface Name list|
                     (none)] [extends class name |(none)]
                    {
                           // the body of class

                                                               }

Saturday, 10 June 2017

Apex Introduction and Overview

Apex Introduction and Overview

Apex is strongly typed object oriented programming language
A.It allows the develops execute flows and transaction control statement.
B.Apex enables developers to add business logic to most system events like button click related records updates and visual force pages.
C.Apex languages
1.       Integrated: it provides built in support for DML calls.
2.       Inline salesforce object query language:
3.       Easy to use.
4.       Easy to test.
5.       Version
6.       Multi-tenant aware

When should I use apex:
A.      To create email services
B.      Create web services
C.      Perform complex validation over multiple objects.
D.      To create complex business processes that are not supported by work flow.
E.       Create custom transaction logic
F.       Attach custom logic to another operation.

How does apex work:

All apex programmers entirely on-demand on force.com platform.

When the developer writes and server Apex code to the platform

A.First the platform application serves compiles the code into abstract set of instruction that can be understood by apex run time interpreter.

B.The compile code is stored to meta data.

C.When the end uses triggers the execution of apex by clicking button visual force page the application services retrieves the compiled instructions from the meta data and send them to run time interpreters before returning the result.