2

Im trying to do a custom simple save and new method in a custom controller. Basically its just a simple form for nominations with a table above it of all the already submitted nominations and the action is called nominate which just does

public PageReference nominate() { 
 insert newapplicant;
 // back to the same page with the proper query params
 PageReference pageRef = pageRef = new PageReference('/nominate?id='+NominationRound.id+'&key='+NominationRound.name);
 pageRef.setRedirect(true);
 return pageRef;

}

the problem i am having is the record is saved fine but doesnt seem to be saved before the redirect happens because its not displaying on the page. If i just refresh the page again its there but thats not good, i want to be sure nominators see their nominations right away?

am i missing something odvious?

EDIT

Adding a little more code here for clarity... also wanted to mention that all of this is working through an unauthenticated force.com pages and i'd quadruple checked permissions

here is the list in visualforce

Your Nominees
<table class="table">
 <apex:repeat value="{!applications}" var="application">
  <tr><td>{!application.First_Name__c}</td><td>{!application.Last_Name__c}</td><td>{!application.Nomination_Type__c}</td></tr>
</apex:repeat>
</table>

and the form is below it.. so the idea is that you save the nominee and then it refreshes the list.

I tried using rerender and i am still getting the delay? things show up eventually but not right away and not on initial load.

Is is possible slowness in the sandbox that wont be there in production? or is it related to the fact that its a publicably accessible page in sites?

4
  • 1
    I think you may want to rerender something instead of a page redirect. May help to show some of your Visualforce and explain more of what you're trying to realize. Jul 2 '13 at 18:45
  • 2
    You might consider making your custom controller a controller extension, and calling the standard controller's quicksave action.
    – metadaddy
    Jul 2 '13 at 19:00
  • Is there a trigger that calls a future method on the Applicant object? The inserted applicant might not appear in the list of nominations until this future method has been processed. Jul 2 '13 at 19:38
  • nope no triggers on anything... its really strange i dont understand whats causing the delay? Jul 2 '13 at 21:59
2

It sounds like it could be a caching issue. Check out Caching Force.com Sites Pages. The behavior is dependent on the configuration of your site (e.g., login-enabled) and apex:page cache and expires attributes.

1
  • 1
    YES! That was totally it. Unauthenticated pages are cached for 10 mins by default I added cache="false" to the page tag and it works perfectly! Jul 2 '13 at 22:57

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.