繁体   English   中英

如何在JSF的数据表顶部添加新行?

[英]How can I add a new row at the top of my datatable in JSF?

每次我在数据表中添加新行时(通过命令按钮“新反馈”),该行都会添加到数据表的底部。 如何添加它并确保它显示在顶部?

<h:form>
    <h:inputText value="#{helloBean.content}" ></h:inputText>
    <h:commandButton value="send message"
        action="#{helloBean.multiAufruf}">
    </h:commandButton>
    <h:commandButton value="new Feedback"
        action="#{helloBean.gettingFeedbackMulti}">
    </h:commandButton>

    <h:dataTable value="#{helloBean.sentMessagesList}" var="message">
        <h:column>
            <h:inputText value="#{message.content}"></h:inputText>
        </h:column>
        <h:column>
            <h:outputText value="#{message.time}"></h:outputText>
        </h:column>
        <h:column>
            <h:outputText value="#{message.idList}"></h:outputText>
        </h:column>
        <h:column>
            <h:outputText value="#{message.feedbackz}"></h:outputText>
        </h:column>
    </h:dataTable>
</h:form>

在命令gettingFeedbackMulti操作方法中,您可能正在执行以下操作

sentMessagesList.add(message);

只需将其更改为将add()与索引参数一起使用,就像这样

sentMessagesList.add(0, message);

这会将其添加到列表的索引0

暂无
暂无

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

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