Many errors on screen. Data table and autocomplete primefaces - jsf-2

My data table does not show exclusion message. I put the id of message on update metod of commandbutton inside of data table, but i receive Cannot find component with identifier "messages" referenced from "j_idt31:
The Autocomplete does not works. error occurs in the name of the converter. I put the name beginning whith upper and lower cases but not works. I receive
Jul 29, 2013 4:11:19 PM com.sun.faces.application.ApplicationImpl createConverter
SEVERE: JSF1006: Não pode criar instância para o conversor de tipo pacienteConverter
<ui:define name="conteudo">
<h:form>
<p:panelGrid columns="2" id="painel"
style="width: 100%; margin-top: 20px" columnClasses="rotulo, campo">
<p:outputLabel value="Nome do paciente" for="nPaciente" />
<p:autoComplete value="#{cadastroPacienteBean.pacienteSelecionado}" id="nPaciente"
completeMethod="#{cadastroPacienteBean.pacientes}" var="p"
itemLabel="#{p.name}" itemValue="#{p}" converter="pacienteConverter"
forceSelection="true">
<f:facet name="itemtip">
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="Nome do Paciente: " />
<h:outputText value="#{p.nomePaciente}" />
</h:panelGrid>
</f:facet>
</p:autoComplete>
</p:panelGrid>
<p:messages id="messages" showDetail="false" showSummary="true" />
<p:dataTable id="dataTable" var="paciente"
value="#{consultaPacienteBean.pacientes}" paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<p:column sortBy="#{paciente.nomePaciente}"
headerText="nome do Paciente">
<h:outputText value="#{paciente.nomePaciente}" />
</p:column>
<p:column style="width: 100px; text-align: center">
<p:button icon="ui-icon-pencil" outcome="CadastroPaciente"
title="Editar">
<f:param name="codigo" value="#{paciente.codigo}" />
</p:button>
<p:commandButton action="#{consultaPacienteBean.excluir}"
icon="ui-icon-trash" title="Excluir" update="dataTable,messages"
ajax="true">
<f:setPropertyActionListener
target="#{consultaPacienteBean.pacienteSelecionado}"
value="#{paciente}" />
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
My class Converter :
#FacesConverter(forClass=Paciente.class)
public class PacienteConverter implements Converter {
}

Related

Primefaces confirmDialog doesn't show up after one call

I have a problem with PrimeFaces <p:confirmDialog>, when I click on the <p:commandLink> that must show up the dialog and choose 'No', everything is fine. But when I click on yes,everything works just the first time.
When the process is over and I click again on any <p:commandLink>, the dialog doesn't show up unless I refresh the whole page.I had try everything but I cannot figure out what can be the problem.
<h:form>
<p:dataTable border="0" rules="all" value="#{userBean.users}" var="user" autoUpdate="true" styleClass="table table-hover" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="6,10,15" >
<p:column>
<f:facet name="header">
<h:outputText value="Login" />
</f:facet>
<h:outputText value="#{user.login}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandLink class="badge bg-red marge-left" onclick='PF("cdu#{user.id}").show()' title="Supprimer un utilisateur"><span class="fa fa-trash-o"/></p:commandLink>
<p:confirmDialog ajax="true" message="Voulez vous vraiment supprimer l'utilisateur '#{user.login}'" closable="true" header="Confirmation" severity="alert" widgetVar="cdu#{user.id}" >
<p:commandButton value="oui" actionListener="#{userBean.deleteUser}" update="#form" onclick='PF("cdu#{user.id}").hide()' styleClass="btn btn-primary"/>
<p:commandButton value="non" onclick='PF("cdu#{user.id}").hide()' type="button" styleClass="btn btn-danger" />
</p:confirmDialog>
</p:column>
</p:dataTable>
</h:form>
I had finally resolved my problem. I changed the <p:confirmDialog> by a global one and it works.
<h:form>
<p:dataTable border="0" rules="all" value="#{userBean.users}" var="user" autoUpdate="true" styleClass="table table-hover">
<p:column>
<f:facet name="header">
<h:outputText value="Login" />
</f:facet>
<h:outputText value="#{user.login}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Nom" />
</f:facet>
<h:outputText value="#{user.firstName} #{user.lastName}" />
</p:column>
<p:column style="width:200px;">
<f:facet name="header">
<h:outputText value="Email" />
</f:facet>
<h:outputText value="#{user.email}" />
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandLink class="badge bg-blue marge-left" action="#{userBean.getUserRowToEdit}" title="Editer un utilisateur" ><span class="fa fa-edit"/></p:commandLink>
<p:commandLink class="glyphicon glyphicon-trash icon-trash" actionListener="#{userBean.deleteUser}" title="Supprimer un utilisateur" update="#form">
<p:confirm header="Confirmation" message="Voulez-vous vraiment supprimer l'utilisateur?" icon="ui-icon-alert"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:confirmDialog global="true">
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
</p:confirmDialog>
</h:form>
I tried your code and repaired it a little. Hope it will work for you too.
-I removed ajax="true"
-usersBean.deleteUser function need to know which user to so -> deleteusersBean.deleteUser(user)
Under is my code that i use to test your case. A few things are changed due to existing beans i have. This code is tested on latest primefaces(5.2).
my xhtml file:
<p:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandLink class="badge bg-red marge-left" value="delete" onclick='PF("cdu#{user.userId}").show()' title="Supprimer un utilisateur"><span class="fa fa-trash-o"/></p:commandLink>
<p:confirmDialog message="Voulez vous vraiment supprimer l'utilisateur '#{user.name}'" closable="true" header="Confirmation" severity="alert" widgetVar="cdu#{user.userId}" >
<p:commandButton value="oui" actionListener="#{loginBean.deleteUser(user)}" update="#form" onclick='PF("cdu#{user.userId}").hide()' styleClass="btn btn-primary"/>
<p:commandButton value="non" onclick='PF("cdu#{user.userId}").hide()' type="button" styleClass="btn btn-danger" />
</p:confirmDialog>
</p:column>
</p:dataTable>
</h:form>
my loginBean:
public class LoginBean implements Serializable {
private static final long serialVersionUID = 6188046073588310656L;
private List<User> users= new ArrayList<User>();
public LoginBean() {
}
public List<User> getUsers() {
if(users.size()==0){
for (int i= 0; i<3; i++){
User u = new User();
u.setUserId(i);
u.setName("noob"+i);
users.add(u);
}
}
return users;
}
public void deleteUser(User user){
users.remove(user);
}
}

After Filtering Primefaces Datatable not show The Filtered Row Details in a dialog box

I use jsf 2.2 and Primefaces 4.0 in my project. but I faced a problem . After Filter Primefaces Datatable. I want to show the filtered Row ditails in a dialog but after filter, Row ditails not show dialog box . Even Until Reload the page don't show Row Details in the dialog box . My Jsf Code Is ..........
<h:form id="Form_showRequest" style="font-size: 10pt;">
<input type="text" id="search" placeholder="Search now..."></input>
<p:growl id="MSG_grl" autoUpdate="false" showDetail="true"/>
<p:dataTable id="TBL_data" var="List_request" value="#{allRequestBean.requestDetailsList}" scrollable="true" widgetVar="reTab"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
scrollHeight=" 460" style="font-size: 10pt; font-family: serif;margin-bottom:0;">
<p:column headerText="Mobile No" style="width: 80px;" filterBy="#{List_request.mobileNumber}" >
#{List_request.mobileNumber}
</p:column>
<p:column headerText="User Name" style="width: 80px;">
#{List_request.userName}
</p:column>
<p:column headerText="Amount" style="width: 50px;">
#{List_request.rechargeAmount}
</p:column>
<p:column headerText="Cost" style="width: 50px;">
#{List_request.costAmount}
</p:column>
<p:column headerText="Service" style="width: 100px;">
#{List_request.serviceName}
</p:column>
<p:column headerText="Bank " style="width: 50px;">
#{List_request.bankName}
</p:column>
<p:column headerText="Bank Tran Id" style="width: 100px;">
#{List_request.bankTrankId}
</p:column>
<p:column headerText="Date Time" style="width: 150px;" >
#{List_request.rechargeDate}
</p:column>
<p:column headerText="Conformation Id" style="width: 100px;">
#{List_request.conformationId}
</p:column>
<p:column headerText="Status" style="width: 80px;">
<h:outputText value="#{List_request.rechargeStatusName}"/>
</p:column>
<p:column id="op" headerText="Option" style="width: 100px">
<p:commandButton id="but" value="Action" action="#{actionBean.allReRowDetails()}"
update=":Form_showRequest:PNL_action" style=" font-size: 10px" onclick="PF('widget_action').show();"
ajax="true" disabled="#{List_request.rechargeStatusId eq 4 or List_request.rechargeStatusId eq 5}">
<f:setPropertyActionListener value="#{List_request}" target="#{actionBean.allRequestBeanValue}"/>
</p:commandButton>
<p:commandLink id="requestDetails" value="Details" action="#{allRequestDetailsBean.rowDetails()}"
update=":Form_showRequest:PNL_request" oncomplete="PF('widget_request').show();" ajax="true" >
<f:setPropertyActionListener value="#{List_request}" target="#{allRequestDetailsBean.allRequestBeanValue}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog id="Dialog_acton" header="Action" widgetVar="widget_action" modal="true">
<h:panelGrid id="PNL_action" style="margin-bottom:10px; width: 300px;" cellpadding="10">
<p:selectOneRadio id="action" columns="1" value="#{actionBean.actionType}">
<f:selectItem itemLabel="Resend" itemValue="1" />
<f:selectItem itemLabel="Complete" itemValue="4" />
<f:selectItem itemLabel="Cancel" itemValue="5" />
</p:selectOneRadio><br/>
<p:outputLabel value="Reason" style="width:20px; "/>
<p:inputTextarea value="#{actionBean.confirmId}" style="width: 250px" />
</h:panelGrid>
<p:commandButton value="Ok" action="#{actionBean.action()}" update="Form_showRequest:TBL_data,MSG_grl"
oncomplete="widget_action.hide()" style="width: 200px; margin-left: 50px;"/>
</p:dialog>
<p:dialog id="Dialog_request" header="Request Details Information" widgetVar="widget_request" showEffect="clip" hideEffect="fold" resizable="false" >
<p:panelGrid id="PNL_request" columns="2" style="width: 450px" >
<p:outputLabel value="Recharge Id :"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeId}"/>
<p:outputLabel value="User Name:"/>
<p:outputLabel value=" #{allRequestDetailsBean.userName}"/>
<p:outputLabel value="Mobile Number :"/>
<p:outputLabel value=" #{allRequestDetailsBean.mobileNumber}"/>
<p:outputLabel value="Recharge Amount:"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeAmount}"/>
<p:outputLabel value="Cost :"/>
<p:outputLabel value=" #{allRequestDetailsBean.costAmount}"/>
<p:outputLabel value="Number Type:"/>
<p:outputLabel value=" #{allRequestDetailsBean.numberType}"/>
<p:outputLabel value="Operator :"/>
<p:outputLabel value=" #{allRequestDetailsBean.operatorName}"/>
<p:outputLabel value="Service :"/>
<p:outputLabel value=" #{allRequestDetailsBean.serviceName}"/>
<p:outputLabel value="Bank Nmae:"/>
<p:outputLabel value=" #{allRequestDetailsBean.bankName}"/>
<p:outputLabel value="Bank Transaction Id:"/>
<p:outputLabel value=" #{allRequestDetailsBean.bankTrankId}"/>
<p:outputLabel value="Ip Address:"/>
<p:outputLabel value=" #{allRequestDetailsBean.ipAddress}"/>
<p:outputLabel value="Time:"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeDate}"/>
<p:outputLabel value="Invoice No:"/>
<p:outputLabel value=" #{allRequestDetailsBean.invoiceNo}"/>
<p:outputLabel value="Conformation Id:"/>
<p:outputLabel value=" #{allRequestDetailsBean.conformationId}"/>
<p:outputLabel value="Status:"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeStatusName}"/>
</p:panelGrid>
</p:dialog>
</h:form>
I Solved it by this code write in p:dataTable tag ....
filteredValue="#{allRequestDetailsBean.filteredRequest}"
and also create a list in allRequestDetailsBean
private List<AllRequestBean> filteredRequest;

Primefaces Datagrid is working but popup is empty

Why my popup is empty . image is coming but data is not coming ..
<p:dataGrid var="publicationVar" value="#{adminhome.lazyModel}"
columns="5" id="imageGridId" lazy="true" rows="15" paginator="true"
style="float: left;" binding="#{adminhome.dataGrid}"
emptyMessage="Records non trovati!"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" paginatorPosition="bottom"
rendered="#{adminhome.renderImages}">
<p:column id="colGridId">
<p:panel style="width: 50%;" id="panlId">
<h:panelGrid id="panGridId">
<p:commandLink oncomplete="dlg2.show()" update=":form:tesss"
process="#this" id="comLinkId">
<p:graphicImage id="grapImgId"
value="#{publicationVar.imageTmbPath}" width="140" height="160"
style="margin-right: -12px" alt="#{publicationVar.ISSNcode}"
title="#{publicationVar.editore}, #{publicationVar.title}, € #{publicationVar.priceStr}" />
<f:setPropertyActionListener value="#{publicationVar}"
target="#{adminhome.selectedPubblicazioni}" id="setPropId" />
</p:commandLink>
</h:panelGrid>
</p:panel>
</p:column>
</p:dataGrid>
Here is the dialog box . I can see blank dialog .But it was working before the lazy concept is introduced .
<p:dialog id="modalDialog" widgetVar="dlg2" modal="true" height="100%" dynamic="true">
<p:outputPanel id="tesss">
<p:panelGrid>
<p:row>
<p:column rowspan="13" >
<div style="width:100%;height:100%">
<h:commandLink action="popup.xhtml" target="_blank" >
<p:graphicImage style="margin-left:5px" value="#{adminhome.selectedPubblicazioni.imagePath}" height="500" width="375" />
</h:commandLink>
</div>
</p:column>
</p:row>
<p:row> <p:column> <h:outputText value="Data " style="float: left;margin-left: 30px;color:red;font-size: 18px;font-weight: bold"/> </p:column> <p:column> <h:outputText value="#{adminhome.selectedPubblicazioni.sample}" style="float: left;"/> </p:column> </p:row>
<p:row> <p:column> <h:outputText value="Name " style="float: left;margin-left: 30px;color:red;font-size: 18px;font-weight: bold"/> </p:column> <p:column> <h:outputText value="#{adminhome.selectedPubblicazioni.ename}" style="float: left;"/> </p:column> </p:row>
<p:row> <p:column> <h:outputText value="Code " style="float: left;margin-left: 30px;color:red;font-size: 18px;font-weight: bold"/> </p:column> <p:column><h:outputText value="#{adminhome.selectedPubblicazioni.code}" style="float: left;"/> </p:column> </p:row>
<p:row> <p:column> <h:outputText value="Sample " style="float: left;margin-left: 30px;color:red;font-size: 18px;font-weight: bold"/> </p:column> <p:column> <h:outputText value="#{adminhome.selectedPubblicazioni.sample}" style="float: left;"/> </p:column> </p:row>
</p:panelGrid>

Filter is preventing to reset table values

The two main components in my jsf are p:tree and p:dataTable
The idea is to create a table according to the tree node selection.
Jsf:
<h:panelGrid columns="2" style="width: 100%" columnClasses="treeColumn,tableColumn">
<h:panelGroup id="treePanel">
<p:tree id="tree"
value="#{genRepBean.root}"
var="node"
dynamic="true"
cache="true"
animate="true"
selectionMode="single"
selection="#{genRepBean.selectedNode}"
rendered="#{genRepBean.renderTree}">
<p:ajax event="select" listener="#{genRepBean.onNodeSelect}" update=":mainForm:tablePanel"/>
<p:treeNode expandedIcon="ui-icon-folder-open"
collapsedIcon="ui-icon-folder-collapsed">
<h:outputText value="#{node.name}" styleClass="tableTreeText"/>
</p:treeNode>
<p:treeNode type="au" icon="ui-icon-document">
<h:outputText value="#{node.name}" />
</p:treeNode>
</p:tree>
</h:panelGroup>
<h:panelGroup id="tablePanel">
<p:dataTable id="acqDataTable"
var="acq"
value="#{genRepBean.acqList}"
rendered="#{genRepBean.renderTable}"
filteredValue="#{genRepBean.filteredAcqList}"
paginator="true"
paginatorPosition="bottom"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15"
rows="10"
lazy="false"
style="width: 100%">
<p:column headerText="ID" sortBy="#{acq.Id}" styleClass="tableTreeText">
<h:outputText value="#{acq.Id}" />
</p:column>
<p:column headerText="IP ADDRESS" sortBy="#{acq.ipAddress}" styleClass="tableTreeText">
<h:outputText value="#{acq.ipAddress}"/>
</p:column>
<p:column headerText="STEP" sortBy="#{acq.Step}" filterBy="#{acq.Step}" filterMatchMode="contains" styleClass="tableTreeText">
<h:outputText value="#{acq.Step}"/>
</p:column>
<p:column headerText="STATUS" sortBy="#{acq.status}" filterBy="#{acq.status}" styleClass="tableTreeText">
<h:outputText value="#{acq.status}"/>
</p:column>
</p:dataTable>
The bean (onNodeSelect):
public void onNodeSelect() {
acqList.clear();
this.acqList = AcqHelper.getAllViaStartDate(new java.sql.Date(startDate.getTime()));
if (!acqList.isEmpty()) {
DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("mainForm:acqDataTable");
dataTable.reset();
renderTable = true;
}
I don’t want to remove the filter option since its very usable to the client but I don’t know why its blocking the table refresh ??
Any help would be great
Thanks
You don't need to perform changes into a DataTable model. Primefaces is taking data from #{genRepBean.acqList}. Just set proper values in that list and reset #{genRepBean.filteredAcqList} list. After the request is completed, datatable will be refreshed with new values.

Clearing form fields after invalidation JSF

Ok i have the following problem: In my web app i have the CRUD all one page via dialogs controls of Primefaces. In the new dialog i have some validators. For example: when a user does not fill the necessary fields for form submission obviously the form doesn't submit. But when i close de New dialog and open it up again, the validation messages are still there! How can i get rid of this? I want a fresh new page (without accumulated validation errors) every time a dialogs open up! How that can be done?
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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:p="http://primefaces.org/ui"
template="./../../resources/templates/baseTemplate.xhtml">
<ui:define name="content">
<f:view id="vRoot">
<p:fieldset legend="Gerenciar público">
<h:form id="frmPublicos">
<!-- Exibição de mensagens gerais -->
<p:growl id="gMessages" sticky="false" globalOnly="true" />
<!-- Exibição da lista de públicos -->
<p:dataTable id="dtPublicos"
value="#{publicoBean.lstDataTablePublico}"
paginator="true" rows="5"
rowsPerPageTemplate="5,10"
paginatorPosition="bottom"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
var="atual">
<!-- Every time dialog opens validation messages should be cleaned -->
<f:facet name="header">
<p:commandButton id="cbViewNovo"
value="Novo" type="button"
styleClass="cbViewNovo"
onclick="dlgNovo.show();"
update=":dlgNovoPublico"
process="#this">
<p:resetInput target=":dlgNovoPublico"/>
</p:commandButton>
</f:facet>
<!-- Colunas de edição e exclusão -->
<p:column>
<f:facet name="header">
<h:outputLabel value="Editar"/>
</f:facet>
<p:commandButton id="cbViewEditar"
image="ui-icon-pencil"
title="Editar"
update=":frmEditar:pEditarPublico"
oncomplete="dlgEditar.show();">
<f:setPropertyActionListener value="#{atual}" target="#{publicoBean.publicoSelecionado}" />
</p:commandButton>
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel value="Excluir"/>
</f:facet>
<p:commandButton id="cbViewExcluir" onclick="dlgExcluir.show();"
icon="ui-icon-close" title="Excluir">
<f:setPropertyActionListener value="#{atual}" target="#{publicoBean.publicoSelecionado}" />
</p:commandButton>
</p:column>
<p:column>
<f:facet name="header">
Nome
</f:facet>
<h:outputLabel id="olViewNomePublico" value="#{atual.nmePublico}"/>
</p:column>
<p:column>
<f:facet name="header">
Tipo de público
</f:facet>
<h:outputLabel id="olViewTipoPublico" value="#{atual.tdTipoPublico}"/>
</p:column>
</p:dataTable>
</h:form>
<!-- Caixa de diálogo de inclusão -->
<p:dialog id="dlgNovoPublico"
widgetVar="dlgNovo"
modal="true"
header="Novo público"
resizable="false">
<h:form id="frmNovo">
<p:panel id="pNovoPublico">
<p:messages id="mNovoMessages" redisplay="false" />
<p:panelGrid columns="2">
<p:outputLabel id="olNovoNomePublico" value="Nome:" for="itNovoNomePublico"/>
<p:inputText id="itNovoNomePublico" value="#{publicoBean.nome}" required="true"
requiredMessage="Digite o nome do público."/>
<p:outputLabel id="olNovoTipoPublico" for="somNovoTipoPublico" value="Tipo de público:"/>
<p:selectOneMenu id="somNovoTipoPublico"
value="#{publicoBean.tipoPublicoSelecionado}"
effect="fade"
converter="#{publicoBean.conversor}"
required="true"
requiredMessage="Selecione um tipo de público."
>
<f:selectItem itemLabel="Selecione um item..." itemValue=""/>
<f:selectItems value="#{publicoBean.lstMenuTipoPublico}" var="atual" itemLabel="#{atual.label}" itemValue="#{atual}"></f:selectItems>
</p:selectOneMenu>
<p:commandButton value="Cancelar" immediate="true" onclick="dlgNovo.hide()"/>
<p:commandButton id="cbNovoSalvar" value="Salvar"
actionListener="#{publicoBean.cadastrarPublico}"
oncomplete="handleSalvo(xhr, status, args);"
update=":frmPublicos:dtPublicos :frmNovo :frmPublicos:gMessages"
ajax="true"/>
</p:panelGrid>
</p:panel>
</h:form>
</p:dialog>
<!-- Caixa de diálogo de exclusão -->
<p:confirmDialog id="dialogoExcluir" message="Deseja realmente excluir?"
header="Excluir público" severity="alert"
widgetVar="dlgExcluir">
<h:form id="frmExcluir">
<p:commandButton id="cbExcluirCancelar" value="Cancelar" onclick="dlgExcluir.hide()" type="button" />
<p:commandButton id="cbExcluirContinuar" value="Continuar"
update=":frmPublicos:dtPublicos :frmPublicos:gMessages"
oncomplete="dlgExcluir.hide()"
actionListener="#{publicoBean.excluirPublico}"/>
</h:form>
</p:confirmDialog>
<!-- Caixa de diálogo de edição -->
<p:dialog id="dialogoEditar" widgetVar="dlgEditar" header="Editar público"
resizable="false" modal="true">
<h:form id="frmEditar">
<p:panel id="pEditarPublico">
<p:messages id="mEditarMessages" redisplay="false" />
<p:panelGrid columns="2">
<p:outputLabel id="olEditarNomePublico" value="Nome:" for="itEditarNomePublico"/>
<p:inputText id="itEditarNomePublico" value="#{publicoBean.publicoSelecionado.nmePublico}" required="true"
requiredMessage="Digite o nome do público."/>
<p:outputLabel id="olEditarTipoPublico" for="somEditarTipoPublico" value="Tipo de público:"/>
<p:selectOneMenu id="somEditarTipoPublico"
value="#{publicoBean.publicoSelecionado.tdTipoPublico}"
effect="fade"
converter="#{publicoBean.conversor}"
required="true"
requiredMessage="Selecione um tipo de público."
>
<f:selectItem itemLabel="Selecione um item..." itemValue=""/>
<f:selectItems value="#{publicoBean.lstMenuTipoPublico}"
var="atual"
itemLabel="#{atual.label}"
itemValue="#{atual}"></f:selectItems>
</p:selectOneMenu>
<p:commandButton value="Cancelar" immediate="true" onclick="dlgEditar.hide()"/>
<p:commandButton id="cbEditarSalvar" value="Salvar"
actionListener="#{publicoBean.alterarPublico}"
oncomplete="dlgEditar.hide();"
update=":frmPublicos:dtPublicos :frmEditar :frmPublicos:gMessages"/>
</p:panelGrid>
</p:panel>
</h:form>
</p:dialog>
</p:fieldset>
</f:view>
<!-- Javascript responsável por fechar a caixa de diálogo ao cadastrar-->
<script type="text/javascript">
function handleSalvo(xhr, status, args){
if(args.salvo){
dlgNovo.hide();
}
}
function handleEditar(xhr, status, args){
if(args.salvo){
dlgEditar.hide();
}
}
</script>
</ui:define>
Try p:resetInput. http://www.primefaces.org/showcase-labs/ui/resetInput.jsf
Try with pe:resetInput from Primefaces Extensions: http://fractalsoft.net/primeext-showcase-mojarra/sections/resetInput/formElements.jsf
<p:commandButton id="cbViewNovo"
value="Novo" type="button"
styleClass="cbViewNovo"
onclick="dlgNovo.show();"
update=":dlgNovoPublico"
process="#this">
<pe:resetInput target=":dlgNovoPublico"/>
</p:commandButton>

Resources