0

I am having a small issue while assigning a value to custom picklist in my VF.

I am storing values (0 or 1) in a custom field (Match_Filter__c).

With my logic I am able to get the value of above custome field, and also able to assign it to crit.reportingMatch.

But, still the value ofcrit.reportingMatch isn't upadting with the value which we set in class. It is still showing '- Reporting Match Filter -' in VF page.

Our expected result is : If crit.reportingMatch is 1 or 0, cutom picklist also shoud be updated accordingly.

VF

<apex:pageBlockSectionItem >
   <apex:outputText >Match Filter</apex:outputText>
   <apex:selectList value="{!crit.reportingMatch}" size="1">  
      <apex:selectOptions value="{!crit.reportingMatchPicklist}"/>
   </apex:selectList>
</apex:pageBlockSectionItem>

Controller Class

public with sharing class massOppController {

    public massOppCriteria Crit{get; set;}

// Assigning filterRec.Match_Filter__c value(either 0 or 1) to crit.reportingMatch
crit.reportingMatch = String.valueOf(filterRec.Match_Filter__c);

massOppCriteria Class

public String reportingMatch {get;set;}

public static LIST<SelectOption> getReportingMatchPickList() {
        List<SelectOption> reportingMatchPickList = new List<SelectOption>();
        reportingMatchPickList.add(new selectoption('', '- Reporting Match Filter -'));
        reportingMatchPickList.add(new selectoption('0', '0'));
        reportingMatchPickList.add(new selectoption('1', '1'));
        return reportingMatchPickList;
    }
1

One possibility is that the value of filterRec.Match_Filter__c is null. This can occur if the value has not yet been set. If it is null then the following line results in crit.reportingMatch being assigned null.

crit.reportingMatch = String.valueOf(filterRec.Match_Filter__c);

If that happens, the first SelectOption in the list of crit.picklist will be displayed. In your case the first SelectOption is - Reporting Match Filter -.

I suggest adding in some System.debug statements to the controller to track the value of filterRec.Match_Filter__c.

0

I somehow found the issue.

I had to refresh the section where we have the Picklist field. so I addde that section in rerender attribute of the component.

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.