2

If a user checks a checkbox to TRUE on page one of a force.com site, then on the next page the true section should render. This works as desired, however, if the user then goes back and checks FALSE and proceeds to the next page the true section is still rendering. Refreshing the page will update the rendering to be correct, however the refreshing is manual. Any Hints?

The issue I am encountering seems similiar to this http://bobbuzzard.blogspot.com/2011/02/visualforce-re-rendering-woes.html

However bossman's solution works for a single page, not sequential pages.

Checkbox Page

<apex:page standardController="Form__c" extensions="render_Controller" showHeader="false" standardStylesheets="false" sidebar="false">
<tr>
    <td>
        <apex:inputField value="{!Form__c.Yes_Checkbox__c}" 
                         required="true" 
                         styleClass="inputfieldwide"/>
    </td>
</tr>
<tr>
    <td>
         <apex:commandButton value="Next Page" action="{!nextpage}" styleClass="myButton"/>
    </td>
 </tr>

Next Page

<apex:page standardController="Form__c" extensions="render_Controller" showHeader="false" standardStylesheets="false" sidebar="false">
<apex:outputPanel rendered="{!Form__c.Yes_Checkbox__c = TRUE}">
    <tr class="blankrow">
    </tr>
    <tr>
        <td>
            <apex:outputText value="Yay! Render Sucess" styleClass="outputtextbold"/>
        </td>
    </tr>
    //etc...

Controller

public class render_Controller {

    public render_Controller (ApexPages.StandardController stdController) {

        form= (Form__c)stdController.getRecord();
        formId = stdController.getRecord().Id;
    } 

    public PageReference insertForm() {

        insert form;

        formId = form.Id;

        PageReference page = new pageReference(‘https://dev89-mom.cs15.force.com/render/startpage?id='+ formId);
        page.setRedirect(true);
        return page;
    }

    public PageReference nextpage() {

        update form;

        PageReference page = new pageReference('https://dev89-mom.cs15.force.com/render/nextpage?id='+ formId);
        page.setRedirect(true);
        return page;               
    }
}
6
+100

I've played around with your code a bit then I remembered you wrote "Refreshing the page will update the rendering to be correct, however the refreshing is manual." It happens because of caching mechanism. If you set cache="false" on your nextpage it will render correctly each time. In Force.com sites caching defaults to true. You can read manual from here.

<apex:page standardController="Form__c" extensions="render_Controller" showHeader="false" standardStylesheets="false" sidebar="false" cache="false">

should do what you want.

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.