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
lakslaks 

VF Pages redirection problem in Force.com Sites

Hi All,

 

I am facing a problem with visualforce pages behaviour after being moved to Force.com Sites.


When the VF pages were moved to Site, the redirection that was working fine fails to work anymore.

The requirement is that we need to traverse across some 4,5 pages capturing the user entry in each and carrying it till the last page where we are doing a save to an object.


I have associated the same controller with all pages and redirecting using:

PageReference redirect = new PageReference('/apex/survey3');       
return redirect;

 

This works fine before moving to Sites.
But once moved to Sites, it doesn't redirect at all, just refreshes the same page.

 

When the code is changed as below, it redirects but the view state is not maintained I guess and hence the values are not carried over as required.

PageReference redirect = new PageReference('/survey3');
return redirect;

 

Could you provide any information on what might be wrong ?

Thanks in advance.

 

Regards,

Lakshmi.

Best Answer chosen by laks
lakslaks
Hi,

Was revisiting this post after long and thought of mentioning what was actually wrong in this case.

It was the firewall in the office network that was causing the VF pages to misbehave after being moved to Force.com Sites.

Regards,
Lakshmi.

All Answers

bob_buzzardbob_buzzard

I wouldn't expect the view state to be lost just because you have moved to sites.  The '/apex/page' notation won't work in sites as the apex aspect isn't needed.  Its better to use the Page notation:

 

PageReference redirect = Page.survey3;
return redirect;

 

as this will work correctly regardless of whether you are accessing from sites or internal.

 

I assume all of your pages are using the same controller?

 

lakslaks

Hi Bob,

 

Thank you for reply.

 

I changed it to Page.survey3.

 

Still it doesn't work in Sites(it just refreshes the same page), but works fine otherwise.

 

And yes, I am associating the same controller with all the pages.

 

 

This is webpage error details that comes in the browser:

 

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Timestamp: Wed, 8 Aug 2012 07:48:25 UTC


Message: Expected '}'
Line: 1546
Char: 203
Code: 0
URI: http://resmed.dev.cs14.force.com/survey/jslibrary/1341513998000/sfdc/main.js


Message: 'LC' is undefined
Line: 1
Char: 1
Code: 0
URI: http://resmed.dev.cs14.force.com/survey/jslibrary/labels/1343830263000/en_US.js


Message: 'Sfdc' is undefined
Line: 1
Char: 1
Code: 0
URI: http://resmed.dev.cs14.force.com/survey/jslibrary/1341513998000/sfdc/VFState.js


Message: 'ApexPage' is undefined
Line: 45
Char: 23
Code: 0
URI: http://resmed.dev.cs14.force.com/survey/survey1


Message: 'Sfdc' is undefined
Line: 72
Char: 1
Code: 0
URI: http://resmed.dev.cs14.force.com/survey/survey1

 

Any idea what else might be wrong ?

 

Regards,

Lakshmi.

bob_buzzardbob_buzzard

Do you have the javascript error when the page loads, or when you attempt to submit it back?  

lakslaks

Hi Bob,

 

Just cross checked that now.

 

The error is displayed on page load, as well as after clicking the next button(on which the redirect code should be executed.)

 

Again, none of this is there when the page is accessed normally, other than from Sites.

 

 

 

Regards,

Lakshmi.

bob_buzzardbob_buzzard

When I've encountered this before its been that I'm relying on some javascript which is available from the standard Salesforce UI but is not present when accessing via sites.  Tracking it down is often interesting - the last time I looked at the source of the standard page and added in the libraries one by one until I found the one that was required.

lakslaks

Oh ok. That is interesting indeed.

 

And how can we add in the required libraries to our page ?

 

 

Regards,

Lakshmi.

lakslaks

Do you mean going to "View source" of the original page (not the one in Sites).

Finding out the ones missing and adding to the VF page in a script tag ?

Like - <script src="/jslibrary/1341513998000/sfdc/main.js"></script>

 

 

Regards,

Lakshmi.

bob_buzzardbob_buzzard

It depends if they are exposed externally or not.  I start off pasting the script address into a separate browser page and check its available.  if it isn't, I download it, upload as a static resource and then add that to the site page.

 

The other way to approach this is to comment out parts of the visualforce page and see what causes the error to go away.  It might be as simple as using a different component.

lakslaks

Ok, Will check out that approach.

 

Thanks a lot for your help.

 

 

Regards,

Lakshmi.

lakslaks
Hi,

Was revisiting this post after long and thought of mentioning what was actually wrong in this case.

It was the firewall in the office network that was causing the VF pages to misbehave after being moved to Force.com Sites.

Regards,
Lakshmi.
This was selected as the best answer