【问题标题】:page not get rendered using ajax in Jsf 2.0页面未在 Jsf 2.0 中使用 ajax 呈现
【发布时间】:2012-03-30 17:57:24
【问题描述】:

我面临着非常奇怪的问题。在我这边调试之后,我想在论坛上发布同样的问题。

问题::我有 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。

我为&lt;f:ajax&gt; 标签尝试了许多组合,但没有任何效果。例如,

<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" />

请告诉我哪里理解有误。

【问题讨论】:

  • 我是否正确地阅读了您的代码,您有两种形式?
  • 嗨,马特,我只有一个表格

标签: ajax jsf-2


【解决方案1】:

它必须引用组件的客户端 ID。对于初学者来说,确定正确客户端 ID 的最简单方法是在浏览器中打开页面,右键单击并查看源代码,然后找到 JSF 组件的 HTML 表示。它看起来像这样

<table id="foo:bar:tableId" ...>

您需要准确地获取这个值并在其前面加上:

<f:ajax render=":foo:bar:tableId" ... />

如果它没有以: 为前缀,默认的NamingContainer 分隔符,那么它将相对于当前的NamingContainer 父级进行解析。此类组件有&lt;h:form&gt;&lt;h:dataTable&gt;&lt;ui:repeat&gt;、复合组件等。

【讨论】:

    猜你喜欢
    • 2012-02-10
    • 2011-05-30
    • 2013-09-27
    • 2012-12-08
    • 1970-01-01
    • 1970-01-01
    • 2013-05-17
    • 2012-04-19
    • 1970-01-01
    相关资源
    最近更新 更多