1

I've got a list of fields that I want display on a Visualforce page.

I can get this to work:

<apex:repeat var="animal" value="{!animals}" id="lotsofanimals">  
                           <apex:outputText value=""  >
                                <apex:param value="{!animal['Color_Dog']}" /> 
                           </apex:outputText>
                           <apex:outputText value=""  >
                                <apex:param value="{!animal['Color_Bird']}" /> 
                           </apex:outputText>
                           <apex:outputText value=""  >
                                <apex:param value="{!animal['Color_Cat']}" /> 
                           </apex:outputText>
                           <apex:outputText value=""  >
                                <apex:param value="{!animal['Color_Horse']}" /> 
                           </apex:outputText>
</apex:repeat>

So I thought a better way would be to store 'Color_Dog', 'Color_Cat', etc in its own object and then pass that in. The Name being the field I want to display

and this works:

<apex:repeat var="animal" value="{!animals}" id="lotsofanimals">  
    <apex:repeat var="traits" value="{!animalstraits}" id="lotsofanimalstraits">  
                           <apex:outputText value=""  >
                                <apex:param value="{!animal[traits.Name]}" /> 
                           </apex:outputText>
       </apex:repeat>
    </apex:repeat>

So I thought I could abstract it one more time with something like this:

<apex:repeat var="animal" value="{!animals}" id="lotsofanimals">  
    <apex:repeat var="species" value="{!animalsspecies}" id="lotsofanimalspecies">  
                           <apex:outputText value=""  >
                                <apex:param value="'Color_'{!animal[traits.species]}" /> 
                           </apex:outputText>
       </apex:repeat>
    </apex:repeat>

But that's when I get the error:

The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice.

Any suggestions on how to accomplish this?

One idea I had was to further abstract it again with 'Color_', 'Weight_',etc as another object and then put a 3rd repeat

Thanks!

1

Everything to be resolved needs to be in the merge field, so it'd be:

"{!animal['Color_'&traits.species]}"

I'm not entirely sure that format is supported, but this would be the syntax required.

1
  • I was missing the '&' when I tried 'Color_' inside the []. Thanks!! – LeeFranke May 13 '20 at 18:24

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.