I want a simple way in Visualforce to expose part of the page in response to a button click. This should be easy, but it is giving me more trouble than anything I've done with VF to date.
After reading How can an apex:pageBlockSection be rerendered I wrapped the re-render section in a div tag, but that didn't help at all.
Here is a much-simplified version of the page:
<apex:page controller="ProvisioningController">
<apex:form >
<apex:commandButton action="{!showActivationForm}" value="Activate" rerender="activationForm"/>
</apex:form>
<div id="activationForm">
<apex:form rendered="{!activationFormIsVisible}">
<p>Show some more fields here...</p>
<apex:commandButton action="{!updateDb}" value="Whatever, Man"/>
</apex:form>
</div>
</apex:page>
And the relevant controller code:
public with sharing class ProvisioningController {
public Boolean activationFormIsVisible { get; private set; }
public ProvisioningController() {
activationFormIsVisible = false;
}
public PageReference showActivationForm() {
this.activationFormIsVisible = true;
return ApexPages.currentPage();
}
}
It seems like I shouldn't even need to use my controller for this kind of task.