gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 12:40:07 26 4
gpt4 key购买 nike

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

<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

关于java - 如何在 JSF 中的数据表顶部添加新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44974012/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com