You need to sign in to do that
Don't have an account?

Dynamic Visualforce Components and Merge Fields
Can the new Dynamic Visualforce Components be used to generate an outputText tag with merge fields, such that the merge fields are resolved when the page is displayed? Something like this.
<apex:page standardController="Account" extensions="dynamicSample">
Name: <apex:dynamicComponent componentValue="{!dynamicName}"/>
</apex:page>
public class dynamicSample {
public Component.Apex.OutputText getName () {
String x = new Component.Apex.OutputText;
x.value = "{!Account.Name}" ;
return x ;
}
}
Yes, but to set an expression on a dynamic component attribute you use
x.expressions.value="{!Account.name}"
What if there are multiple merge fields? Something like "Your first name is {!Account.FirstName} and your surname is {!Account.Surname}" ? Any way of doing that?
TIA
To answer trhe question, this is doable. You can say:
x.expressions.value = 'Your first name is {!Account.FirstName} and your surname is {!Account.Surname}' ;
and it will display correctly in the VF page. However, I discovered a bug in the SFDC implementation of this (which I notified SFDC about). If the last char of x.expressions.value is a period (.), then it causes an internal error. So this will cause that to happen:
x.expressions.value = 'Your first name is {!Account.FirstName} and your surname is {!Account.Surname}.' ; // Note period at end
ApeX Page:-
<apex:page controller="examples15" >
<apex:form >
<apex:dynamicComponent componentValue="{!outtext}"/>
<apex:dynamicComponent componentValue="{!cmdbutton}"/>
</apex:form>
</apex:page>
Apex Controller:-
public class examples15
{
public Component.Apex.OutputText getOuttext()
{
Component.Apex.OutputText outText = new Component.Apex.OutputText();
outText.value = 'Some dynamic output text.';
return outText;
}
public Component.Apex.CommandButton getcmdbutton()
{
Component.Apex.CommandButton cmdbutton = new Component.Apex.CommandButton();
cmdbutton.value = 'Click';
return cmdbutton;
}
}
Kindly Check it and Send Response.
Are you haviong a problem with it?