<h: dataTable value = # {myBean.xxx}>: getXxx () recibe tantas llamadas, ¿por qué?
Pieza simple de código sobredataTable
. CentralFeed
es SessionScoped Bean, yPostComment
es 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>
dentroCentralFeed.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;
}
Mi problema es quegetProfileComments()
llamarse mucho.currentPhaseId
nos dirá en qué fase se llamó al método. Cuando la página se carga por primera vez,getProfileComment
recibir llamadas5 veces, en la fase 6 -RENDER_RESPONSE
. La página tiene uninputTextarea
, así que escribo allí algo y hago clicPost
(el botón de comando). EntoncesgetProfileComment
llamarse otro12 veces pasando por la fase 1-> 4. Cada fase llama a este método3-4 veces. Luego, después de eso, el método setter del atributonewComment
get call (so setNewComment () get call), elgetProfileComment
recibir llamada nuevamente aphase 5
. EntoncespostReply()
recibir llamada, entoncesgetProfileComment
recibir llamada nuevamente por otro5 veces aphase 6
. Que esta pasando? ¿Se supone que es así? Si miras migetProfileComment
, a través de mi EJBscholarBean
, Realmente consulto la base de datos, por lo que tener que consultar la base de datos como 20 veces es una muy mala idea.