+ Start a Discussion
miko Leemiko Lee 

how to show a pageBlock using outputLink value

Hi guys, I want to show a pageBlock in the same VF page only after i press the outputLink. Hence, what should I put in outputLink so that when I press the link, it will direct me to the pageBlock that I want. Or there are still another way except from outputLink.

Now, the code below show the <apex:pageBlock title="Examination Result"> is stick with <apex:pageBlock title="Grade and Result" >. But what I want is after I press View, it will show the Grade and Result in the same VF page but without Examination Result pageBlock.

<apex:pageBlock title="Examination Result" rendered="{!showRecords}" >
	    <!--apex:pageBlock title="Examination Result"-->
	        <table>
	            <tr>
	                <td><apex:outputLabel >Current Date:</apex:outputLabel></td>
	                <td><apex:outputText value="{!myCurrentDate}"/></td>
	            </tr>
	         </table>   
		    <apex:outputPanel>	    
				    <apex:pageBlockTable value="{!resultList}" var="rl">
				    	
					    <apex:column value="{!rl.Exam_Date__c}"/>
					    <apex:column value="{!rl.Exam_Token__r.Exam_Type__c}"/>
					    <apex:column value="{!rl.Exam_Token__r.Proficiency_Level__c}"/>
					    <apex:column value="{!rl.Exam_CorrectAns__c}"/>
					    <apex:column value="{!rl.Exam_Token__r.Total_Question__c}"/>
					    <apex:column value="{!rl.Exam_Score__c}"/>
				        <apex:column >
				        	<apex:facet name="header">Grade and Result</apex:facet>
				        	<apex:outputLink value="/" >View</apex:outputLink>		                  
				        </apex:column>
				    </apex:pageBlockTable>
		    </apex:outputPanel > 
		</apex:pageBlock>


			<apex:pageBlock title="Grade and Result" >
			    <apex:outputPanel id="myPreviousResult">
			        <h3>Hello, {!$User.FirstName} {!$User.LastName}</h3>        
			    </apex:outputPanel>
			                 
			</apex:pageBlock>
Thanks!!!
Best Answer chosen by miko Lee
DeveloperSudDeveloperSud
Hi Miko,

I think instead of using outputlink you can use a commandLink for this.
Now to show the pageblock with title 'grade and result' use a render attribute and make this false by default , make it true when the user click on the link in the page.The same can be done with the pageblock with title 'Examination Result'. I just make a demo code for it . Hope this will help you to achieve the functionality for your page. Refer this and let us know of this helps. Thanks.
 
<apex:page controller="sample1x">
<apex:form >
<apex:pageBlock rendered="{!NOT(checkval)}" id="pb1" title="The first pageblock">
</apex:pageBlock>

<apex:pageBlock rendered="{!checkval}" id="pb2" title="The second pageblock">
</apex:pageBlock>

<apex:commandLink value="Click" action="{!test}"/>
</apex:form>
</apex:page>
 
public with sharing class sample1x {

   public boolean checkval{get;set;}

   public  sample1x(){
   
   checkval=false;
   
   }
   public pageReference test(){
   checkval=true;
   return null;
   
   }

}

 

All Answers

DeveloperSudDeveloperSud
Hi Miko,

I think instead of using outputlink you can use a commandLink for this.
Now to show the pageblock with title 'grade and result' use a render attribute and make this false by default , make it true when the user click on the link in the page.The same can be done with the pageblock with title 'Examination Result'. I just make a demo code for it . Hope this will help you to achieve the functionality for your page. Refer this and let us know of this helps. Thanks.
 
<apex:page controller="sample1x">
<apex:form >
<apex:pageBlock rendered="{!NOT(checkval)}" id="pb1" title="The first pageblock">
</apex:pageBlock>

<apex:pageBlock rendered="{!checkval}" id="pb2" title="The second pageblock">
</apex:pageBlock>

<apex:commandLink value="Click" action="{!test}"/>
</apex:form>
</apex:page>
 
public with sharing class sample1x {

   public boolean checkval{get;set;}

   public  sample1x(){
   
   checkval=false;
   
   }
   public pageReference test(){
   checkval=true;
   return null;
   
   }

}

 
This was selected as the best answer
miko Leemiko Lee
Thank you @DeveloperSud... This is what exactly I want !!!!