function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Neethu DivyaNeethu Divya 

List of records using links in visualforce page

Hi,
I am trying to develop a visual force page in which the list of records should be displayed on the click of the object name.
The same functionality is working fine with the check box,but i want it to be done with links.
This is my code which is displaying the list of records when the check box is checked.

<apex:page controller="multirecords" >
<apex:form >
<apex:messages />
<apex:pageBlock id="theBlock">                                                    
<apex:inputCheckbox value="{!Check}" required="false">
<apex:actionSupport event="onclick" rerender="theBlock"/>
</apex:inputCheckbox>
         
<apex:outputLabel value="View Job Application"  style="font-weight:bold;"></apex:outputLabel>&nbsp;<br/>
<apex:inputCheckbox value="{!Check1}" required="false">
<apex:actionSupport event="onclick" rerender="theBlock"/>
</apex:inputCheckbox>
<apex:outputLabel value="View Positions"  style="font-weight:bold;"></apex:outputLabel>&nbsp;<br/>
<!--  <apex:commandLink value="Positions"  action="{!display}" id="position" rendered="{!inputmode}">
<apex:actionSupport event="onclick" rerender="theBlock"/>
</apex:commandLink>-->
           
<apex:pageBlock title="Job Application" rendered="{!(Check == true)}">          
<apex:pageblockTable value="{!ja}" var="a">
<apex:column value="{!a.Name}"/>
</apex:pageblockTable><br/>
</apex:pageBlock>                                
<apex:pageBlock title="Position" rendered="{!(Check1 == true)}">                
<apex:pageblockTable value="{!pos}" var="p">
<apex:column value="{!p.Name}"/>
</apex:pageblockTable>
</apex:pageBlock>     
</apex:pageBlock>    
</apex:form>
</apex:page>

---Controller--
public class multirecords {

      
    public List<Job_Application__c> ja {get; set;}
    public List<Position__c> pos {get; set;}
    public List<Review__c> rev {get; set;}
    public boolean Check{get;set;}
    public boolean Check1{get;set;}
    public boolean Check2{get;set;}
    public multirecords()
    {
       
       ja = [SELECT Name FROM Job_Application__c];
       pos = [SELECT Name FROM Position__c];
    }
          

}
Best Answer chosen by Neethu Divya
Grazitti TeamGrazitti Team
Hi Neethu,

Use the following code to get List of records using links in visualforce page. Hope this will help you.


CONTROLLER--
public class multirecords {   
    public List<Job_Application__c> ja {get; set;}
    public List<Position__c> pos {get; set;}
    public List<Review__c> rev {get; set;}
    public boolean Check{get;set;}
    public boolean Check1{get;set;}
    public boolean Check2{get;set;}
   
    public multirecords(){
       ja = [SELECT Name FROM Job_Application__c];
       pos = [SELECT Name FROM Position__c];
    }
   
    Public void showPositions(){
       if(Check1 == true){Check1 = false;}
       else{Check1 = true;}
    } 
     Public void showJobApp(){
       if(Check2 == true){Check2 = false;}
       else{Check2 = true;}
    } 
}

APEX PAGE--
<apex:page controller="multirecords" >
<apex:form >
<apex:messages />
    <apex:pageBlock >
   <apex:commandLink value="Positions" action="{!showPositions}" reRender="PGB2"/><br/>
   <apex:commandLink value="Job applications" action="{!showJobApp}" reRender="PGB2"/><br/>
    </apex:pageBlock>
 
    <apex:outputPanel id="PGB2">
   <apex:pageBlock id="position" rendered="{!Check1}">
    <apex:pageblockTable value="{!pos}" var="p">
     <apex:column value="{!p.Name}"/>
    </apex:pageblockTable>
   </apex:pageBlock>
   <apex:pageBlock id="jobApp" rendered="{!Check2}">
    <apex:pageblockTable value="{!ja}" var="j">
     <apex:column value="{!j.Name}"/>
    </apex:pageblockTable>
   </apex:pageBlock>      
    </apex:outputPanel> 
</apex:form>
</apex:page>


And don't forget to mark this answer as best, if answer this helps you :-)


--
Regards,
Grazitti Team
Web: www.grazitti.com

All Answers

Grazitti TeamGrazitti Team
Hi Neethu,

Use the following code to get List of records using links in visualforce page. Hope this will help you.


CONTROLLER--
public class multirecords {   
    public List<Job_Application__c> ja {get; set;}
    public List<Position__c> pos {get; set;}
    public List<Review__c> rev {get; set;}
    public boolean Check{get;set;}
    public boolean Check1{get;set;}
    public boolean Check2{get;set;}
   
    public multirecords(){
       ja = [SELECT Name FROM Job_Application__c];
       pos = [SELECT Name FROM Position__c];
    }
   
    Public void showPositions(){
       if(Check1 == true){Check1 = false;}
       else{Check1 = true;}
    } 
     Public void showJobApp(){
       if(Check2 == true){Check2 = false;}
       else{Check2 = true;}
    } 
}

APEX PAGE--
<apex:page controller="multirecords" >
<apex:form >
<apex:messages />
    <apex:pageBlock >
   <apex:commandLink value="Positions" action="{!showPositions}" reRender="PGB2"/><br/>
   <apex:commandLink value="Job applications" action="{!showJobApp}" reRender="PGB2"/><br/>
    </apex:pageBlock>
 
    <apex:outputPanel id="PGB2">
   <apex:pageBlock id="position" rendered="{!Check1}">
    <apex:pageblockTable value="{!pos}" var="p">
     <apex:column value="{!p.Name}"/>
    </apex:pageblockTable>
   </apex:pageBlock>
   <apex:pageBlock id="jobApp" rendered="{!Check2}">
    <apex:pageblockTable value="{!ja}" var="j">
     <apex:column value="{!j.Name}"/>
    </apex:pageblockTable>
   </apex:pageBlock>      
    </apex:outputPanel> 
</apex:form>
</apex:page>


And don't forget to mark this answer as best, if answer this helps you :-)


--
Regards,
Grazitti Team
Web: www.grazitti.com

This was selected as the best answer
Neethu DivyaNeethu Divya
thank u..
Grazitti TeamGrazitti Team
Hi,

If it was helpful, can you mark this as anwer.

--
Regards,
Grazitti Team
Web: www.grazitti.com