I want to generate facelets code from UIComponent, Eg:
org.primefaces.component.commandbutton.CommandButton;
CommandButton btn=new CommandButton();
btn.setValue("Click");
for this code, the following tag has to be generated
<p:commandButton value="Click" />
what i need is to generate facelet code corresponding to UIComponent object in the bean and code has to be stored and used later.
is it possible??
Take a look at these two articles [1] and [2]. You have to locate the parent component to which you want to attach your new components, create the components and add them as children. Here [3] is an example on how to locate components by id.
[1] - http://www.softwareengineeringsolutions.com/thoughts/frameworks/JSF.Techniques-Adding.Components.Dynamically.htm
[2] - http://www.jsfcentral.com/articles/dynamic_jsf.html
[3] - http://illegalargumentexception.blogspot.com/2009/02/jsf-working-with-component-ids.html