如何重新渲染使用;

发布于 2024-09-16 02:08:48 字数 1696 浏览 4 评论 0原文

我已经实现了一个由转发器创建的列表:

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

以及一个过滤我的列表的按钮:

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

那么,有没有一种简单的方法可以在单击命令链接(使用 AJAX)后仅渲染我的转发器:-)


我尝试了以下操作:

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

但这并没有工作..


更新

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

也不起作用...也许我必须将操作方法​​(overviewController.filterNew)放入ajax标签中?


更新2

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

也不起作用!


也许无法重新渲染中继器?是否还有其他元素,例如 div 标签或可以重新渲染的元素???

...

感谢您的帮助

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


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?


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

...

Thank you for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

飘逸的'云 2024-09-23 02:08:48

本身不会生成任何 HTML 输出。 需要 HTML DOM 树中存在的 ID。将其放入带有 id 中并引用它。

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

The <ui:repeat> itself does not generate any HTML to the output. The <f:ajax render> expects an ID which is present in the HTML DOM tree. Put it in a <h:panelGroup> with an id and reference it instead.

<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>
强者自强 2024-09-23 02:08:48

是:

  • 使用 Richfaces
  • 使用 JSF 2.0
  • 使用 Primefaces

Yes:

如何视而不见 2024-09-23 02:08:48
<f:ajax render="repeater">
ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>
<f:ajax />

你为什么用 f:ajax 包装它?在这种情况下这是多余的。

确保您的组件被 标签包围

<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>
<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? It's redundant in this case.

Make sure that your components are surrounded by <h:form> tag

<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>
如梦初醒的夏天 2024-09-23 02:08:48

这个怎么样:

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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文