I implement a <h:form> to edit Employee data which gets preloaded from the database. The preload works fine - all fields get filled with data. The <h:form id="editEmployeeForm"> is surrounded by a <h:form> which contains a <p:dataTable>.
When I do an edit on Employee data and click the "Speichern"-button nothing happens. <p:messages> says all my fields are empty what is obviously a wrong validation because all fields are prefilled. Then I deleted all <p:message> tags from my <h:inputText> tags to check whether the doSaveEmployeeEdit() gets called at all. But nothing happens - no error in console, etc. Even a simple System.out.println() doesn't get printed from the doSaveEmployeeEdit() at all.
Below the <p:dialog> what I have at the time:
<h:form id="editEmployeeForm">
<p:dialog header="Angestellten ändern" id="employeeEditDialog" widgetVar="employeeEditDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" closeOnEscape="true">
<p:outputPanel id="employeeDataEdit" rendered="#{not empty employeeEditController.employee}">
<h:panelGrid columns="2">
<p:outputLabel for="usernameEdit" value="Benutzername: " />
<p:inputText id="usernameEdit" value="#{employeeEditController.employee.username}" disabled="true" />
</h:panelGrid>
<p:separator/>
<h:panelGrid columns="6">
<p:outputLabel for="firstnameEdit" value="Vorname: " />
<p:inputText id="firstnameEdit" value="#{employeeEditController.employee.firstName}" />
<p:outputLabel for="lastnameEdit" value="Nachname: " />
<p:inputText id="lastnameEdit" value="#{employeeEditController.employee.lastName}" />
<p:outputLabel for="birthdayEdit" value="Geburtsdatum: " />
<p:inputMask mask="99/99/9999" id="birthdayEdit" value="#{employeeEditController.employee.birthday}" />
<p:outputLabel for="locationEdit" value="Wohnort: " />
<p:inputText id="locationEdit" value="#{employeeEditController.employee.location}" />
<p:outputLabel for="streetEdit" value="Straße: " />
<p:inputText id="streetEdit" value="#{employeeEditController.employee.streetName}" />
<p:outputLabel for="postcodeEdit" value="Postleitzahl: " />
<p:inputMask id="postcodeEdit" mask="9999?9" slotChar=" " value="#{employeeEditController.employee.postcode}" />
<p:outputLabel for="phonenumberEdit" value="Telefonnummer: " />
<p:inputMask id="phonenumberEdit" mask="9?99999999999" slotChar=" " maxlength="12" value="#{employeeEditController.employee.phoneNumber}" />
<p:outputLabel for="emailEdit" value="Email: " />
<p:inputText id="emailEdit" validatorMessage="Ungültiges Email-Format!" value="#{employeeEditController.employee.email}">
<f:validateRegex pattern="^$|^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*#[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
</p:inputText>
</h:panelGrid>
<p:separator/>
<h:panelGrid columns="6">
<p:outputLabel for="familyStatus" value="Familienstatus: " />
<p:selectOneMenu id="familyStatus" value="#{employeeEditController.employee.familyStatus}" style="width:150px">
<f:selectItem itemLabel="Wähle Familienstatus" itemValue="#{employeeEditController.employee.familyStatus}" />
<f:selectItems value="#{enumController.familyStatus}" />
</p:selectOneMenu>
<p:outputLabel for="Religion" value="Religion: " />
<p:selectOneMenu id="Religion" value="#{employeeEditController.employee.religion}" style="width:150px">
<f:selectItem itemLabel="Wähle Religion" itemValue="#{employeeEditController.employee.religion}" />
<f:selectItems value="#{enumController.religions}" />
</p:selectOneMenu>
<p:outputLabel for="Role" value="Rolle: " />
<p:selectOneMenu id="Role" value="#{employeeEditController.employee.workRole}" style="width:150px">
<f:selectItem itemLabel="Wähle Arbeitsrolle" itemValue="#{employeeEditController.employee.workRole}" />
<f:selectItems value="#{enumController.workRoles}" />
</p:selectOneMenu>
</h:panelGrid>
<p:separator/>
<h:panelGrid columns="3">
<p:commandButton value="Speichern" action="#{employeeEditController.doSaveEmployeeEdit()}" />
<p:commandButton value="Neu laden" action="#{employeeEditController.doReloadEmployee()}" />
<p:commandButton value="Abbruch" onclick="PF('employeeEditDialog').hide()" />
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
What can be the reason that html or whatever still do the validation and don't call the doSaveEmployeeEdit()?
UPDATE:
I made a new xhtml-file with same outputs - no validation anymore. But my controller method doesn't get called.
My children.xhtml:
<h:body>
<body class="theme-blue sidebar-mini sidebar-collapse">
<div class="wrapper">
<div class="content-wrapper" style="min-height: 1126px;">
<section class="content">
<div class="box">
<div class="box-body">
<h:form id="childForm">
<p:dataTable id="childTable" var="child" value="#{childController.children}">
<p:column headerText="Vorname">
<h:outputText value="#{child.firstName}" />
</p:column>
<p:column headerText="Nachname">
<h:outputText value="#{child.lastName}" />
</p:column>
<p:column headerText="Geburtsdatum">
<h:outputText value="#{child.birthday}" />
</p:column>
<p:column style="width:32px;text-align: center">
<p:commandButton update=":childForm:childEdit" oncomplete="PF('childEditDialog').show()" icon="ui-icon-note" title="Bearbeiten">
<f:setPropertyActionListener value="#{child}" target="#{childEditController.childEdit}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:dialog header="Kind bearbeiten" widgetVar="childEditDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
<p:messages autoUpdate="true" />
<p:outputPanel id="childEdit" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty childEditController.childEdit}" columnClasses="label,value">
<p:outputLabel id="primParent" value="primäres Elternteil:" />
<p:inputText for="primParent" value="#{childEditController.childEdit.primaryParent.id}" disabled="true" />
<p:outputLabel id="firstName" value="Vorname:" />
<p:inputText for="firstName" value="#{childEditController.childEdit.firstName}" />
<p:outputLabel id="lastName" value="Nachname:" />
<p:inputText for="lastName" value="#{childEditController.childEdit.lastName}" />
<p:outputLabel id="birthDay" value="Geburtsdatum:" />
<p:inputText for="birthDay" value="#{childEditController.childEdit.birthday}" />
<p:outputLabel id="emgNum" value="Notfallkontakt:" />
<p:inputText for="emgNum" value="#{childEditController.childEdit.emergencyNumber}" />
<p:outputLabel id="imgName" value="Bildname:" />
<p:inputText for="imgName" value="#{childEditController.childEdit.imgName}" />
<p:outputLabel for="gender" value="Geschlecht: " />
<p:inputText id="gender" value="#{childEditController.childEdit.gender}" disabled="true" />
<p:separator />
<h:panelGrid columns="3">
<p:commandButton value="Speichern" action="#{childEditController.doSaveChild}" update=":childForm:childTable" />
<p:commandButton value="Abbruch" onclick="PF('childEditDialog').hide()" immediate="true" />
</h:panelGrid>
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</div>
</div>
</section>
</div>
</div>
</body>
</h:body>
My childEditController:
#Component
#Scope("request")
public class ChildEditController {
#Autowired
private ChildService childService;
private Child childEdit;
public Child getChildEdit() {
return childEdit;
}
public void setChildEdit(Child childEdit) {
this.childEdit = childEdit;
}
public void doSaveChild(){
childEdit = childService.saveChild(childEdit);
childEdit = null;
}
}
Related
I have this code, I want to gain advantage of the left space (Not filed value)...
[![<h:panelGrid columns="2" cellpadding="5" >
<p:outputLabel value="Field1:" for="itField1" />
<p:inputText id="itField1" style="width:200px" required="true"
value="#{bean.field1}">
</p:inputText>
<p:outputLabel value="Field2:" for="itField2" />
<h:panelGrid columns="2" style="width:200px" cellpadding="0" cellspacing="0" >
<p:inputText id="itField2" required="true"
value="#{="#{bean.field2}"
/>
<p:commandButton icon="fa fa-search"
/>
</h:panelGrid>
<p:outputLabel value="Field3:" for="itField3" />
<p:inputText id="itField3" style="width:200px" required="true"
value="#{bean.field3}">
</p:inputText>
</h:panelGrid>]
I want this!
But, I get that :( :
How to do it?
This can be achieved by adding CSS style width:100% to <p:inputText id="itField2" ..... /> and <p:commandButton .... />as follows:
<p:inputText id="itField2" value="#{bean.field2}" required="true" style="width:100%" />
<p:commandButton icon="fa fa-search" style="width:100%" />
I have the following xhtml:
<f:metadata>
<f:viewParam name="livroId" value="#{livroBean.livro.id}" />
<f:viewAction action="#{livroBean.carregarLivroPelaId}"
if="#{param.livroId != null}" />
</f:metadata>
<ui:define name="titulo">
<p:outputPanel>Novo Livro</p:outputPanel>
</ui:define>
<ui:define name="conteudo">
<h:form>
<p:messages id="messages" />
<p:fieldset legend="Dados do Livro">
<p:panelGrid columns="2">
<p:outputLabel value="Titulo:" for="titulo" />
<p:inputText id="titulo" value="#{livroBean.livro.titulo}"
required="true" requiredMessage="Título obrigatório"
validatorMessage="Título não pode ser superior a 40">
<f:validateLength maximum="40" />
<f:ajax event="blur" render="messages" />
</p:inputText>
<p:outputLabel value="ISBN:" for="isbn" />
<p:inputMask id="isbn" value="#{livroBean.livro.isbn}"
validator="#{livroBean.comecaComDigitoUm}"
mask="999-9-99-999999-9" />
<p:outputLabel value="Preço:" for="preco" />
<p:inputText id="preco" value="#{livroBean.livro.preco}" />
<p:outputLabel value="Data de Lançamento:" for="dataLancamento" />
<p:calendar id="dataLancamento"
value="#{livroBean.livro.dataLancamento.time}"
pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" mask="true" />
</p:panelGrid>
</p:fieldset>
<br />
<p:fieldset legend="Dados do Autor">
<p:panelGrid columns="4">
<p:outputLabel value="Selecione Autor:" for="autor" />
<p:selectOneMenu value="#{livroBean.autorId}" id="autor">
<f:selectItems value="#{livroBean.autores}" var="autor"
itemLabel="#{autor.nome}" itemValue="#{autor.id}" />
</p:selectOneMenu>
<p:commandButton value="Gravar Autor"
action="#{livroBean.gravarAutor}" process="#this autor"
update="tabelaAutores" />
<p:commandLink value="ou cadastrar novo autor"
action="#{livroBean.formAutor}" immediate="true" update="#all" />
</p:panelGrid>
<p:dataTable value="#{livroBean.autoresDoLivro}" var="autor"
id="tabelaAutores" emptyMessage="Nenhum autor">
<p:column>
<h:outputText value="#{autor.nome}" />
</p:column>
<p:column>
<p:commandLink value="X"
action="#{livroBean.removerAutorDoLivro(autor)}"
update="tabelaAutores" process="#this" />
</p:column>
</p:dataTable>
</p:fieldset>
<br />
<h:panelGrid style="margin: 0 auto">
<p:commandButton value="Gravar" action="#{livroBean.gravar}"
process="#form" update="#form :formTabelaLivros:tabelaLivros" />
</h:panelGrid>
</h:form>
<br />
<h:form id="formTabelaLivros">
<p:dataTable value="#{livroBean.livros}" var="livro"
id="tabelaLivros" paginator="true" rows="5">
<f:facet name="header">Livros</f:facet>
<p:column headerText="Título" sortBy="#{livro.titulo}"
filterBy="#{livro.titulo}" filterMatchMode="startsWith">
<h:outputText value="#{livro.titulo}" />
</p:column>
<p:column headerText="ISBN" sortBy="#{livro.isbn}">
<h:outputText value="#{livro.isbn}" />
</p:column>
<p:column headerText="Preço" sortBy="#{livro.preco}">
<h:outputText value="#{livro.preco}">
<f:convertNumber type="currency" pattern="R$ #0.00"
currencySymbol="R$" locale="pt_BR" />
</h:outputText>
</p:column>
<p:column headerText="Data" sortBy="#{livro.dataLancamento.time}">
<h:outputText value="#{livro.dataLancamento.time}">
<f:convertDateTime pattern="dd/MM/yyyy"
timeZone="America/Sao_Paulo" />
</h:outputText>
</p:column>
<p:column headerText="Alterar">
<h:commandLink value="Alterar" action="#{livroBean.carregar(livro)}" />
</p:column>
<p:column headerText="Remover">
<h:commandLink value="Remover" action="#{livroBean.remover(livro)}" />
</p:column>
</p:dataTable>
</h:form>
</ui:define>
The h:commandLink "Remover" is actually removing the object from my database, but is not updating the DataTable. I've already set process="#form" update="#form", but it doesn't help.
It was actually working fine before, and it suddenly stopped (I didn't modify anything related to my bean).
EDIT:
I changed it to a CommandButton, as below:
<p:column headerText="Remover">
<p:commandButton icon="fa fa-fw fa-remove" actionListener="#{livroBean.remover(livro)}" process="#form" update="#form" />
</p:column>
But still no results... The button works, it removes the entry from my database, but it does not updates the datatable. Tried with action= as well.
I have a dialog that open when the page is reloaded and ask for the login. This was working perfectly until I create another dialog that open when I click in a button. Both have different names and I am calling then right! I really don't know what is wrong..
Now, when I reload the page it shows me the login dialog and I put the right login and password but it rejects.. But if I remove the other dialog and do the same thinh, it works.
My code:
<body onload="PF('dlgLogin').show();">
<h:form name="">
<p:growl id="growl" sticky="true" showDetail="true" life="2000" />
<p:dialog header="Login" widgetVar="dlgLogin" modal="true" closable="false" resizable="false">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="login" value="Username:" />
<p:inputText id="login" value="#{loginView.login}" required="true" label="Login" />
<h:outputLabel for="password" value="Password:" />
<p:password id="password" value="#{loginView.senha}" required="true" label="Password" />
<f:facet name="footer">
<p:commandButton value="Login" update="growl" action="#{loginView.login}"
oncomplete="handleLoginRequest(xhr, status, args)" />
</f:facet>
</h:panelGrid>
</p:dialog>
<p:dialog header="Nova classificação" widgetVar="dlgClassificacao" modal="true" resizable="false">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="nome" value="Nome:" />
<p:inputText id="nome" value="#{adminView.classNome}" required="true" label="Nome" />
<h:outputLabel for="valor" value="Valor:" />
<p:inputText id="valor" value="#{adminView.classPreco}" required="true" label="Valor" />
</h:panelGrid>
<f:facet name="footerAdicionar">
<p:commandButton value="Adicionar" action="#{adminView.novaClassificacao}" />
</f:facet>
</p:dialog>
<p:layout>
<p:layoutUnit position="center">
<p:dataTable id="classificacoes" selection="#{adminView.selectedClassificacao}" var="classificacao" value="#{adminView.classificacoes}" style="margin-bottom:20px">
<p:ajax event="rowSelect" listener="#{adminView.onRowSelect}"/>
<p:column>
<f:facet name="header">
<h:outputText value="Nome" />
</f:facet>
<h:outputText value="#{classificacao.nome}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Valor" />
</f:facet>
<h:outputText value="#{classificacao.preco}" />
</p:column>
</p:dataTable>
<f:facet name="footer">
<p:commandButton title="Novo" icon="ui-icon-document" onclick="PF('dlgClassificacao').show();" type="button"/>
<p:commandButton title="Editar" icon="ui-icon-pencil" />
<p:commandButton title="Deletar" icon="ui-icon-trash" update="classificacoes" actionListener="#{adminView.excluirClassificacao}"/>
</f:facet>
</p:layoutUnit>
</p:layout>
</h:form>
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
PF('dlg').jq.effect("shake", {times:5}, 100);
}
else {
PF('dlg').hide();
$('#loginLink').fadeOut();
}
}
</script>
</body>
The problem is that you are sending all the form data when you press the login button. Then you obtain messages indicating that you have not (naturally) typed any data for Nome nor Valor fields.
You can fix it by adding an id attribute to your login dialog and to your form and also adding a process attribute to your login button:
<p:commandButton process=":yourForm:dlgLogin" value="Login"
update="growl" action="#{loginView.login}" />
Following is my code:
<p:contentFlow value="#{fileOnDeskViewDlgBacking.filesContentFlowList}" var="row">
<p:panel styleClass="filePanel" >
<p:outputLabel value="#{row.srNo}" />
<p:panelGrid styleClass="borderless" columns="2">
<p:graphicImage name="/dashboard/images/file_64px.png"/>
<p:panelGrid styleClass="borderless" columns="1">
<p:outputLabel value="(#{row.subject})" />
</p:panelGrid>
</p:panelGrid>
<p:outputLabel style="color:#3D83B5;" value="Files#{row.date}">
<f:convertDateTime pattern="dd/mm/yyy HH:mm" />
</p:outputLabel>
<h:panelGrid styleClass="borderless" columns="2">
<p:outputLabel value="FileId:" />
<p:outputLabel styleClass="wrapText" value="#{row.Id}" />
<p:outputLabel value="Description:" />
<p:outputLabel styleClass="wrapText" value="#{row.description}" />
<p:outputLabel value="Heading:" />
<p:outputLabel value="#{row.name}" />
<p:outputLabel value="Priority:" />
<p:outputLabel value="#{row.priorityName}" />
<p:outputLabel value="Type:" />
<p:outputLabel value="#{row.typeName}" />
<!-- <p:outputLabel value="Created By:" />
<p:outputLabel value="#{row.createdBy}" /> -->
</h:panelGrid>
<p:spacer height="5px" />
<p:separator />
<p:commandButton value="#{row.fileId}" action="#{fileOnDeskViewDlgBacking.fileNoting(row.fileId)}" />
</p:panel>
</p:contentFlow>
The problem is here on button <p:commandButton value="#{row.fileId}" action="#{fileOnDeskViewDlgBacking.fileNoting(row.fileId)}" /> the method does not pass fileId and it resolved to null, where as #{row.fileId} alwasys give its value.
MORE
It do work in p:dataTable, there is any problem with the component i think.
I tried populating the collection in the #PostConstruct method, then a NPE is thrown.
Also tried redirecting, but I get IllegalStateException: Response already committed.
this.networks = this.getNetworks();
if (this.networks.isEmpty()) {
JsfUtils jsfUtils = new JsfUtils();
jsfUtils.displayMessage("WARN", "No network inserted!", "Insert a network!");
}
Then I tried using FacesMessage directly inside the getter method. The message isn't shown, though the method is being executed since I see the message in the console.
public List<Network> getNetworks() {
if (this.networks == null) {
networks = networkBean.findWithNamedQuery("Network.findAll");
if (networks.isEmpty()) {
FacesContext fc = FacesContext.getCurrentInstance();
fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,"Insert a network!",""));
System.out.println(">>>>>>>>>>>> Insert a Network!");
}
}
return networks;
}
Using the same structure as the first in a #PostLoad method also doesn't display any message.
Page code:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:p="http://primefaces.org/ui" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
template="/WEB-INF/tpl/template1.xhtml">
<ui:define name="title">Add Stablishment</ui:define>
<ui:define name="header">Add Stablishment</ui:define>
<ui:define name="content">
<h:form id="form" enctype="multipart/form-data">
<p:growl id="growl" autoUpdate="true" showDetail="true" sticky="true" globalOnly="true" />
<h:panelGrid columns="3" cellpadding="5">
<p:outputLabel for="categories" value="Category:" />
<p:selectOneMenu id="categories" value="#{stablishmentMB.category.id}">
<f:selectItem itemValue="" itemLabel="-- Select --" noSelectionOption="true" />
<f:selectItems value="#{stablishmentCategoryMB.categories}" var="category" itemLabel="#{category.name}" itemValue="#{category.id}" />
</p:selectOneMenu>
<p:message for="categories" />
<p:outputLabel for="networks" value="Network:" />
<p:selectOneMenu id="networks" value="#{stablishmentMB.network.id}">
<f:selectItem itemValue="" itemLabel="-- Selecione --" noSelectionOption="true" />
<f:selectItems value="#{networkMB.networks}" var="network" itemLabel="#{network.tradeName}" itemValue="#{network.id}" />
</p:selectOneMenu>
<p:message for="networks" />
<p:outputLabel for="cnpj" value="CNPJ:" />
<p:inputMask id="cnpj" pt:placeholder="99.999.999/9999-99" mask="99.999.999/9999-99" value="#{stablishmentMB.stablishment.cnpj}" required="true" />
<p:message for="cnpj" />
<p:outputLabel for="companyName" value="Company Name:" />
<p:inputText id="companyName" value="#{stablishmentMB.stablishment.companyName}" required="true" />
<p:message for="companyName" />
<p:outputLabel for="tradeName" value="Trade Name:" />
<p:inputText id="tradeName" value="#{stablishmentMB.stablishment.tradeName}" required="true" />
<p:message for="tradeName" />
<p:outputLabel for="zipCode" value="Zip Code:" />
<p:inputMask id="zipCode" mask="99999-999" value="#{stablishmentMB.zipCode.number}" required="true">
<p:ajax event="blur" listener="#{stablishmentMB.findByZipCode}" update="street neighbourhood city state" />
</p:inputMask>
<p:message for="zipCode" />
<p:outputLabel for="state" value="State:" />
<p:inputText id="state" value="#{stablishmentMB.state.abbreviation}" required="true" />
<p:message for="state" />
<p:outputLabel for="city" value="City:" />
<p:inputText id="city" value="#{stablishmentMB.city.nome}" required="true" />
<p:message for="city" />
<p:outputLabel for="neighbourhood" value="Neighbourhood:" />
<p:inputText id="neighbourhood" value="#{stablishmentMB.neighbourhood.nome}" />
<p:message for="neighbourhood" />
<p:outputLabel for="street" value="Street:" />
<p:inputText id="street" value="#{stablishmentMB.street.name}" required="true" />
<p:message for="street" />
<p:outputLabel for="number" value="Nº:" />
<p:inputText id="number" value="#{stablishmentMB.stablishment.number}" required="true" />
<p:message for="number" />
<p:outputLabel for="complement" value="Complement:" />
<p:inputText id="complement" value="#{stablishmentMB.stablishment.complement}" />
<p:message for="complement" />
<p:outputLabel for="telephone" value="Telephone:" />
<p:inputMask mask="(99) 9999-9999" id="telephone" value="#{stablishmentMB.stablishment.telephone}" />
<p:message for="telephone" />
<p:outputLabel for="contact" value="Contact:" />
<p:inputText id="contact" value="#{stablishmentMB.stablishment.contact}" />
<p:message for="contact" />
<p:outputLabel for="email" value="E-mail:" />
<p:inputText id="email" value="#{stablishmentMB.stablishment.email}" />
<p:message for="email" />
<p:outputLabel for="site" value="Site:" />
<p:inputText id="site" value="#{stablishmentMB.stablishment.site}" />
<p:message for="site" />
<p:outputLabel for="latitude" value="Latitude:" />
<p:inputText id="latitude" value="#{stablishmentMB.stablishment.latitude}" />
<p:message for="latitude" />
<p:outputLabel for="longitude" value="Longitude:" />
<p:inputText id="longitude" value="#{stablishmentMB.stablishment.longitude}" />
<p:message for="longitude" />
<p:commandButton action="#{stablishmentMB.save}" value="Save" update="#form" />
</h:panelGrid>
</h:form>
</ui:define>
You should remove your code from the getter because a getter is not mean to do such staff and always #PostConstruct will be executed before any getter on your bean!
A quick fix to your problem is to move <p:growl> to the end of page this will make your bean construction happens before the renderer try to render <p:growl>.