简体   繁体   English

持有ui:repeat的面板上的JSF2 f:ajax渲染将数据翻倍

[英]JSF2 f:ajax render on a panel holding a ui:repeat doubles data once

I have a ui:repeat inside ah:panelgroup, and af:ajax outside the panel. 我在ah:panelgroup内有一个ui:repeat,在面板外有af:ajax。 The f:ajax click event triggers a render on the h:panelgroup. f:ajax click事件触发h:panelgroup上的渲染。 When I load the page the repeater shows my 5 items on the list. 当我加载页面时,转发器会在列表中显示我的5个项目。 When I click the button for the first time, the h:panelgroup doubles to 10 items, every subsequent click just refreshes the first 5 items on the panel (as it should). 当我第一次单击该按钮时,h:panelgroup会翻倍至10个项目,随后的每次单击都只会刷新面板上的前5个项目(应如此)。 What am I doing wrong? 我究竟做错了什么? shouldn't the render event always just refresh the panel with the repeater in it? 渲染事件不应该总是只刷新带有中继器的面板吗?

BEAN: 豆角,扁豆:

    @ManagedBean(name = "TestBean")
    @RequestScoped
    public class TestBean {
    private List testStrings;
    public TestBean() {
    Random rn = new Random(System.currentTimeMillis());
    testStrings = Arrays.asList(rn.nextInt(),rn.nextInt(),rn.nextInt(),rn.nextInt(),rn.nextInt());
        }
    }
    public List getTestStrings() {
        return testStrings;
    }

    public void setTestStrings(List testStrings) {
        this.testStrings = testStrings;
    }

JSF: JSF:

    <h:commandButton value="Refresh">
            <f:ajax event="click" render="testPanel"></f:ajax>
    </h:commandButton>
    <p>
    <h:panelGroup id="testPanel">
            <ui:repeat var="option" value="#{TestBean.testStrings}" varStatus="status">
                    <p>
                            <h:outputText value="#{option}"></h:outputText>
                    </p>
            </ui:repeat>
    </h:panelGroup>
    </p>

I am using mojarra 2.1 I think. 我认为我正在使用mojarra 2.1。

Thanks. 谢谢。

ANSWER 回答

The problem doesn't happen if I remove the <p>...</p> and reaplace it with <h:outputText value="#{option}"></h:outputText><br/> 如果删除<p>...</p>并用<h:outputText value="#{option}"></h:outputText><br/>重新放置,则不会发生此问题。

如果删除<p>...</p>并用<h:outputText value="#{option}"></h:outputText><br/>重新放置,则不会发生此问题。

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

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