Seguinte pessoal.
Tô desenvolvendo uma tela com Richfaces e JSF e me deparei com o seguinte problema.
Nessa tela, tenho o Painel geral e dentro dele um TabPanel (painel com abas).
Por enquanto, só estou utilizando a primeira aba.
Nesta aba, eu coloquei um panelGrid pra manter a organização dos dados.
Adicionei vario campos de entrada de dados para o meu BackingBean, campos input e selectOneMenu.
Eu fechei o meu Panel Grid, abaixo adicionei um Rich Data Table e um botão para adicionar dados nessa tabela.
Quando eu clico nesse botão para adicionar os dados eu abro um Modal Pane para inserir os dados que serão colocados na tabela, porém, todo o conteúdo que estava preenchido nos meus inputs são apagados.
Alguém sabe a razão disso?
Vou colocar o código pra alguém testar se quiser.
Lembrando que, meu Backing Bean funciona perfeitamente.
Se após preencher a tabela eu re-entrar com os dados no formulário, o Backing Bean é populado corretamente.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<ui:composition template="./layout.xhtml">
<ui:define name="esquerda">
<br/>
</ui:define>
<ui:define name="conteudo">
<a4j:keepAlive beanName="auxilioMB" ajaxOnly="true" />
<h:form>
<script type="text/javascript">
var row;
</script>
<a4j:region>
<rich:panel>
<f:facet name="header">
<h:outputText value="Auxílio" />
</f:facet>
<rich:tabPanel switchType="client">
<!-- TAB 1 ###################################-->
<rich:tab label="First">
<h:form>
<h:panelGrid columns="1">
<a4j:outputPanel ajaxRendered="true">
<h:panelGrid columns="4">
<h:outputText value="Nº Processo Entidade" />
<h:inputText value="#{auxilioMB.auxilio.protocolo}" id="processo"/>
<h:outputText value="" />
<h:outputText value="" />
<h:outputText value="Entidade Financiadora" />
<h:selectOneMenu value="#{auxilioMB.financiador}"
converter="Converter" required="true" id="entidade">
<f:selectItems value="#{auxilioMB.listaFinanciadorCombo}"/>
</h:selectOneMenu>
<h:outputText value="" />
<h:outputText value="" />
<h:outputText value="Início Auxílio" />
<rich:calendar datePattern="dd/MM/yyyy" required="false" value="#{auxilioMB.auxilio.dataInicial}"/>
<h:outputText value="Término Auxílio" />
<rich:calendar datePattern="dd/MM/yyyy" required="false" value="#{auxilioMB.auxilio.dataFinal}"/>
</h:panelGrid>
<rich:dataTable id="tabela" value="#{auxilioMB.listaAlineaBean}" rowClasses="linha1, linha2" var="n" rows="10" columns="2" rowKeyVar="row" reRender="datascroller"
width="100%">
<f:facet name="header">
<h:outputText value="Alíneas" />
</f:facet>
<rich:column sortBy="#{n.descricao}" sortOrder="ASCENDING" width="300px">
<f:facet name="header">
<h:outputText value="Descrição" />
</f:facet>
<h:outputText value="#{n.descricao}" id="nome" />
<f:facet name="footer">
<h:panelGrid>
<h:outputText value="Valor Total R$" id="nomeFooter" />
<h:outputText value="Valor Total U$" id="nomeFooter2" />
</h:panelGrid>
</f:facet>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Valor" />
</f:facet>
<h:outputText value="#{n.verbaAprovada}" id="valor">
<f:convertNumber pattern="###,###,##0.00"/>
</h:outputText>
<f:facet name="footer">
<h:panelGrid>
<h:outputText value="#{auxilioMB.totalReal}" id="valorFooter">
<f:convertNumber pattern="###,###,##0.00"/>
</h:outputText>
<h:outputText value="U$ 000000,00" id="valorFooter2" />
</h:panelGrid>
</f:facet>
</rich:column>
<f:facet name="footer">
<rich:columnGroup>
<rich:column colspan="1">
<rich:datascroller id="datascroller" renderIfSinglePage="false"/>
</rich:column>
<rich:column>
<a4j:commandLink ajaxSingle="true" id="addlink" oncomplete="#{rich:component('editPanel')}.show()" action="#{auxilioMB.prepareAdicionar}" immediate="true">
<h:graphicImage value="/images/icons/add1.png" style="border:0"/>
</a4j:commandLink>
<rich:toolTip for="addlink" value="Add" />
</rich:column>
</rich:columnGroup>
</f:facet>
</rich:dataTable>
<h:panelGrid columns="4">
<h:outputText value="Observações" />
<h:inputText value="#{auxilioMB.auxilio.observacoes}" id="observacao" size="100" maxlength="250"/>
</h:panelGrid>
</a4j:outputPanel>
</h:panelGrid>
<a4j:commandButton value="Cadastrar"
action="#{auxilioMB.cadastraAuxilio}"
status="a4jwaitstatus"/>
</h:form>
</rich:tab>
<!-- TAB 2 ###################################-->
<rich:tab label="Second">
Here is tab #2
</rich:tab>
<!-- TAB 3 ###################################-->
<rich:tab label="Third">
Here is tab #3
</rich:tab>
</rich:tabPanel>
</rich:panel>
</a4j:region>
</h:form>
<a4j:outputPanel ajaxRendered="true">
<!-- ################################### -->
<!-- bloco de edição -->
<rich:modalPanel id="editPanel" autosized="true" width="450">
<f:facet name="header">
<h:outputText value="Editar Registro" />
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/images/close.png" id="hidelink2"
styleClass="hidelink" />
<rich:componentControl for="editPanel" attachTo="hidelink2"
operation="hide" event="onclick" />
</h:panelGroup>
</f:facet>
<h:form>
<rich:messages style="color:red;"></rich:messages>
<h:panelGrid columns="1">
<a4j:outputPanel ajaxRendered="true">
<h:panelGrid columns="3">
<h:outputText value="Alínea" />
<h:selectOneMenu value="#{auxilioMB.alineaBean.descricao}"
converter="Converter" required="true" id="alinea">
<f:selectItems value="#{auxilioMB.listaAlineasCombo}"/>
</h:selectOneMenu>
<rich:message for="alinea" />
<h:outputText value="Valor" />
<h:inputText value="#{auxilioMB.alineaBean.verbaAprovada}" id="valor" >
<f:convertNumber pattern="#,###,##0.00" maxFractionDigits="2"/>
</h:inputText>
<rich:message for="valor" />
</h:panelGrid>
</a4j:outputPanel>
<a4j:commandButton value="Editar"
action="#{auxilioMB.editar}"
reRender="tabela"
oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();"
rendered="#{auxilioMB.editarState}" status="a4jwaitstatus"/>
<a4j:commandButton value="Adicionar"
action="#{auxilioMB.adicionaAlinea}"
reRender="tabela"
oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();"
rendered="#{auxilioMB.adicionarState}" status="a4jwaitstatus"/>
</h:panelGrid>
</h:form>
</rich:modalPanel>
<!-- ################################### -->
<!-- ################################### -->
<!-- bloco de exclusão -->
<!-- ################################### -->
</a4j:outputPanel>
<a4j:status id="a4jwaitstatus" onstart="#{rich:component('wait')}.show()"
onstop="#{rich:component('wait')}.hide()"
forceId="true"/>
<rich:modalPanel id="wait" autosized="true" width="200" height="120"
moveable="false" resizeable="false">
<f:facet name="header">
<h:outputText value="Processando" />
</f:facet>
<h:outputText value="Por favor aguarde..." />
</rich:modalPanel>
<rich:messages></rich:messages>
</ui:define>
<ui:define name="direita">
<a4j:form>
<div id="atualizar">
//...
</div>
</a4j:form>
</ui:define>
</ui:composition>
</html>
Resolvido,
foi só setar para “False” o atributo ajaxSingle=“true” do a4j:commandLink.