• Shivani Maheshwari
  • 0 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
i need guidance regarding DataLoader any one please suggest to complete Challenge 8
Hello. I'm new to salesforce. I created simple apex page, using standard controller and custom extension. I have contact list for a specific account shown as input fields to edit that straight away. The problem is when I added the extension, standard save function won't work, and I couldn't really find the solution. (without an extension saving works fine, but then I can see EVERY contact, not only contact connected to specific account). I would really appreciate some help. This is the code:
<apex:page standardController="Contact" recordSetVar="contacts" extensions="myExt"><apex:form >
    <apex:pageBlock title="Contacts">
        <apex:pageMessages />
        <apex:pageBlockButtons >
            <apex:commandButton action="{! save}" value="Save"/>   
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        <apex:pageBlockTable value="{!contacts}" var="contact">
            <apex:column ><apex:facet name="header">First name</apex:facet><apex:inputField value="{!contact.FirstName}" required="true"/></apex:column>
            <apex:column ><apex:facet name="header">Last name</apex:facet><apex:inputField value="{!contact.LastName}" required="true"/></apex:column>
            <apex:column ><apex:facet name="header">E-mail</apex:facet><apex:inputField value="{!contact.Email}"/></apex:column>
            <apex:column ><apex:facet name="header">Phone</apex:facet><apex:inputField value="{!contact.Phone}"/></apex:column>
            <apex:column ><apex:facet name="header">Description</apex:facet><apex:inputField value="{!contact.Description}"/></apex:column>

and here is my extension:
public class myExt {
    public ApexPages.StandardSetController stdCntrlr {get; set;}
 	public myExt(ApexPages.StandardSetController controller) {
        stdCntrlr = controller;
        contactAddList = new List<Contact>();
    private String sortOrder='LastName';
	private String acId=ApexPages.currentPage().getParameters().get('Id');
    public List<Contact> getContacts(){
        List<Contact> results = Database.query(
            'SELECT Id, FirstName, LastName, Phone, Email, Description ' +
			'FROM Contact WHERE AccountId=\'' + acId + '\' ' +
			'ORDER BY ' + sortOrder + ' ASC ' +
			'LIMIT 10'
    	return results;

I tried adding this code: 
public PageReference save() {
		return Apexpages.currentPage();
to invoke standard save method, but it only refreshes the page.