function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Flint LockwoodFlint Lockwood 

Isses with reRender

Hi,

 

I am trying to re-render two pageblocks. The first pageblock displays a list of all Accounts and the second pageblock adds the User to add a new Account. The first pageblock re-renders with no issues. however, the second pageblock is not re-rendering. The value stays in the inputfield. Here is my code. Please help.

 

<apex:page standardController="Account" extensions="AllMyAccts">
    <apex:form >         
        <apex:pageBlock id="AcctListBlock"> 
            <apex:pageBlockTable value="{!Accounts}" var="a" columns="2">
                <apex:column value="{!a.Name}">
                </apex:column>
                <apex:column value="{!a.AnnualRevenue}"></apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:pageBlock id="newAcctBlock"> 
        	<apex:pageblocktable var="newacct" value="{!newAcctList}">
        		<apex:column >
        			<apex:inputField value="{!newacct.name}"></apex:inputField>
        		</apex:column>
        	</apex:pageblocktable>
        	
        </apex:pageBlock>
    	<apex:commandbutton value="New Account" action="{!newAccount}" reRender="AcctListBlock, newAcctBlock"/>
    </apex:form>
</apex:page>

 

Thank you in advance.

Best Answer chosen by Admin (Salesforce Developers) 
Flint LockwoodFlint Lockwood

Hi Singh, 

 

Thanks for the hint. I instantiated a new list of Accounts after the insert and it seem to work now. 

 

 

All Answers

Bindhyachal Kumar SinghBindhyachal Kumar Singh

Hi Flint

 

I think you can use apex form id instead of pageblocks id for rerender page.

 

Use following modified code:

 

<apex:page standardController="Account" extensions="AllMyAccts">
    <apex:form id="AllBlock">         
        <apex:pageBlock> 
            <apex:pageBlockTable value="{!Accounts}" var="a" columns="2">
                <apex:column value="{!a.Name}">
                </apex:column>
                <apex:column value="{!a.AnnualRevenue}"></apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:pageBlock> 
        	<apex:pageblocktable var="newacct" value="{!newAcctList}">
        		<apex:column >
        			<apex:inputField value="{!newacct.name}"></apex:inputField>
        		</apex:column>
        	</apex:pageblocktable>
        	
        </apex:pageBlock>
    	<apex:commandbutton value="New Account" action="{!newAccount}" reRender="AllBlock"/>
    </apex:form>
</apex:page>

 

Flint LockwoodFlint Lockwood

Hi Singh, 

 

Thank for your reply. But the second page block still failed to re-render.

Bindhyachal Kumar SinghBindhyachal Kumar Singh

Hi flint 

 

can you post code of extension also.

 

I think  newAcctList name is display every time in inputfield.

 

If you want to reset value of inputfield then set null to newacctlist after performing action of command button.

Flint LockwoodFlint Lockwood

Hi Singh, 

 

Thanks for the hint. I instantiated a new list of Accounts after the insert and it seem to work now. 

 

 

This was selected as the best answer