Skip to content

Instantly share code, notes, and snippets.

@joshbirk
Created November 9, 2011 18:38
Show Gist options
  • Save joshbirk/1352434 to your computer and use it in GitHub Desktop.
Save joshbirk/1352434 to your computer and use it in GitHub Desktop.
Controlling outputpanel with Apex
public with sharing class MyExtension {
public Boolean showPanel {get; set;}
public String inputValue {get; set;}
public MyExtension(ApexPages.StandardController controller) {
inputValue = '';
showPanel = true;
}
public PageReference controlPanel() {
showPanel = true;
if(inputValue == 'Customer - Channel') {
showPanel = false;
}
return null;
}
}
<apex:page showHeader="false" StandardController="Account" extensions="MyExtensions">
<apex:form id="myform">
<apex:actionFunction action="{!controlPanel}" name="controlPanel" rerender="mypanel" >
<apex:param name="inputValue" assignTo="{!inputValue}" value="" />
</apex:actionFunction>
<apex:inputField id="type" value="{!Account.Type}" onchange="controlPanel(document.getElementById('{!$Component.type}').options[document.getElementById('{!$Component.type}').selectedIndex].value);" />
<apex:outputPanel id="mypanel" layout="block" >
<apex:outputPanel rendered="{!showPanel}" ><apex:outputText value="{!inputValue}" />? {!showPanel}</apex:outputPanel>
</apex:outputPanel>
</apex:form>
</apex:page>
@abhinavguptas
Copy link

try renaming from extension.class to extension.java and outputpanel.page to outputpanel.xml/html to get syntax coloring.

@joshbirk
Copy link
Author

nifty!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment