开发者

VisualForce: Pass a parameter to a custom component inside a repeater

开发者 https://www.devze.com 2023-01-09 01:32 出处:网络
I can\'t figure out why this isn\'t working: <开发者_开发百科apex:repeat value=\"{!MyContacts}\" var=\"c\" >

I can't figure out why this isn't working:

<开发者_开发百科apex:repeat value="{!MyContacts}" var="c" >
    <c:ContactRowComponent contactLastName="{!c.LastName}"/>  
</apex:repeat>

(where on the main controller MyContacts returns an array of Contact objects, and on the component contactLastName is defined as a String attribute)

This gives me error:

Literal value is required for attribute contactLastName in <c:ContactRowComponent> at line 25 column 27

It seems to be saying that a literal value is required and not a formula? Is what I am trying to do impossible, or am I doing it wrong?


I have come across this issue as well. In my case it was because I specified the default attribute in the component attribute which you can't do on fields that use a formula for some reason.

For instance this will produce the error you described when passing in a formula value:

<apex:attribute type="string" name="value" default="sometext" description="some name value" />

So if you remove the default attribute the error will be resolved. Let me know if this solves for your particular use case.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号