1

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
4
  • 1
    this looks like a good new years resolution to go through the Trailhead modules that teach SFDC development - specifically Visualforce Commented Jan 1, 2016 at 2:51
  • This doesn't describe my problem Commented Jan 1, 2016 at 4:16
  • I need something like request.getAttribute in Viseualforce pag Commented Jan 1, 2016 at 4:19
  • You can access any public variable in Visualforce using this notation {!variableName}. You can read this post , as it explains VF in very detail from basics - developer.salesforce.com/page/An_Introduction_to_Visualforce Commented Jan 1, 2016 at 5:37

2 Answers 2

1

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.

0

Example

Apex class

public class customCtrl{

    public List<Contact> getAllContacts(){
       return [SELECT FirstName, LastName, Email FROM Contact];
    }
}

VF page

<apex:page Controller="customCtrl">
    <apex:form>     
        <apex:pageBlock title="Contacts">
          <apex:pageBlockTable value="{!AllContacts}" var="contact">
            <apex:column value="{!contact.FirstName}"/>
            <apex:column value="{!contact.LastName}"/>
            <apex:column value="{!contact.Email}"/>
          </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

This page will display all the contacts

Trailhead: A New Approach to Learning Salesforce

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.