You need to sign in to do that
Don't have an account?
Want to display a particular field of the record of a custom object
VF
<apex:page controller="addressfinderController" tabstyle="Location">
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageMessages />
<apex:pageBlockSection >
<apex:inputField value="{!Location__c.Company__c}"/>
<apex:inputField value="{!Location__c.Location_Address__c}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public class addressfinderController{
public Location__c location { get; private set; }
public addressfinderController() {
Id id = ApexPages.currentPage().getParameters().get('id');
location = (id == null) ? new Location__c() :
[SELECT Company__c,Location_Address__c FROM Location__c WHERE Id = :id];
}
public PageReference save() {
try {
upsert(location);
} catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
// After Save, navigate to the default view page:
return (new ApexPages.Controller(location)).view();
}
}