You need to sign in to do that
Don't have an account?
Michael_Johnson
CMSForce Web Form Submissions w/ URL Rewriter Class
Hi All,
I am using CMSForce to build content of one of my current sites and am also using a URL rewriting class. The issue I am having is when using the submit button on a webform page, or calling any pagereference method, the URL rewriter class is called first and the method to save the form never gets executed. Has anyone run into similar issues using URL rewriter, and if so - have you found any workarounds? I appreciate any help with this!
I haven't seen this yet.
Could you post your url rewriter class code ?
global class myRewriter implements Site.UrlRewriter {
String VISUALFORCE_PAGE = '/page?pageid=';
global PageReference mapRequestUrl(PageReference myFriendlyUrl){
String url = myFriendlyUrl.getUrl();
system.debug('***URL '+url);
if(url.length() > 1 && url != '/page'){
String name = url.substring(1,url.length());
system.debug('***Name '+name);
Page__c site_page = [select id from Page__c where URL__c =:name LIMIT 1];
return new PageReference(VISUALFORCE_PAGE + site_page.id);
} return null; }
global List<PageReference> generateUrlFor(List<PageReference> mySalesforceUrls){
List<PageReference> myFriendlyUrls = new
List<PageReference>();
for(PageReference mySalesforceUrl : mySalesforceUrls){
String url = mySalesforceUrl.getUrl();
if(url.startsWith(VISUALFORCE_PAGE)){
String id= url.substring(VISUALFORCE_PAGE.length(), VISUALFORCE_PAGE.length()+15);
Page__c site_page2 = [select URL__c from Page__c where id =:id LIMIT 1];
myFriendlyUrls.add(new PageReference(site_page2.URL__c)); }
else {
myFriendlyUrls.add(mySalesforceUrl);
}
}
return myFriendlyUrls;
}
}
Try the code below.
This is an URL rewriter that allows you to access any page via http://yourdomain.force.com/yoursite/cms/<pagename>
This will be part of CMSForce 2 (long overdue, but I'm working on it ...)
The URL rewriter works (I changed it to pull from a custom field called URL I added) but submitting a form using the webform component does not seem to be working. When I turn the url rewriter off it works fine. Here is the debug log after a form submit.
Here is the additional debug when I turn the url rewriter off and a form successfully submits. I can't seem to track down why methods of renderformcomponentcontroller are not even initiating.
When FriendlyURLs is added as the site URL Rewriting class all webform submissions do not work. When pressing the submit after entering data in the form returns page not found, nor does error checking return to the same page. When FriendlyURLs is removed from site setup the webforms resume correctly on form submissions.
I would like to know if anyone has this working yet as well?
I'm trying to use the UrlRewriter (taken from CMSForce 2.0) in CMSForce. I can confirm that even the login function does not work while the rewriter is 'turned on' for the site. When I remove the rewriter (or even simply go to a page that is not re-written), the login works. (By login, I mean any method call to my Apex controller)
Any news on why this is and how to fix it?
With a bit more diving in to things, I've found that it has something to do with a mix of the rewriter and the <c:contentblock> tags.
I started rebuilding from the 'ground up' and found that everything works until I put in the <c:contentblock> tags. When I put one of them in and click 'submit', I get a 'Page Not Found: page'.
From within a CMSForce page (friendly url name of 'TestSubmit', so path is /cms/TestSubmit)
If I turn off the rewriter, the submit works.
If I remove the contentblock tags, the submit works.
If I go directly to the VF 'template' page on sites (so path of /VFTestSubmit), the submit works regardless of the rewriter being on or not.
I'm experiencing the same type of thing as Michael_Johnson where the form does not get submitted correctly (ie the function in apex never gets called).
Has anyone found a solution for this issue? I'm having the same problem.
Here is a workaround:
http://boards.developerforce.com/t5/Force-com-Labs-Development-and/CMSForce2-Web-Form-Error-due-to-url-rewriter-a-workaround/td-p/439083