2

In the app I'm working on I have a Visualforce page with a few pageBlocks and other fancy stuff. In one of the pageBlocks I have a pageBlockTable with a few columns that get values from the controller.

What I should have: once I click a button, I want the table to refresh(rerender) to show the updated values.

However, this is not happening. After clicking a button, both buttons on that row become disabled(as they should), but rows don't update unless I refresh the whole page.

Visualforce code(many parts omitted to make reading easier)

<apex:form >
    <apex:pageBlock id="theBlock">
        ...
        <apex:pageBlockSection title="Deals" id="dealsBlock">
            <apex:outputPanel id="tableBlock">
                <apex:pageblockTable value="{!tableRows}" var="d">
                    <apex:column headerValue="Action">
                        <apex:commandButton value="Accept" disabled="{!d.buttonsAreDisabled}" action="{!d.acceptDeal}" reRender="dealsBlock"/>
                        <apex:commandButton value="Reject" disabled="{!d.buttonsAreDisabled}" action="{!d.rejectDeal}" reRender="dealsBlock"/>
                    </apex:column>
                    <apex:column value="{!d.theStatus}" headerValue="Status"/>
                    <apex:column value="{!d.theDeal.Name}"/>
                    <apex:column value="{!d.theDeal.Valid_Through__c}"/>
                    <apex:column value="{!d.theDeal.Available_Deals__c}"/>
                </apex:pageblockTable>
            </apex:outputpanel>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

Debugging shows that methods are being called and executed and the records that they create are effectively being created and saved.

I also tried changing reRender values to both theBlock and dealsBlock, but nothing happens. Controller still does everything it should, buttons become disabled as they should, but other columns do not show updated values.

I also tried using <apex:actionSupport>, but then even methods in the controller didn't execute.

EDIT

Controller:

public class DealViewerController {
    public class aTableRow {
        public Deal__c theDeal { get; set; }
        public String theStatus { get; set; }
        public Boolean buttonsAreDisabled { get; set; }
        //other properties and constructor for inner class

        private void initDealAction(boolean isAccepted) {
            Deal_Action__c da = new Deal_Action__c();
            //some basic initialization of this object
            insert da;
        }

        public void rejectDeal() {
            initDealAction(false);
        }

        public void acceptDeal() {
            initDealAction(true);
        }
    }
  • Can't spot anything wrong here. Would it be possible to share your controller function(s)? – FrankZ Nov 12 '14 at 14:07
  • Add a <apex:pageMessages id="msgs"> tag and serenader that as well. Could be there is an error happening in the controller that is not being displayed??? What if you rerender the tableBlock? – Eric Nov 12 '14 at 14:09
  • @FrankZ see edit please. But as I already mentioned, that Deal_Action__c is being created and saved properly – Novarg Nov 12 '14 at 14:25
  • @Eric what sort of error? Everything what should happen is happening(except for updating the fields in the table). And if I rerender the tableBlock nothing happens. Does exactly same thing as with dealsBlock – Novarg Nov 12 '14 at 14:27
  • Found it. I didn't update the property in aTableRow class, so I was still having old values. And they were changing after refresh because controller was loading new values. – Novarg Nov 12 '14 at 14:44
4

It could be because you are not recalculating the tableRows.

You could check if the tableRows list is being repopulated after you are done with whatever you are doing in your action. Perhaps you are just populating the tableRows in the constructor.

Or you could also repopulated the tableRows in its getter. So that every time the getter is called, it fetches the latest values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.