You need to sign in to do that
Don't have an account?
Need help on refreshing a page in force.com sites
Hi
I created a force.com site page and gave authentication to customer portal users to access the page. The force.com site page have callout on pageload as callout1 and callout2 on a button click.
Callout1 - I show some list from external system with a button deactivate
Callout2 - When the user clicks deactivate then that row is eliminated from the list in the external system
Now I refreshes the page when callout2 is over but the salesforce took the page from Cache because the deactivated column is showing on Callout1 list.When I press F5 it shows the correct result by eliminating the column.
Eg) List shows Item1 then deactivate button,item2 then deactivate button
When I click deactivate button on item2, it deactivated and eliminated.
On refreshing a Page by pagereference Still shows item2 on List but by Pressing F5 it shows correctly by elimination
Need help on this
Thanks
Marris
Hi,
So, if I'm gettin this correctly you have 2 actions: 1 taht list some records, and 2nd that removes records from that list. On the rerender of the page after action2 the list still has the initial value.
Solution is simple: in your controller action2 method, at the end of it, after the remove part reinstantiate the record list to refresh its value. Probably a call to action1 is what you need...
Thanks,
Adrian
Hi AdrianCC
Thanks for your help but it is not working
I made a call of first callout at the end of action method as you have mentioned but still it shows the eliminated value in the list. But after a page refresh I call the callout1 means it shows the list excatly by eliminating the values.
Thanks
Marris
You need to debug it to see exactly where the problem is, controller or page.
For the controller, put System.debug(recordList) at the end of both methods to see how if the value is refreshed corectly.
Also in the VF page try adding a rerender attribute to your commandbutton, and rerender only the part that shows the list.
A quick fix would be to change the return type of the action2 to PageReference and return the same page at the end of the method. This would simulate the user clicking F5 on the page...
Can you post the vf page and actions 1 & 2 code here?
Thanks,
Adrian
Hi AdrianCC
Here is my page
Apex class:
Callout2 on a button click
public pagereference activateFeature(){
String FActive;
String featurcode = ApexPages.currentPage().getParameters().get('FeatureId');
system.debug('New Feature code :'+featurcode);
String featuractive = ApexPages.currentPage().getParameters().get('FeatureActive');
system.debug('New Feature active :'+featuractive);
if(featuractive == 'True'){
FActive = 'D';
}else{
FActive = 'A';
}
//Made a callout here and get the response in String response
System.debug('The Response is:'+response);
if(response != null && response.trim() != ''){
Map<String, String> outputDetails = abc.parseDetails( response );
System.debug('Response detail is:'+outputDetails);
System.debug('Response code:'+outputDetails.get( 'ResponseCode' ));
System.debug('Result is:'+outputDetails.get( 'Result' ));
System.debug('Response Msg:'+outputDetails.get( 'ResponseMessage' ));
//System.debug();
try{
if(outputDetails.get( 'Result' ) == 'SUCCESS'){
String Responsecode = outputDetails.get( 'ResponseCode' );
String Responsemsg = outputDetails.get( 'ResponseMessage' );
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.Info,'Plan Feature Changed Successfully'));
}else{
String Errorcode = outputDetails.get( 'ErrorCode' );
String Errormsg = outputDetails.get( 'ErrorMessage' );
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.Info,'Plan Feature not Updated.Please Try again later'));
return null;
}
}catch(Exception e){
System.debug('Exception:'+e);
}
}
featureList.clear();
planfeature(); //Callout1
System.debug('Callout1 List:'+FeatureList); // It shows only a old list which is not updated with elimination
pagereference page = new pagereference('/apex/mypage');
return page;
}
Callout1:
Made a callout named "planfeature()" and return a list of plan features, Callout1 is called in class constructor
Thanks
marris
What are you using for the callouts, HttpRequest class?
Are they running synchronously or asynchronously(are you using @future adnotation)? What's the timeout?
Adrian
You may want to add cache="false" as an attribute on the <apex:page> tag - at least that helps me when I had a similar problem with a Sites page recently. Sites seems to assume that you are doing a public-facing website and that, for performance reasons, you will want to cache as much as possible.
Hope this helps,
Hi Adriancc
I am using Http callout synchronously and i didnt mention any time out for it
Thanks
Marris
Hi SFF
I added the cache as false in page but still faces the same error.
Thanks
Marris
This is wierd... I was thinking your callout was asynchronously and that was the problem, but since it's not then it should wait for the operation to finish and then rerender the page...
What does that
javascript do? does it have anything to do with the list? or other callouts?
As for the refresh problem at hand. You could try manually removing the element from the list when response == SUCCESS without doing the whole retrieve through callout1.
LE: typo
Thanks,
Adrian