<h: dataTable value = # {myBean.xxx}>: getXxx () wird so oft aufgerufen, warum?

Einfacher Code überdataTable. CentralFeed ist SessionScoped Bean undPostComment ist RequestScoped Bean

<h:form id="table">
    <h:dataTable value="#{CentralFeed.profileComments}" var="item">
        <h:column>
            <h:outputText value="#{item.comment}"/><br/>
            <h:inputTextarea value="#{item.newComment}" rows="2"/><br/>
            <h:commandButton value="Post" action="#{PostComment.postReply(item)}" />
        </h:column>
    </h:dataTable>
</h:form>

InnerhalbCentralFeed.java

private List<NewsFeed> profileComments = null;

public List<NewsFeed> getProfileComments() {
    PhaseId currentPhaseId = FacesContext.getCurrentInstance().getCurrentPhaseId();
    profileComments = scholarBean.findProfileCommentsByUserId(getSelectedUser().getId());
    //model = new ListDataModel<NewsFeed>(profileComments);
    return profileComments;
}

Mein Problem ist, dassgetProfileComments() viel angerufen bekommen.currentPhaseId teilt uns mit, in welcher Phase die Methode aufgerufen wurde. Wenn die Seite zum ersten Mal geladen wird,getProfileComment Anruf um @ bekomm5 ma, in Phase 6 -RENDER_RESPONSE. Die Seite hat eininputTextarea, also tippe ich da etwas ein und klicke aufPost (die Befehlstaste). DanngetProfileComment ein anderes @ gerufen bekomm 12 mal Phase 1 durchlaufen> 4. Jede Phase nennt diese Methode 3-4 mal. Danach die Setter-Methode des AttributsnewComment get call (also setNewComment () get call), dasgetProfileComment erneut anrufen beiphase 5. DannpostReply() Anruf erhalten, danngetProfileComment erneut anrufen für ein anderes5 ma beimphase 6. Was ist los? Soll es so sein? Wenn du dir mein @ ansiehgetProfileComment, über mein EJBscholarBean, Ich frage die Datenbank tatsächlich ab, daher ist es eine sehr schlechte Idee, die Datenbank 20 Mal abzufragen.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage