Problem with ViewScope
adsonvinicius Feb 17, 2012 11:58 AMHi, i'm starting with RF4 and i'm having some problems... At this time, i need to pass a query string value to one page, get it and process it. The problem it's because the page which i want to pass and to get the query string value are the same, to do that i saw at google i need to use view scope session, but with this scope i can't re-render after update the bean since my bean's scope is a view scope.
Does anyone can help me? I accept others suggestions to solve this problem...
In categorias.xhtml...
<h:form>
<rich:panel style="padding:0" headerClass="outpanelHeader" rendered="#{categoriasMB.allCategorias != null}" >
<div align="center">
<rich:dataGrid value="#{categoriasMB.allCategorias}" iterationStatusVar="it2" style="background-image:url(arquivos/background.png)" id="tabela" var="item" columns="3" elements="9">
<rich:column colspan="0" rowspan="0">
<div align="center">
<h:graphicImage url="#{config.caminho}#{item.imagem}"/>
<br/>
<h:outputText style="font-size:14px" styleClass="textoNome" value="#{item.nome}" />
<br/>
<h:commandButton value="Abrir" styleClass="no-decor" action="#{categoriasMB.abrirLink}">
<f:param name="id" value="#{item.id}" />
</h:commandButton>
<a4j:commandButton value="Editar" styleClass="no-decor" render="editPaneAI" execute="@this" oncomplete="#{rich:component('editPaneAI')}.show()">
<f:setPropertyActionListener target="#{categoriasMB.editedCategoria}" value="#{item}" />
</a4j:commandButton>
<a4j:commandButton value="Remover" styleClass="no-decor" execute="@this" oncomplete="#{rich:component('confirmPaneAI')}.show()">
<f:setPropertyActionListener target="#{categoriasMB.editedCategoria}" value="#{item}" />
</a4j:commandButton>
</div>
</rich:column>
<f:facet name="footer">
<rich:dataScroller></rich:dataScroller>
<a4j:commandButton value="Nova Categoria" onclick="#{rich:component('addPaneAI')}.show();" />
</f:facet>
</rich:dataGrid>
</div>
</rich:panel>
</h:form>
In categoriasMB
...
public CategoriasMB() {
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
int id = (Integer.parseInt(iexternalContext.getRequestParameterMap().get("id"));
allCategorias = DAO.getCategorias(id);
}
}
public String abrirLink(){
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
String id = externalContext.getRequestParameterMap().get("id");
return "categorias?faces-redirect=true&id_categoria="+id;
}
...