0

In my VF page I have:

<apex:pageblockTable value="{!interview.Skill_review__r}" var="skillreview"> 
                    <apex:column headerValue="Rating">
                        <apex:outputField value="{!skillreview.RatingCopy__c}" rendered="{!NOT(interviewerMode)}"/>
                        <apex:outputText value="{!i}"/>
                        <apex:selectList value="{!SkillReviewList1[i].rating}" multiselect="false" size="1" rendered="{!interviewerMode}" >
                            <apex:selectOption itemValue="1" itemLabel="1"/>
                            <apex:selectOption itemValue="2" itemLabel="2"/>
                            <apex:selectOption itemValue="3" itemLabel="3"/>
                            <apex:selectOption itemValue="4" itemLabel="4"/>
                            <apex:selectOption itemValue="5" itemLabel="5"/>
                        </apex:selectList>
                        <apex:variable var="i" value="{!i+1}"/>
                    </apex:column>
</apex:pageblockTable>

By doing this I get an error when try to get the values . Error - Subscript value 5 not valid. Must be between 0 and 4.

I see it is because in the column rating I only have 5 rows. The <apex:selectList value="{!SkillReviewList1[i].rating}" should only have i value from 0 to 4. How can I control this behavior? i should only increment till 4 , I dont understand why it goes to 5 in <apex:selectList value="{!SkillReviewList1[i].rating}"

  • You didn't happen to start off with <apex:variable name="i" value="{!1}" /> did you? – sfdcfox Jun 6 '16 at 22:07
  • No , I started off by <apex:variable name="i" value="{!0}" /> – SfdcBat Jun 6 '16 at 22:20
  • 1
    SkillReviewList1.size() should be the same as interview.Skill_review__r.size(). if this is not true, you'll get an exception. – sfdcfox Jun 6 '16 at 22:25
  • 4
    this admonition in the SFDC VF doc is worth noting Note: <apex:variable> does not support reassignment inside of an iteration component, such as <apex:dataTable> or <apex:repeat>. The result of doing so, e.g., incrementing the <apex:variable> as a counter, is unsupported and undefined. I've seen lots of folks ignore this though in countless posts – cropredy Jun 6 '16 at 22:26
  • I had to use <apex:variable name="i" value="{!-1}" /> to make this work! Strange! – SfdcBat Jun 6 '16 at 22:40

Your Answer

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

Browse other questions tagged or ask your own question.