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
himanshu huske 7himanshu huske 7 

VisualForce_Task_1

Please Help Me With Code.
I want to create a page in which,
we use <apex:inputField> or <apex:inputText> for FirstName, LastName, DateOfBirth,Gender(PickList).
There will be a button on page, after insert value in each field and clicking on button, next page will get display, wich will show list of output. which we have entered in inputField or input text.
please give me a code using following methods,
PageReference Px = page.PageName;
    Px.getParameters().put();
ApexPages.currentPage().getParameters().get();
 
Ajay K DubediAjay K Dubedi
Hi Himanshu,

<<<<----First vf page --->>>>>
 
<apex:page standardController="Contact"
           extensions="myController"
           title="Contact Us" showHeader="false"
           standardStylesheets="true">
    
    <apex:define name="body">
        <center>
            <apex:form >
                <apex:messages id="error"
                               styleClass="errorMsg"
                               layout="table"
                               style="margin-top:1em;"/>
                <apex:pageBlock title="" mode="edit">
                    <apex:pageBlockButtons >
                        <apex:commandButton value="Submit"
                                            action="{!saveLead}"/>
                    </apex:pageBlockButtons>
                    <apex:pageBlockSection title="Register Page"
                                           collapsible="false"
                                           columns="1">
                        <div style="text-align:center">
                            <apex:inputField value="{!Contact.FirstName}" />
                            <apex:inputField value="{!Contact.LastName}"/>
                            <apex:inputField value="{!Contact.Email}"/>
                        </div>
                    </apex:pageBlockSection>
                </apex:pageBlock>
            </apex:form>
        </center>
    </apex:define> 
    
</apex:page>

<<<<<<------ Rerender page ---->>>>>>
 
<apex:page standardController="Contact" extensions="ContactEdit" title="Job Application" 
           showHeader="false" standardStylesheets="true">
    
        <apex:define name="body">
            <center>
                <apex:form >
                    <apex:messages id="error"
                                   styleClass="errorMsg"
                                   layout="table"
                                   style="margin-top:1em;"/>
                    <apex:pageBlock title="" mode="edit">
                        <apex:pageBlockSection >
                            <apex:commandButton value="edit" action="{!EdittheSection}" />
                        </apex:pageBlockSection>
                        
                        <apex:pageBlockSection rendered="{!!editSection}" title="Contact Us"
                                               
                                               columns="1">
                            <apex:inputText value="{!Contact.FirstName}" />
                            <apex:inputText value="{!Contact.LastName}"/>
                            <apex:inputText value="{!Contact.Email}"/>
                        </apex:pageBlockSection>
                    </apex:pageBlock>
                </apex:form>
            </center>
        </apex:define> 
    
</apex:page>

<<<<<<------ Apex class---- >>>>>
 
public class myController {

     private final Contact weblead;

    public myController(ApexPages.StandardController
                                stdController) {
       weblead = (Contact)stdController.getRecord();
    }

     public PageReference saveLead() {
       try {
       insert(weblead);
       }
       catch(System.DMLException e) {
           ApexPages.addMessages(e);
           return null;
       }
       PageReference p = new pagereference('/apex/rerenderpage?id='+weblead.Id);
       p.setRedirect(true);
       return p;
     }
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi
himanshu huske 7himanshu huske 7
Hi Ajay,
ContactEdit Class Is Missing Here, Can You Please Provide it too

 
Ajay K DubediAjay K Dubedi
Hi Himanshu,
<<<<<<------ Rerender apex class---->>>>>>
public class ContactEdit {
    
    public boolean editSection {get;set;}
    Contact currentRecord;
    public ContactEdit(ApexPages.StandardController controller) 
    {
        this.currentRecord = (Contact)controller.getRecord();
        currentRecord = [SELECT Id, LastName FROM Contact WHERE Id = :currentRecord.Id];
        System.debug('name'+currentRecord);
    }
    public PageReference EdittheSection()
    {
        try {
            
            Update(currentRecord);
            editSection = true;
        }
        catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        return null;
        
    }
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi