我面临着非常奇怪的问题。从我这边调试后,我想在论坛上发布同样的问题。
问题::我有2个JSF数据表说“TableA”和“TableB”。我在TableB中有一些元素,现在我想根据标准移动一些文章移动到TableA并在TableB中删除或不可见。
我能够在TableA中添加元素,并且可以通过调试器看到该元素已从TableB中删除,因为我打印了TableB中存在的元素,但相同的更改不会反映在UI上。
代码是:
<div id="selectedTableId" class="ArtSlected">
<h:dataTable id="selectedArtTable" value="#{articleBean.artList1}" var="sel" width="100%" border="0" cellspacing="0"
cellpadding="0" columnClasses="center" class="TableStyle">
<h:column>
<h:commandButton id="deleteArticle" image="../resources/images/Delete.png" action="#{articleBean.deleteAction}">
<f:setPropertyActionListener target="#{articleBean.articuloPromocionVO}" value="#{sel}"/>
<f:ajax render=":articleSelectionForm:artDescTable selectedArtTable" execute="@form"/>
</h:commandButton>
</h:column>
<h:column>
<f:facet name="header">#{msgs.mpromo_article_selection_articles_selected}</f:facet>
#{sel.articuloNombre} - #{sel.descripcion}
</h:column>
</h:dataTable>
</div>
这里,articleSelectionForm是表单名称 artDescTable是指TableA selectedArtTable是指TableB。
我为<f:ajax>
标签尝试了很多组合,但没有任何效果。例如,
<f:ajax render=":articleSelectionForm:artDescTable selectedArtTable" execute="@form" />
<f:ajax render=":articleSelectionForm:artDescTable :articleSelectionForm:selectedArtTable" execute="@form" />
<f:ajax render=":articleSelectionForm:artDescTable :articleSelectionForm:selectedTableId:selectedArtTable" execute="@form" />
请告诉我理解错误的地方。
答案 0 :(得分:0)
必须引用组件的客户端ID。对于初学者来说,确定正确客户端ID的最简单方法是在浏览器中打开页面,右键单击查看源并找到JSF组件的HTML表示。它看起来像这样
<table id="foo:bar:tableId" ...>
您需要完全此值,并在其前面添加:
。
<f:ajax render=":foo:bar:tableId" ... />
如果它没有:
作为默认NamingContainer
分隔符字符的前缀,则它将相对于当前NamingContainer
父级进行解析。此类组件包括<h:form>
,<h:dataTable>
,<ui:repeat>
,复合组件等。