2017-07-07 49 views
0

每次我在我的數據表中添加一個新行(通過commandbutton「new Feedback」),它被添加到數據表的底部。我怎樣才能添加它,並確保它會出現在頂部?如何在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> 

回答

0

在該命令gettingFeedbackMulti你的操作方法,你可能做這樣的

sentMessagesList.add(message); 

東西只要改變它使用add()與索引參數這樣

sentMessagesList.add(0, message); 

這將將它添加到您的列表的索引0

+1

感謝您的快速回復,它w orked! – SilverFullbuster

相關問題