简体   繁体   English

在Jsf 2.0中无法使用Ajax渲染页面

[英]page not get rendered using ajax in Jsf 2.0

I am facing very strange problem. 我面临一个非常奇怪的问题。 After debugging from my side, I thought to post the same question on forum. 从我这边调试之后,我想在论坛上发布相同的问题。

Problem: : I have 2 JSF Datatables say "TableA" and "TableB". 问题:我有2个JSF数据表,分别是“ TableA”和“ TableB”。 I have some elements in TableB and now I want to move some articles based on criteria to move to TableA and get deleted or not visible in TableB. 我在TableB中有一些元素,现在我想根据条件移动一些文章,以移至TableA并在TableB中删除或不可见。

I am able to add elements in TableA and can see that element has been deleted from TableB also through debugger as I printed the elements present in TableB but the same changes does not get reflected on UI. 我能够在TableA中添加元素,并且可以看到当我打印TableB中存在的元素时,也已经通过调试器从TableB中删除了该元素,但是相同的更改未反映在UI上。

Code is: 代码是:

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

Here, articleSelectionForm is the form name artDescTable refers to TableA selectedArtTable refers to TableB. 在此,articleSelectionForm是表单名称artDescTable引用TableA的形式,selectedArtTable引用TableB的形式。

I have tried many combinations for the <f:ajax> tag, but nothing works out. 我已经为<f:ajax>标记尝试了多种组合,但是没有任何效果。 Example, 例,

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

Please tell me where I am wrong in understanding. 请告诉我我理解上的错误之处。

It must refer the client ID of the component. 它必须引用组件的客户端ID。 For starters, the easiest way to figure the proper client ID is to open the page in browser, rightclick and View Source and locate the HTML representation of the JSF component. 对于初学者来说,确定正确的客户机ID的最简单方法是在浏览器中打开页面,右键单击并查看源,然后找到JSF组件的HTML表示形式。 It'll look like this 看起来像这样

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

You need to take exactly this value and prefix it with : . 您需要精确地获取此值,并在其前面加上:

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

If it's not prefixed with : , the default NamingContainer separator character, then it will be resolved relative to the current NamingContainer parent. 如果它没有以默认前缀NamingContainer分隔符: NamingContainer ,则它将相对于当前NamingContainer父级解析。 Such components are <h:form> , <h:dataTable> , <ui:repeat> , composite components, etc. 这样的组件是<h:form><h:dataTable><ui:repeat> ,复合组件等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM