I have 2 selectList on each row of a table. When the first one is changed, I need to modify the selectOptions of the second one. Currently, the ActionSupport is only called on one line and if the second selectList is changed from Null to any value.

Here is the code for the Apex page :

<apex:outputPanel styleClass="form-group" id="detailsDiv">
    <span class="col-xs-4">{!$ObjectType['MyCustomObject__c'].fields['Details__c'].Label}</span>
    <div class="col-xs-8">
        <table border="0">
            <apex:repeat value="{!convWrapper.Details}" var="detailsId">
                        <apex:selectList value="{!convWrapper.Details[detailsId].someObject__c.Field1__c}" size="1">
                            <apex:selectOptions value="{!convWrapper.Details[detailsId].ListOfFields1}" />
                            <apex:actionSupport event="onchange" action="{!field1Changed}" reRender="detailsDiv">
                                <apex:param name="DetailsIdName" value="{!detailsId}" assignTo="{!detailsIdChanged}"/>
                        <apex:selectList value="{!convWrapper.details[detailsId].someObject__c.Field2__c}" size="1" >
                            <apex:selectOptions value="{!convWrapper.details[detailsId].ListOfFields2}"/>



And the code for the Controller :

public void field1Changed() {

    if (convWrapper != null) {
        convWrapper.Details.get(detailsIdChanged).someObject__c.Field2__c = null;
        convWrapper.Details.get(detailsIdChanged).ListOfFields2 = convWrapper.getListOfFields2FromField1(convWrapper.Details.get(detailsIdChanged).someObject__c.Field1__c);


Here is the code for getListOfFields2FromField1 :

public List<SelectOption> getListOfFields2FromField1(String field1) {
    List<SelectOption> listFields2 = new List<SelectOption>();
    if (String.isNotBlank(field1)) {
        listFields2.add(new SelectOption('---', '---'));
        if (Field1ToField2Map.containsKey(Field1)) {                        
            for (FieldObject2 field2 : Field1ToField2Map.get(Field1)) {
                if (field2 != null && field2.name__c != null) {
                    listFields2.add(new SelectOption(field2.Id, field2.name__c));
    return listFields2;
  • What is not working? Your question is not clear. Mar 12, 2018 at 8:59
  • What I want : The Action Support of the first field triggers everytime the field is changed (only the action support on the same line, of course).
    – N. Germeau
    Mar 12, 2018 at 9:03
  • What happening : The Action Support only triggers on one line and if the second selectList is changed from Null to any value. (For the other lines, it nevers triggers)
    – N. Germeau
    Mar 12, 2018 at 9:04
  • Then you need to add it to second selectList as well. Mar 12, 2018 at 9:06
  • Why ? I don't need to do any change if I change the second one. I will try to be more clear. By example, I have 3 lines, the first have values for both fields, the second and the third ones have only a value for the first field. If I change the first field of the second line, the actionSupport triggers and changes the selectOptions for the second field of the second line. If I change the first field of the first or the third line, the ActionSupport doesn't trigger but should.
    – N. Germeau
    Mar 12, 2018 at 9:18

1 Answer 1


Ok, found it !

listFields2.add(new SelectOption('---', '---'));

needs to be corrected as

listFields2.add(new SelectOption('', '---'));

You must log in to answer this question.

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