Olá Pessoal !!!
Tenho um exemplo de formulário de cadastro que grava corretamente, mas gostaria de limpar os registros dele ao fechar. Segue o código de como chamo o form.
<p:layoutUnit position="left" width="200" header="Atividades" resizable="true" closable="true" collapsible="true">
<h:form prependId="false">
<p:commandButton value="Novo"
action="#{PastelMB.novoPastel}"
update="gerNovo, formCad, infoCad"
oncomplete="dialogCad.show()" />
</h:form>
</p:layoutUnit>
No MB
public void novoPastel(){
pastel = new Pastel();
System.out.println("Criando novo");
}
E o dialog
<p:dialog header="Gerência" widgetVar="dialogCad"
resizable="false" modal="true" width="500">
<p:outputPanel id="gerNovo">
<h:form prependId="false" id="formCad">
<p:messages id="avisoCad"/>
<h:panelGrid id="infoCad" columns="2" style="margin-bottom:10px">
<h:outputLabel value="Nome:"/>
<h:inputText id="nomeCad" value="#{PastelMB.pastel.nome}"
required="true" requiredMessage="Campo [Nome] obrigatório">
<f:validateLength minimum="2" maximum="100" />
</h:inputText>
<h:outputLabel value="Tamanho:"/>
<h:inputText id="tamanhoCad" value="#{PastelMB.pastel.tamanho}"
required="true" requiredMessage="Campo [Tamanho] obrigatório">
<f:validateLength maximum="100" />
</h:inputText>
<p:commandButton value="Salvar"
actionListener="#{PastelMB.cadastra}"
oncomplete="dialogCad.show(); "
update="formCad"
/>
<p:commandButton oncomplete="dialogCad.hide();"
value="Cancelar" />
</h:panelGrid>
</h:form>
</p:outputPanel>
</p:dialog>
Problema que quando fecho o dialog e abro novamente os dados dos campos continuam. Exibe a mensagem “Criando novo” portando passa por ali. O que posso fazer para corrigir ?
Obrigado