[SalesForce] Displaying data in visualforce page

I am new to salesforce. How to write response data from Page Controller in visualsource page. That I want to populate all the text field data whose values are retrieved from controller contating database and and the retrieved data iswritten to the response. How to write data into response in controller. So 2 questions…

  1. How to write response data from Page Controller in visualsource page
  2. How to write data into response in controller. So 2 questions

Best Answer

Here is a sample code for you.

        <apex:pageBlock title="Edit Account">
            <apex:pageMessages/>
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{! Account.Name }"/>
                <apex:inputField value="{! Account.Phone }"/>        
                <apex:inputField value="{! Account.Industry }"/>        
                <apex:inputField value="{! Account.AnnualRevenue }"/>
           </apex:pageBlockSection>

            <apex:pageBlockButtons>
                <apex:commandButton action="{! save }" value="Save" />        
            </apex:pageBlockButtons>

        </apex:pageBlock>
        <apex:pageBlock title="Contacts">
        <apex:pageBlockTable value="{!Account.contacts}" var="contact">
            <apex:column>
                <apex:outputLink
                    value="{! URLFOR($Action.Contact.Edit, contact.Id) }">
                    Edit
                </apex:outputLink>
                &nbsp;
                <apex:outputLink
                    value="{! URLFOR($Action.Contact.Delete, contact.Id) }">
                    Del
                </apex:outputLink>
            </apex:column>
            <apex:column value="{!contact.Name}"/>
            <apex:column value="{!contact.Title}"/>
            <apex:column value="{!contact.Phone}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>


        </apex:form>
    </apex:page>

For custom controller you can check @Ratan's answer.

Related Topic