There are only two fields in my page, one conditionally rendering the other.
Everything works as expected (checkbox toggles the display of the date field) if I set the Boolean value to true from my constructor.
But if set to false, and I try to toggle the checkbox from UI, I get "An internal server error has occurred. An error has occurred while processing your request. The salesforce.com support team has been notified of the problem." In debug logs I get nothing worth mentioning.
Here is my code: I apologize if it is something silly I am missing, but I just could not find it out.
<apex:page controller="testctrl" docType="html-5.0">
<apex:form >
<apex:pageBlock id="myPgBlk">
<apex:pageBlockSection title="My Pageblocksection" columns="1">
<apex:inputCheckbox label="Choose a custom date" value="{!chk}">
<apex:actionSupport event="onchange" rerender="myPgBlk" action="{!NULL}"/>
</apex:inputCheckbox>
<apex:input label="Cust Date" value="{!custDate}" type="date" rendered="{!chk == true}"/>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class testctrl {
public Boolean chk {get; set;}
public Date custDate {get; set;}
public testctrl() {
chk = false; // works fine if initialized with true
custDate = Date.today();
}
}
Best Answer
The issue is, you are calling a Controller action as Null. Remove the action attribute
action="{!NULL}"
from the<apex:actionSupport
element. It will work.VF Page
Controller
Screenshots:
It seems there are some issues with HTML 5 elements. Meanwhile, I got it working by wrapping the checkbox with an actionRegion tag.