Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- How to save a custom object custom fileds in a vis...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to save a custom object custom fileds in a visualforc e page?
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-05-2012 01:20 AM - edited 03-05-2012 01:23 AM
We are trying to make a simple employment application with visualforce.
We created a custom object for employment application, and made a page and site.
The problem is, when I publically insert the data and try to save it—the form directs me to that particular record only signed in users can see—so the public user will get an error page that says the public user don't have access to that certain page.
Here is our simple apex code:
<apex:page sidebar="false" showHeader="false" standardController="Staff_Application__c">
<div style="margin: 0 auto; padding: 30px; width: 500px;">
<apex:form >
<label>First Name:</label>
<apex:inputField value="{!Staff_Application__c.First_Name__c}" />
<label>Last Name:</label>
<apex:inputField value="{!Staff_Application__c.Last_Name__c}" />
<apex:commandButton value="Save" action="{!save}" />
</apex:form>
</div>
</apex:page>
and here is a link to our application:
http://artandjustice.force.com/employment
How can a public user press save button and it directs the public user to a page that I want them to see after they press them?
For example after they insert the data, I want them to go to artandjustice.org/confirmation.php?
Solved! Go to Solution.
Re: How to save a custom object custom fileds in a visualforc e page?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-05-2012 01:42 AM
Hi,
Since you are using force.com site and in site you can only access visualforce page. Hence in your page u are using standard controller as well as save method and save method of standard controller redirect u to object's record page that is not visualforce page and you cant access that using site.
So wat you need to do, just override the save method. First u need to create extension class and in this class override the save method. Sample code is as given below:
Public class MyExtension
{
Staff_Application__c staff;
public MyExtension(ApexPages.standardController con)
{
staff=(Staff_Application__c)con.gerRecord();
}
public PageReference save()
{
if(staff!=null)
insert staff;
PageReference pr=new PageReference(PAGE_URL);
// if you want to redirect to any VF page then PAGE_URL will be = '/apex/pagename';
// and you want to redirect to any external site page the provide full qualified url
pr.setRedirect(true);
return pr;
}
}
And add this class as extension in your page:
<apex:page sidebar="false" showHeader="false" standardController="Staff_Application__c" extensions="MyExtension">
Alok @ Nagarro Inc.
Salesforce.com Certified Developer
Re: How to save a custom object custom fileds in a visualforc e page?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-05-2012 01:59 AM
Alok_vibrant, you are amazing! Thank you so much for your help! It worked!

