+ Start a Discussion
san k.ax737san k.ax737 

Need help on controller on my Custom Page { URGENT}

I'm trying to develop a  custom page which contains  positions( object: position) and the Job Application Form(object:Job application). Here i want to display all Positions as just readOnly position names  ( but not listview) and Job application as input field with some Fields... i want when i sumbit form by Save action it should navigate to new page where some Greeting masg ll be there......and data enetered by candidate in form should be mapped in Job application Object in Force.com Enviornment.....

 

The Page Code is below:

 

<apex:page showHeader="false" standardController="Job_Application__c" recordSetVar="Jobform" extensions="jobAppFormExtension" standardStylesheets="true" >

<apex:pageblock id="thePage" >   
<apex:listViews type="position__c"/>

</apex:pageblock>
<apex:form >
        <apex:stylesheet value="{!$Resource.jobFormBgColor}"/>
<apex:pageBlock title="Job Application Form">
<apex:pageblockSection >
<apex:inputField value="{!Job_Application__c.Applicant_Name__c}" styleClass="page"></apex:inputField>

<apex:inputField value="{!Job_Application__c.Email__c}" styleClass="page"></apex:inputField>
<apex:commandButton value="Save" action="{!save}" oncomplete="{!greeting}"/>
</apex:pageblockSection>


</apex:pageBlock>

</apex:form>

</apex:page>

 

 

 

 

 

PLz give  me sample controller code for above problem...

 

 

Urgent...

 

Thanx

san

imuino2imuino2

Hi,

What i would do is to create a property of your object type

 

public Job_Application__c jobApp{get;set;}

 

Then in the class contructor

 

public yourController(){

        jobApp = new jobApp();

}

 

in your save method do this

 

public PageReference save(){

    try{

         insert jobApp;

         PageReference successPage = new PageReference('/apex/success');

         successPage.getParameters().put('id', jobApp.Id);

         successPage.setRedirect = true;

         return successPage;

   }catch(DMLException e){

        PageReference errorPage= new PageReference('/success');

        errorPage.setRedirect = true;

        return errorPage;

  }

}

This tries to save the object values and then redirects you to the success page if it is all good or the error page if there is some error on insertion.

That's what PageReference class does, here you can find some more info about this class and all other salesforce standard classes.

With the getParameters().put line you pass a parameter to the success page, in this case the new object id. You will use it on the success page to query for the object and show the data.

 

If you have any other questions, or want more details let me know.

Greetings.

Ignacio.