Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically Adding Components

Andrew Rigsby
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to add components to the JSF tree at runtime within an event listener but the added components aren't displayed. My code is as follows:

*** jsp page ***
<h:form id="jsfForm">
<h:commandButton type="submit" value="Submit" immediate="true" action="#{actionBean.processAction}">

*** actionBean.processAction implementation ***
FacesContext fContext = FacesContext.getCurrentInstance();
Application app = fContext.getApplication();
UIViewRoot view = fContext.getViewRoot();

UIComponent form = view.findComponent("jsfForm");
HtmlOutputText newComponent = (HtmlOutputText) app.createComponent("javax.faces.HtmlOutputText");

return "success";

Could anyone suggest why the added HtmlOutputText component isn't displayed?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic