Dynamic creation of outputLabel

Sample Code:


Visualforce page:

<apex:page controller=”Sample” sidebar=”false”>
    <apex:pagemessages />
    <apex:dynamicComponent componentValue=”{!lbl}”/>
</apex:page>



Apex Code:

public class Sample
{
    public Component.Apex.OutputLabel getlbl()
    {
        Component.Apex.OutputLabel lb = new Component.Apex.OutputLabel();
        lb.Value = ‘Sample’;
        return lb;
    }     
}





Output:

Leave a Reply