0

I created a visualforce page to handle inserting of records in custom setting. But I encounter this error every time I try to save the page:

Unknown property 'CustomSettingController.SettingWrapper.Field1__c

Meanwhile, here's what I've been working on so far:

Apex Class:

public class CustomSettingController {

    public SettingWrapper sWrap {get; set;}

    public CustomSettingController() {
        String settingId = ApexPages.currentPage().getParameters().get( 'id' );
        if (settingId != null ) {
            sWrap = new SettingWrapper([SELECT Id, Name, Field1__c FROM Setting__c WHERE Id = :settingId]);
        } else {
            sWrap = new SettingWrapper();
        }
    }

    public void save() {
        if (sWrap.Id != null) {
            update sWrap.getSetting();
        } else {
            sWrap.insertSetting();
        }

    }

    public class SettingWrapper {
        public Id Id {get;set;}
        public String Field1 {get;set;}

        public SettingWrapper(Setting__c s2) {
            this.Id = s2.Id;
            this.Field1  = s2.Field1__c;
        }

        public SettingWrapper() {}

        public Setting__c getSetting() {
            return new Setting__c(
                Id = this.Id,
                Field1__c = this.Field1 
            );
        }

        public void insertSetting() {
            Setting__c s2 = this.getSetting();
            insert s2;
            this.Id = s2.Id;
        }

    }
}

Visualforce Page:

<apex:page controller="CustomSettingController ">
    <apex:pageMessages />
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel>Field 1</apex:outputLabel>
                    <apex:inputText value="{!sWrap.Field1__c}"/>                
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

1 Answer 1

3

You are exposing the wrapper class in UI so it should be

 <apex:inputText value="{!sWrap.Field1}"/>  
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .