Trusted Contributor
Rajesh Shah
Posts: 296
Accepted Solution
actionSupport rerender problem
[ Edited ]

I am having a problem using action Support and rerendering a section.

Following is the page code.

<apex:form id="AccountForm">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}" />
<apex:commandButton value="Custom Save" action="{!saveCustom}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!Account.Name}" />
<apex:inputField required="true" value="{!Account.AccountNumber}" />
<apex:inputField value="{!Account.Industry}" />
<apex:inputField value="{!Account.Has_Shipping_Address__c}" >
<apex:actionSupport event="onclick" action="{!changeShippingSection}" rerender="AccountForm" status="StatusChange"/>
<apex:actionStatus startText="Updating page ..." id="StatusChange"/>
</apex:inputField>


</apex:pageBlockSection>

<apex:pageBlockSection id="ShippingAddressSection" rendered="{!shippingSection}" Title="Shipping Address" >
<apex:inputField value="{!Account.ShippingCity}" />
<apex:inputField value="{!Account.ShippingState}" />
<apex:inputField value="{!Account.ShippingCountry}" />
<apex:inputField value="{!Account.ShippingPostalCode}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

 In the above code, when the Has Shipping Address field is clicked, the Shipping Address section should be visible. Following is the corresponding controller code

public void changeShippingSection()
{
shippingSection = account.Has_Shipping_Address__c;
//return null;
}

 It works perfectly fine when I AccountForm as Id in the rerender attribute. But if I put shippingAddressSection as Id in the attribute, no change happens even though function gets called.

Is this the intended behaviour or am I missing something?

 

 

 

Message Edited by Rajesh Shah on 10-08-2009 07:47 PM
Trusted Contributor
Rajesh Shah
Posts: 296
Re: actionSupport rerender problem
Any thoughts on the above?
Trusted Contributor
Edwin1
Posts: 360
Re: actionSupport rerender problem

Hi.. try using an outputpanel and rerender the outputpanel, place your pageblocksection inside the outputpanel..

I too faced a similar issue, but i do not remember the cause... Maybe, the pageblocksection in turn has a rerender which causes the problem..

 

Cheers!!

ForceTree.com-Visualforce Tips and tricks (with code samples) - Click here
Trusted Contributor
Rajesh Shah
Posts: 296
Re: actionSupport rerender problem
[ Edited ]

Found the solution :smileyhappy:: (thanks to Sorna and Edwin)

It seems that if the component that I am rerendering has a rendered attribute, it doesn't works. So I had to wrap the pageBlockSection in an outputPanel with no rerenderd attribute. Now I just rerender the outputPanel. Attached is the updated code .

<apex:form id="AccountForm">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}" />
<apex:commandButton value="Custom Save" action="{!saveCustom}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!Account.Name}" />
<apex:inputField required="true" value="{!Account.AccountNumber}" />
<apex:inputField value="{!Account.Industry}" />
<apex:inputField value="{!Account.Has_Shipping_Address__c}" >
<apex:actionSupport event="onclick" action="{!changeShippingSection}" rerender="ShippingAddressPanel" status="StatusChange"/>
<apex:actionStatus startText="Updating page ..." id="StatusChange"/>
</apex:inputField>

</apex:pageBlockSection>
<apex:outputPanel id="ShippingAddressPanel">
<apex:pageBlockSection id="ShippingAddressSection" rendered="{!shippingSection}" Title="Shipping Address" >
<apex:inputField value="{!Account.ShippingCity}" />
<apex:inputField value="{!Account.ShippingState}" />
<apex:inputField value="{!Account.ShippingCountry}" />
<apex:inputField value="{!Account.ShippingPostalCode}" />
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>

 

 

 

 

 

 

Message Edited by Rajesh Shah on 10-09-2009 04:47 PM