Created
March 8, 2018 13:04
-
-
Save thams017/c44780f64e16f1f34c77051b9de050a9 to your computer and use it in GitHub Desktop.
This page will hide and show the output panel when a button is clicked.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RenderExampleClass { | |
/****get set varaible which will carry the true or false condition to the page****/ | |
public Boolean showPanelHistory{ get; set;} | |
/****get set varaible which carry the list of accounts to the page****/ | |
public Account accountList{ get; set;} | |
/****Acction method which is used in the page which acts like switch*****/ | |
public PageReference showpanel(){ | |
if(showPanelHistory == false) { | |
showPanelHistory = true; | |
} | |
else if(showPanelHistory == true){ | |
showPanelHistory = false; | |
} | |
return null; | |
} | |
/***Example methos that to query the list of accounts***/ | |
public void accountList(){ | |
accountList = [ | |
SELECT Id, | |
Name, | |
Type | |
FROM Account | |
]; | |
} | |
/***** Setting up showPanelHistory = false directly in constructor | |
so when page loads the switch willl be in false condition********/ | |
public RenderExampleClass() { | |
showPanelHistory = false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="RenderExampleClass"> | |
<apex:form > | |
<apex:commandButton value="Show Section" action="{!showpanel}" rerender="showpanel"> | |
</apex:commandButton> | |
<apex:outputPanel id="showpanel"> | |
<apex:outputPanel rendered="{!showPanelHistory}"> | |
<apex:pageBlock title="List of Accounts"> | |
<apex:pageBlockSection > | |
<apex:outputField value="{!accountList.Name}"/> | |
<apex:outputField value="{!accountList.Type}"/> | |
</apex:pageBlockSection> | |
</apex:pageBlock> | |
</apex:outputPanel> | |
</apex:outputPanel> | |
</apex:form> | |
</apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment