0

I have a VF page with inline edit mode on and a controller having a set controller.

A validation rule is present to check if LastName == '11', then show message 'Custom Error'.

Now when I edit the lastname field in the table to '11' and hit 'Save' it shows the error message on the top but I want to show which are the records that got failed. As of now it is not showing the error message only.


<apex:page Controller="TestPage8Controller">
    <apex:form >
        <apex:pageMessages showDetail="true"></apex:pageMessages>

       <apex:pageBlock >

           <apex:commandButton action="{!Save}" value="Save" />
           <apex:variable var="x" value="{!1}" />
            <apex:pageBlockTable value="{!Records}" var="c">
                <apex:column ><apex:outputField value="{!c.salutation}" ><apex:inlineEditSupport /></apex:outputField></apex:column>
                <apex:column ><apex:outputField value="{!c.firstName}" ><apex:inlineEditSupport /></apex:outputField></apex:column>
                <apex:column ><apex:outputField value="{!c.LastName}" ><apex:inlineEditSupport /></apex:outputField></apex:column>
                <apex:column ><apex:outputField value="{!c.AccountId}" ><apex:inlineEditSupport /></apex:outputField></apex:column>
           </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form> 
</apex:page>

public class TestPage8Controller {

    public ApexPages.StandardSetController ctrl{get;set;}
    public String i{get;set;}

    public TestPage8Controller()
    {
        this.ctrl = new ApexPages.StandardSetController(Database.getQueryLocator('Select Id,Salutation,FirstNAme,LastName,AccountId from Contact'));
    }


    public void Save()
    {
        ctrl.save();
    }

    public List getRecords()
    {
        return (List)ctrl.getRecords();
    }

}
  • Standardcontorller? Where do you have it? – Rao Dec 20 '16 at 11:33
  • StandSetController ctrl @Rao in apex class. – Saumya Ranjan Satapathy Dec 20 '16 at 11:35
  • you are using a custom controller in your VF page! – Rao Dec 20 '16 at 11:42
  • My pageBlockTable is refering to a StandardSetController @Rao – Saumya Ranjan Satapathy Dec 20 '16 at 11:45
  • 2
    The save method returns a PageReference, so its not going to tell you which records got saved. And moreover why are you involving a SetController in between, you can just update/upsert the list of records storing in a list<contact> – Santanu Halder Dec 20 '16 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.