Qual escopo vcs costumam usar para uma tela que contem apenas uma tabela com registros e filtros para a mesma?
Estou com um problema chato...no projeto estou usando CDI, então tenho a disposição quatro escopos pro meu managed bean:
@RequestScoped
@ConversationScoped
@SessionScoped
@ApplicationScoped
Essa tela possui uma tabela com dataScroller para ela. Quando o usuário clica em outra página, a tabela deveria apenas ser atualizada através de um requisicao ajax. Mas, por alguma razão, o managed bean está sendo criado novamente...então eu perco todos os dados da tela e etc!
Estou usando para esse bean o @ConversationScoped, gostaria de usar o @ViewScoped mas ele simplesmente não funciona também...
Eu chamo o begin() no método anotado com a @PostContruct....mas toda vez que faço uma requisição ajax ou qualquer coisa ele passa nesse método....
Alguém tem ideia do que possa estar acontecendo?
Obrigado!
Segue o código:
@Named
@ConversationScoped
public class NegotiationWorkflowListBean implements Serializable {
@Inject
private Conversation conversation;
/*
* Declaração de variáveis...getters, setters e etc...
*/
@PostConstruct
public void beginConversation() {
conversation.begin();
}
public void search() {
/*codigo de consulta*/
}
}
Trecho com ajax e executa o método search...quando clico nesse botão o código do beginConversation é executado novamente
<ui:define name="main">
<h:form>
<a4j:region>
<h:panelGrid columns="4">
<h:outputLabel
value="#{bundles.messages.negotiationWorflow_negotiationNumber}"
styleClass="labels" />
<h:inputText
value="#{negotiationWorkflowListBean.filterNegotiationNumber}" />
<h:outputLabel
value="#{bundles.messages.negotiationWorflow_negotiationManager}"
styleClass="labels" />
<h:inputText
value="#{negotiationWorkflowListBean.filterNegotiationManager}" />
<h:outputLabel
value="#{bundles.messages.negotiationWorflow_negotiationAgency}"
styleClass="labels" />
<h:inputText
value="#{negotiationWorkflowListBean.filterNegotiationAgency}" />
<h:outputLabel
value="#{bundles.messages.negotiationWorflow_negotiationClientGroup}"
styleClass="labels" />
<h:inputText
value="#{negotiationWorkflowListBean.filterNegotiationClientOrGroup}" />
<h:outputLabel
value="#{bundles.messages.negotiationWorflow_negotiationType}"
styleClass="labels" />
<h:selectOneMenu
value="#{negotiationWorkflowListBean.filterNegotiationType}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{negotiationWorkflowListBean.negotiationTypes}"
var="type" itemLabel="#{type}" itemValue="#{type}" />
<f:converter converterId="negotiationTypeConverter" />
</h:selectOneMenu>
<h:outputLabel
value="#{bundles.messages.negotiationWorflow_negotiationStatus}"
styleClass="labels" />
<h:selectOneMenu value="#{negotiationWorkflowListBean.filterNegotiationStatus}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{negotiationWorkflowListBean.negotiationStatus}"
var="status" itemLabel="#{status}" itemValue="#{status}"/>
<f:converter converterId="negotiationStatusConverter"/>
</h:selectOneMenu>
</h:panelGrid>
<a4j:commandButton
value="#{bundles.messages.negotiationWorflow_search}"
action="#{negotiationWorkflowListBean.search}" render="table scroll" />
</a4j:region>
<rich:dataTable id="table"
</rich:dataTable>
<h:panelGrid columns="1" styleClass="pagination">
<rich:dataScroller id="scroll" for="table" page="1" maxPages="5" />
</h:panelGrid>
</h:form>
</ui:define>
