1

My page

 <apex:pageblocksectionItem >
            <apex:outputlabel value="Date Format"/>
             <Apex:selectlist value="{!dateval}" size="1" style="width:100px;">
               <Apex:selectoptions value="{!datevalues}"></Apex:selectoptions>
             </Apex:selectlist>
          </apex:pageblocksectionItem>       
          <apex:pageBlockSectionItem >
             <Apex:outputLabel value="Counter Seed"></Apex:outputLabel>
             <apex:inputtext value="{!Settings.Counter__c}" maxlength="10" />
          </apex:pageBlockSectionItem>

My class is

string dateval='yyyy';
public void setdateval(string S){this.dateval= S;}
public string getdateval(){return dateval;}

public list<selectoption> getdatevalues(){
    list<selectoption> Value = new list<selectoption>();
    Value.add(new Selectoption('dd-mm-yyyy','dd-mm-yyyy'));
    value.add(new selectoption('mm-dd-yyyy','mm-dd-yyyy'));
     value.add(new selectoption('mm/dd/yyyy','mm/dd/yyyy'));
}
 public void SaveSetting(){
 Sett.Date_Format__c = this.dateval;
 Sett.Counter__c = Settings.Counter__c;
}

here whence I click on save text field is inserted but picklist value is not inserted.I need to get picklist value also inserted.how can I do it.

5
  • salesforce.com/us/developer/docs/pages/Content/…. I was looking at this example and we seems to intialise the string with 'yyyy'.I guess lets just have String there and then the setter must set that thing – Mohith Shrivastava Nov 21 '12 at 13:12
  • Also please debug inside the setter to see whether the picklist value selected comes back in controller or not . – Mohith Shrivastava Nov 21 '12 at 13:14
  • 1
    I am wondering if you need to perform some DML to update your custom setting in your 'SaveSetting' method? e.g. upsert Sett; – Andrew Fawcett Nov 21 '12 at 13:26
  • Andrew its good point actually.Thanks.Yes i see no Update statement also – Mohith Shrivastava Nov 21 '12 at 13:47
  • If(SettingsSize.size()==0){insert Settings; ApexPages.Message UpdateSuccess = new ApexPages.Message(ApexPages.severity.INFO, 'Invoice Settings inserted Successfully');ApexPages.addMessage(UpdateSuccess); }If(SettingsSize.size()==0){insert Settings; ApexPages.Message UpdateSuccess = new ApexPages.Message(ApexPages.severity.INFO, 'Invoice Settings inserted Successfully');ApexPages.addMessage(UpdateSuccess); }if (SettingsSize.size()==1){update Settings; } in Savesettings() – Eagerin Sf Nov 21 '12 at 14:04
1

Try a different construction for the getter/setter of dateVal:

public class YourClass {
  public String dateVal {
    get { return dateVal; }
    set { dateVal = value; }
  }
}

This is from the SFDC Apex doc on properties. 'value' is an implicit keyword referring to the value passed by the VF page (or any caller)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.