• Tomasz Woźniak
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I have a wrapper class with checkboxes, and a pageblock table with input fields. Some fields are mandatory to fill in to save them, but I also have a Remove button and I'd like to skip validation of the fields, as I don't want to populate the form just to delete them. Do you have any ideas how to do that? Immediate=true doesn't work, because it doesn't send the value of the checkbox to the controller.
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:pageBlockButtons>
        
        <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>
        </apex:pageBlockTable>  
    </apex:pageBlock></apex:form>
</apex:page>

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() {
        stdCntrlr.save();
		return Apexpages.currentPage();
	}
to invoke standard save method, but it only refreshes the page. 
 
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:pageBlockButtons>
        
        <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>
        </apex:pageBlockTable>  
    </apex:pageBlock></apex:form>
</apex:page>

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() {
        stdCntrlr.save();
		return Apexpages.currentPage();
	}
to invoke standard save method, but it only refreshes the page.