ads

Thursday, 28 July 2016

Parameter Passing Between Two Visualforce Page Using URL





Controller Code of First VF Page: -



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public class gettingURLid
{
public Account Accinsert{get;set;}
public pagereference save()
    {
        insert accinsert;
       
        Pagereference page=new Pagereference('/apex/refpage?id='+accinsert.id);
        Page.setredirect(true);
        return page;
    }

public gettingURLid()
{
Accinsert=new account();
}
}

Code For First VF Page :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<apex:page controller="gettingURLid">
<apex:form >
<apex:pageBlock >

<apex:pageBlockButtons >
  <apex:commandButton action="{!save}" value="Save"/>
 </apex:pageBlockButtons>
 
<apex:pageblockSection >


<apex:inputField value="{!accinsert.name}"/>
<apex:inputField value="{!accinsert.type}"/>
<apex:inputField value="{!accinsert.phone}"/>



</apex:pageblockSection>
</apex:pageBlock>

</apex:form>
</apex:page>

OutPut Screen  For First VF Page:-




Controller Code of Second VF Page: -



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
public class refpage
{

//public string posId;
public account acc_var{get;set;}

public refpage()
    {
     string postId;
        postId=apexpages.currentpage().getparameters().get('id');
       
      
        acc_var= [select name, type from account where id= :postID];
        
        
    }


}


Code For Second VF Page :-



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<apex:page controller="refpage">
<apex:form >
<apex:pageBlock >

<apex:pageblockSection >

Hello customer <br></br>Your Account name is:-  <h1>{!acc_var.name} </h1>
<br></br>
Type :- <h1>{!acc_var.type}</h1>


</apex:pageblockSection>
</apex:pageBlock>

</apex:form>

</apex:page>


OutPut Screen  For Second VF Page:-


No comments:

Post a Comment