This is my VF Page :
<apex:page standardcontroller="Contact" extensions="CreateContactController" >
<apex:sectionHeader title="Create Contact" subtitle="from Account..."/>
<apex:form >
<apex:pageblock >
<apex:pageblockbuttons location="bottom">
<apex:commandbutton action="{!save}" value="Save" />
<apex:commandbutton action="{!cancel}" value="Cancel" />
</apex:pageblockbuttons>
<apex:pageblocksection title="Personal Information">
<apex:inputfield value="{!Contact.FirstName}" />
<apex:inputfield value="{!Contact.LastName}" />
</apex:pageblocksection>
<apex:pageblocksection title="Contact Information">
<apex:inputfield value="{!Contact.Email}" />
<apex:inputfield value="{!Contact.Phone}" />
</apex:pageblocksection>
<apex:pageblocksection title="Account Information" columns="1" id="AccInfo">
<apex:inputfield value="{!Contact.AccountId}">
<apex:actionsupport action="{!renderinfo}" event="onchange" rerender="AccInfo"/>
</apex:inputfield>
<apex:inputfield value="{!Contact.Account.Phone}" />
<apex:inputfield value="{!Contact.Account.Website}" />
</apex:pageblocksection>
<apex:pageblocksection >
<apex:outputText rendered="{!called}"> <!--HERE-->
ABCDEF
</apex:outputText>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
This is my controller
public with sharing class CreateContactController {
private ApexPages.StandardController ctrl;
public Boolean called{get;set;}
public CreateContactController(ApexPages.StandardController controller) {
ctrl = controller;
called = false;
}
public void renderinfo()
{
System.debug('~~~~ METHOD BEGINNING');
called = true;
Contact c = (Contact)ctrl.getRecord();
//c.addError('test');
if(!String.isBlank(c.AccountId))
{
c.Account = [SELECT ID,Phone,Website FROM Account WHERE ID = :c.AccountId];
}
else
{
c.Account = null;
}
System.debug('~~~~ c.Account = '+c.Account);
System.debug('~~~~ called = '+called);
}
}
Issue :
There is a boolean property "called" that determines whether to render the output text or not (highlighted in the code).
Intially the text("ABCDEF") will not be displayed as I am setting the "called" to be false in the controller.
After invoking the renderinfo() method also the outputtext is not getting rendered (aka..the change in "called"'s value from "false" to "true" after the completion of renderinfo() method is not shown in the VF)
From debug logs though, I could see that "called"'s value is indeed true.
Can someone tell me why it is happening ?