【发布时间】:2015-07-22 04:19:22
【问题描述】:
我想用 bean 中的新组件“更新”一个组件。
XHTML
<composite:interface>
<composite:attribute name="rootKey" required="true" />
<composite:attribute name="id" required="true" />
</composite:interface>
<composite:implementation>
<rich:panel id="#{cc.attrs.id}" binding="#{myBean.customPanel}"/>
<a4j:jsFunction name="createPanels"
action="#{myBean.createPanels}"
render="#{cc.attrs.id}">
<a4j:param name="rootId" assignTo="#{myBean.rootId}"/>
<a4j:param name="rootKey" assignTo="#{myBean.rootKey}"/>
</a4j:jsFunction>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function() {
createPanels('#{cc.attrs.id}','#{cc.attrs.rootKey}');
});
/*]]> */
</script>
</composite:implementation>
</ui:composition>
豆子
private UIPanel rootPanel;
public void setCustomPanel(UIPanel panel) {
rootPanel = panel;
}
public UIPanel getCustomPanel() {
return rootPanel;
}
public void createPanels() {
//try #1 : Adding new panels as children
rootPanel.getChildren().add((UIPanel)createPanels(rootId,rootKey));
//try #2 : A new Panel component
rootPanel = (UIPanel)createPanels(rootId,rootKey);
...
rootPanel.setId(rootId); // this ID is the same as the 'placeholder' panelId
FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(rootPanel.getId()); // the rerender should also already be done in the XHTML js function.
}
使用调试器,我看到 rootPanel 更改为新面板组件,但不在视图中。 我想念什么?
简而言之:在 xhtml 视图中为面板组件动态生成子组件。生成需要“rootKey”参数来生成正确的集合。
使用:
- JSF 莫哈拉 2.1.19
- 富豪脸
【问题讨论】:
-
您是否检查过来自服务器的响应? (你可以把 a4j:log 放到你的页面上查看)。
-
嗯,不,我没有检查响应。我不熟悉页面上的 a4j:log。生病检查日志功能(对于未来的问题很可能非常有用)
标签: jsf richfaces components javabeans