I have a questionnaire form in which components (questions) are generated all programatically in my backing bean.
In form submit event I need to collect all user inputs and store them in db.
But JSF does not recognize the dymanically generated components and only finds the ones that are in my Facelets page which are my panelgrid and submit button. This is my submit() method.
public boolean submit() {
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
UIComponent formComponent = viewRoot.findComponent("mainForm"); //form id
HtmlForm form = (HtmlForm)formComponent;
List<UIComponent> componentList = form.getChildren();
for(int p=0; p<componentList.size(); p++) {
UIComponent component = componentList.get(p);
System.out.println("The Component ID is:"+component.getId());
}
return true;
}
So does anyone know where I can hunt my components other than the method above?