ads

Wednesday, 27 July 2016

Use of ActionRegion,rerender,Param and Id






Controller Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class ActionReson3{


public List<opportunity> opplist{get;set;}
public opportunity opp_var{get;set;}
Public id Recid{get;set;}

public boolean ShowHide {get;set;}
    
    public ActionReson3() 
    {    
    ShowHide=False;
        opplist = [SELECT ID, Name,closedate FROM opportunity limit 5] ;
    }   
     
     public void getRecordID()
     {
     showHide= True;
       opp_var= [select name, accountid,closedate,ForecastCategoryName,Amount,leadsource from opportunity where id=:Recid ];
    
       
     }

    
}


Visualforce Page :-



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<apex:page controller="ActionReson3">
<apex:form >
<apex:pageblock Title="List of Opportunity">

<apex:pageblockTable value="{!opplist}" var="opp">
  <apex:column headerValue="Opportunity Name">
            
         <apex:actionregion >
        <apex:commandLink action="{!getRecordID}" value="{!opp.name}" rerender="pb" >
             <apex:param assignTo="{!Recid}" name="testuser" value="{!opp.id}"/>
             
         </apex:commandLink>
          </apex:actionregion>
          </apex:column>
         
           
            <apex:column headerValue="Close Date">
                <apex:outputLink value="/{!opp.id}" >{!opp.closedate}</apex:outputLink>
            </apex:column>
       
       
       
        </apex:pageblockTable>
        

    </apex:pageblock>
    
    
    <apex:pageBlock rendered="true" id="pb"  >
        <apex:pageBlockSection >
        <apex:outputField value="{!opp_var.name}"  />
        <apex:outputField value="{!opp_var.accountid}"/>
        <apex:outputField value="{!opp_var.closedate}"/>
        <apex:outputField value="{!opp_var.ForecastCategoryName}"/>
        <apex:outputField value="{!opp_var.Amount}"/>
        <apex:outputField value="{!opp_var.leadsource}"/>
        
</apex:pageBlockSection>
    
</apex:pageBlock>  


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



OutPut Screen :-

No comments:

Post a Comment