2

I have a scenario where there are repeating Tabs. Within each tab, there are multiple drop-down lists (say DL1, DL2, DL3). DL2 is dynamically generated based on the value selected from DL1. And DL3 is dynamically generated based on the value from DL2. I implemented something similar as:

<apex:repeat id="repeat1" value="{!reps}" var="rep">
.
.
.
    <div id="div1-{!rep.id}">
        <apex:outputPanel id="DL1" >
            <apex:selectList value="{!selectedVal1}" size="1" id="SL1">
                <apex:selectOptions value="{!list1}" />                                                                                                                                
                    <apex:actionSupport event="onchange" rerender="DL2"/>                                         
            </apex:selectList>
        </apex:outputPanel>
    </div> 
    <div id="div2-{!rep.id}">
        <apex:outputPanel id="DL2" >
            <apex:selectList value="{!selectedVal2}" size="1" id="SL2">
                <apex:selectOptions value="{!list2}" />                                                                                                                                
                    <apex:actionSupport event="onchange" rerender="DL3"/>                                         
            </apex:selectList>
        </apex:outputPanel>
    </div>          
    <div id="div3-{!rep.id}">
        <apex:outputPanel id="DL3" >
            <apex:selectList value="{!selectedVal3}" size="1" id="SL3">
                <apex:selectOptions value="{!list3}" />                                                          
            </apex:selectList>
        </apex:outputPanel>
    </div>
.
.
.
</apex:repeat>

Issue: Rerender is not getting triggered on DL1. This seems to be because this is within the "repeat" because I have a similar feature implemented outside repeat and it works without any issues.

I tried the following options after browsing several links but still no luck

  1. Set Outputpanel layout attribute to "none"

  2. Tried to assign a dymanic id to Outputpanel. But VisualForce throws error " Literal value is required for attribute id in <apex:outputPanel>"

  3. Modified code to rerender as rerender="repeat1:DL2"

  4. Modified code to rerender as rerender = "{!$Component.DL2}

I am a newbie to SalesForce. Any help would be greatly appreciated!

Thank you!

9
  • Shouldn't your div ids merge in {!rep} and not {!var}?
    – Adrian Larson
    May 4, 2015 at 19:05
  • Also just a hunch...you may want to look into picklist dependencies so you can configure this behavior instead.
    – Adrian Larson
    May 4, 2015 at 19:06
  • @AdrianLarson - You are correct, the div ids are merged with {!rep.id}. I typed them by mistake, I corrected it now. The data for the drop down lists are pulled via external webservices. Hence the drop down lists has to be dynamic... I am also looking for other options to make it work.. If nothing helps, moving outside the repeat would work but I want that to be the last option.. thanks for your comment..
    – Pel
    May 4, 2015 at 19:15
  • Well the other issue is you have id collision, every iteration through your repeat generates another outputPanel whose id is "DL1". Unfortunately I don't think you can merge values into standard component ids. Have you tried rerendering the entire repeat?
    – Adrian Larson
    May 4, 2015 at 19:18
  • Tried now to set rerender to repeat id, this is not triggering too.
    – Pel
    May 4, 2015 at 19:26

1 Answer 1

0

Thank you for the help! The issue is fixed now after the below changes

  1. Unknowingly I had the selectList value declared as both the list and the getter by mistake which prevented the onchange event to trigger. I removed those duplicates.
  2. As the selectList value was static, the value was not set correctly. Modified it to store in a Map so that it can be dynamic for each repeat

You must log in to answer this question.

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