I am working through an example in the "JSF in action book" which displays a dynamic grid(html table) of numbers driven by an input. The jsp portion is below
<p>
<h:panelGrid id="controlPanel"
binding="#{helloBean.controlPanel}"
columns="20" border="1" cellspacing="0"/>
</p>
<h:commandButton id="redisplayCommand" type="submit"
value="Redisplay"
actionListener="#{helloBean.addControls}"/>
The binding bean code is below
public void addControls(ActionEvent actionEvent)
{
Application application = FacesContext.getCurrentInstance().getApplication();
List children = controlPanel.getChildren();
children.clear();
for (int count = 0; count < numControls; count++)
{
HtmlOutputText output = (HtmlOutputText)application.
createComponent(HtmlOutputText.COMPONENT_TYPE);
output.setValue(" " + count + " ");
output.setStyle("color: blue");
children.add(output);
}
}
The code is functional for a few values and then out of nowhere i get this error
"javax.servlet.ServletException: Component ID welcomeForm:j_id51 has already been found in the view"
There doesent seem to be a pattern to when this exception occurs. Is there an way to "drop" a component from its parent?