Wednesday 1 July 2015

ApexPages.currentPage().getParameters().get('id')

Basically all developer using  the above code , I had a confusion when I have used this first time . At that time apex pdf does not have clear definition of methods and classes .
This is the concept of method chaining .

I have divided into 3 steps to know detail concept behind it .

Step1:-
ApexPages is a class in which CurrentPage is a method which returns a PageReference .

Click on the link ApexPages_methods to know about the method and other methods as well .

Step2:-
As step one returns a PageReference  now we can use PageReference method in step2
ApexPages.currentPage().getParemeters()
getParemeters() is a method in PageReference class which retuns a Map .

Click on the link PageReference_methods to know about the method and other methods as well .

Step 3 :-
ApexPages.currentPage().getParemeters().get()/put()

As step2 returns Map so we can use map methods in step3 .
Click on the link Map_methods to know about the method and other methods as well .

What else we can do with it : -

1.You can get the full url by using belwo code :

ApexPages.currentPage().getUrl();

2.You can get the IP address from belwo code .

ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');







4 comments:

  1. Hi manoj,
    can u explain it in brief.you have told which class contains which methods but you have not explained what actually the statement do.
    Thanks in advance.

    ReplyDelete
    Replies
    1. Ok I will modify the blog to add some thing related to that .This is very common to sales force to interact with page URL .

      Delete