JSF-Komponenten dynamisch erstellen

Variante 1:

import javax.faces.context.FacesContext;
import javax.faces.application.Application;
import javax.faces.component.html.HtmlInputText;
 
...
 
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
HtmlInputText input = (HtmlInputText) app.createComponent(HtmlInputText.COMPONENT_TYPE);

Variante 2:

import javax.faces.component.html.HtmlInputText;
 
...
 
HtmlInputText input = new HtmlInputText();