【发布时间】:2012-04-11 07:05:24
【问题描述】:
我正在研究“JSF in action book”中的一个示例,该示例显示了由输入驱动的数字的动态网格(html 表格)。下面是jsp部分
<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}"/>
绑定bean代码如下
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);
}
}
代码对一些值有效,然后我不知从哪里得到这个错误
“javax.servlet.ServletException: 组件 ID welcomeForm:j_id51 已在视图中找到”
似乎没有一种模式可以确定何时发生此异常。有没有办法从父组件中“删除”组件?
【问题讨论】:
标签: jsf components