+ Start a Discussion
SCRSCR 

Getting REdirected to Page Not Found in Sites VS Page

I've got a VS Sites Page (PublicJobs) that links to a VS Sites Detail Page (PublicJobsDetails) when you click on the link for a selected item within a list, which then presents the detail for the selected item and provides an 'Apply' button that should direct you to another VS Sites Page (PublicJobApplication) to apply for the job poisiton selected.  The initial VS Sites Page (PublicJobs) renders no problem, as does the VS Sites Page (PublicJobDetails) it links to.  But I get the following error Page when I click the 'Apply' button on the Job Details Page:

 

  
Page Not Found: %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PublicJobApplication

 

Also very odd is that the URL in the addrress bar of the browser (in this case Fire Fox) has a gap in the string when this error Page is rendered:

 

http://stratasaas-developer-edition.na6.force.com/              PublicJobApplication?jobid=a018000000Mf2euAAB

 

Any help resolving this would be greatly appreciated.  Thanks in advance.  Code info below.

 

Code fragment in the VS Sites Page (PublicJobDetails) linking the PublicJobApplication VS Sites Page via a command button:

 

<apex:pageBlockButtons > <!-- Apply button linked to the job application page --> <apex:commandButton value="Apply" onclick="window.top.location='{!$Site.Prefix}/ PublicJobApplication?jobid={!Position__c.Id}'; return false;"/> </apex:pageBlockButtons>

 

VS Sites Page markup for PublicJobApplication:

 

<!-- This page uses the standard controller and extends it to overwrite the action buttons and file upload --> <apex:page standardController="Candidate__c" extensions="PublicJobApplicationExtension" title="Job Application" showHeader="false" standardStylesheets="true"> <!-- The site template provides the layout and the style for the site --> <apex:composition template="{!$Site.Template}"> <apex:define name="body"> <apex:form > <apex:sectionHeader title="" subtitle="{!Position.name}"/> <!-- Breadcrum link back to the job details page --> <apex:commandLink value="<- Back to Job Details" onclick="top.history.go(-1);return false;" /> <!-- section to display the error mesages --> <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em;"/> <apex:pageBlock title="Job Application Form" mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!saveApplication}"/> <apex:commandButton value="Cancel" onclick="top.history.go(-1);return false;"/> </apex:pageBlockButtons> <!-- Job information in read only --> <apex:pageBlockSection title="Job Information" collapsible="false" columns="1"> <apex:outputField value="{!Position.name}"/> <apex:outputField value="{!Position.Position_type__r.Name}"/> <apex:outputField value="{!Position.Job_Description__c}" /> </apex:pageBlockSection> <!-- Candidate information editable--> <apex:pageBlockSection title="Candidate Information" collapsible="false" columns="1"> <apex:inputField value="{!Candidate__c.First_Name__c}"/> <apex:inputField value="{!Candidate__c.Last_Name__c}"/> <apex:inputField value="{!Candidate__c.Address__c}"/> <apex:inputField value="{!Candidate__c.City__c}"/> <apex:inputField value="{!Candidate__c.State_Province__c}"/> <apex:inputField value="{!Candidate__c.Postal_Code__c}"/> <apex:inputField value="{!Candidate__c.Country__c}"/> <apex:inputField value="{!Candidate__c.Email__c}"/> <apex:inputField value="{!Candidate__c.Phone__c}"/> <apex:inputField value="{!Candidate__c.Mobile__c}"/> <apex:inputField value="{!Candidate__c.Education__c}"/> <apex:inputField value="{!Candidate__c.Current_Employer__c}"/> <!-- Field to upload candidate resume --> <apex:pageBlockSectionItem > Upload your resume <apex:inputFile accept="doc, txt, pdf" filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" value="{!resume}"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:define> </apex:composition> </apex:page>

 

VS Site Page Controller Extension:

 

public class PublicJobApplicationExtension { // This controller extends the standard controller // overwrites the actions // creates a candidate record // creates attachment on the candidate record based on the uploaded file // creates a job application record that links the candidate record and the related position private final Candidate__c candidate; private ID positionid = ApexPages.currentPage().getParameters().get('jobid'); private Job_Application__c jobapplication {get; private set;} public Blob resume {get; set;} public String contentType {get; set;} public String fileName {get; set;} // Extends the standard controller for the candidate object public PublicJobApplicationExtension(ApexPages.StandardController stdController) { candidate = (Candidate__c)stdController.getRecord(); } public Position__c getPosition() { return [SELECT id, name, Position_type__r.Name, Job_Description__c FROM Position__c WHERE id = :positionid]; } public PageReference saveApplication() { // Creates the candidate record try { insert(candidate); } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } jobapplication = new Job_Application__c(); jobapplication.Candidate__c = candidate.id; jobapplication.Position__c = positionid; // Creates an attachment to the candidate record if a resume file is uploaded if (resume != null) { Attachment attach = new Attachment(); attach.Body = resume; attach.Name = fileName; attach.ContentType = contentType; attach.ParentId = candidate.id; try { insert(attach); } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } } // Creates the job application record to link the candidate and the related position try { insert(jobapplication); } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } PageReference p = Page.PublicJobApplicationConfirmation; p.setRedirect(true); return p; } }

 

Best Answer chosen by Admin (Salesforce Developers) 
SCRSCR

I found the problem.  You can not place any white space between the "{!$Site.Prefix}/" and the reference (in this case "PublicJobApplication?jobid={!Position__c.Id}';").

 

Revised code fragment from VS Sites Page (PublicJobDetails):

<apex:pageBlockButtons > <!-- Apply button linked to the job application page --> <apex:commandButton value="Apply" onclick="window.top.location='{!$Site.Prefix}/PublicJobApplication?jobid={!Position__c.Id}'; return false;"/> </apex:pageBlockButtons>

 

 

Also need to make sure the Public Access Settings allow users to do everything they need to on the Page.