You need to sign in to do that
Don't have an account?
Correction to Documentation: <apex: ComponentBody>
There is a small error in the documentation for the <apex:componentBody> tag.
The example code for the custom component is the following:
<!-- Component: myaccounts-->
<apex:component controller="myAccountsCon">
<apex:attribute name="var" type="String" description="The variable to represent a single account in the iteration."/>
<apex:repeat var="componentAccount" value="{!accounts}">
<apex:componentBody >
<apex:variable var="a" value="{!componentAccount}"/>
<apex:outputPanel style="border:1px solid black;" layout="block">
{!componentAccount.name}
</apex:outputPanel>
</apex:componentBody>
</apex:repeat>
</apex:component>
The entire example works because you use "a.name" in apex:ComponentBody even though you should be able to pass in and use any variable name you'd like. The lines that need to be changed to make this work are:
<apex:componentBody >
<apex:variable var="a" value="{!componentAccount}"/>
I've made the changes to make the componentBody after the variable tag and changed the variable name to that passed in via the "var" attribute in the component:
<apex:component controller="myAccountsCon">
<apex:attribute name="var" type="String"
description="The variable to represent a single account in the iteration." />
<apex:repeat var="componentAccount" value="{!accounts}">
<apex:variable var="{!var}" value="{!componentAccount}" />
<apex:componentBody >
<apex:outputPanel style="border:1px solid black;" layout="block">
{!componentAccount.name}
</apex:outputPanel>
</apex:componentBody>
</apex:repeat>
</apex:component>
Hope this helps anyone trying to use componentBody within custom components!
ps- Can you have components with custom Facets?
Parker
Thanks Parker. We'll get this fixed.
You can't create custom facets yet but it's on the roadmap. Not sure if there is an idea out there yet for it yet but would help.
Thanks again,