简体   繁体   English

如何重新渲染<ui:repeat>使用<f:ajax render>

[英]How to re-render <ui:repeat> using <f:ajax render>

I have implemented a list created by a repeater:我已经实现了一个由中继器创建的列表:

<ui:repeat value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

and a Button that filters my list:和一个过滤我的列表的按钮:

<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
</h:commandLink>

So, is there an easy way to render only my repeater after clicking the command link (with AJAX) :-)那么,是否有一种简单的方法可以在单击命令链接(使用 AJAX)后仅呈现我的转发器 :-)


I tried following:我尝试了以下操作:

<f:ajax render="repeater">
ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>
<f:ajax />


<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
<f:ajax event="click" render="repeater"/>
</h:commandLink>

but that did not work..但这不起作用..


Update更新

<h:form>
ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
<f:ajax event="click" render="repeater"/>
</h:commandLink>
</h:form>

doesn't work either... Maybe I hav to put the action method (overviewController.filterNew) into the ajax tag?也不起作用...也许我必须将操作方法​​ (overviewController.filterNew) 放入 ajax 标记中?


Update 2更新 2

    <f:ajax event="click" render="repeater">
    <h:commandLink action="#{overviewController.filterEBus}">
    <h:outputText value="EBusiness" />
    </h:commandLink>
    </f:ajax>

Doesn't work either!也不行!


Maybe it's not possible to rerender a repeater ?也许不可能重新渲染中继器? is there another element like a div tag or something that can be rerendered???是否有另一个元素,如 div 标签或可以重新渲染的东西???

... ...

Thank you for your help谢谢您的帮助

The <ui:repeat> itself does not generate any HTML to the output. <ui:repeat>本身不会为输出生成任何 HTML。 The <f:ajax render> expects an ID which is present in the HTML DOM tree. <f:ajax render>需要一个存在于 HTML DOM 树中的 ID。 Put it in a <h:panelGroup> with an id and reference it instead.将它放在带有id<h:panelGroup>并引用它。

<h:form>
    <h:panelGroup id="projects">
        <ui:repeat value="#{projectData.paginator.list}" var="project">
            <h:outputText value="#{project.title}" />
        </ui:repeat>
    </h:panelGroup>
    <h:commandLink action="#{overviewController.filterNew}">
        <h:outputText value="Filter List" />
        <f:ajax execute="@form" render="projects" />
    </h:commandLink>
</h:form>

Yes:是的:

<f:ajax render="repeater">
ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>
<f:ajax />

why did you wrap it with f:ajax?你为什么用 f:ajax 包装它? It's redundant in this case.在这种情况下它是多余的。

Make sure that your components are surrounded by <h:form> tag确保你的组件被<h:form>标签包围

<h:form>
<ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
<f:ajax event="click" render="repeater"/>
</h:commandLink>
</h:form>

How about this:这个怎么样:

<ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

<h:commandLink>
  <h:outputText value="Filter List" />
  <f:ajax render="repeater" listener="#{overviewController.filterNew}" />
</h:commandLink>

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

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