I'm trying to create Primefaces UIComponents programmatically and somehow I'm not able to get the data to the Backing Bean. Not sure if it's the Ajax or the value I set for the InputText. My code that I want to write programmatically:
<p:inputText id="id_test" value="#{myBean.value}">
<p:ajax />
</p:inputText>
This is how I tried to solve the problem:
private String value; // Getter&Setter
public void buildComponent(){
FacesContext fc = FacesContext.getCurrentInstance();
Application ap = fc.getApplication();
InputText inputText = (InputText) ap.createComponent(fc, "org.primefaces.component.InputText", "org.primefaces.component.InputTextRenderer")
inputText.setValue(value);
inputText.setId("id_test");
AjaxBehavior ajaxBehavior = (AjaxBehavior) ap.createBehavior(AjaxBehavior.BEHAVIOR_ID);
inputText.addClientBehavior(inputText.getDefaultEventName(), behavior);
}