Update selected Item in Primefaces selectOneMenu from commandButton - jsf

i have a reset Button and want to select a default value
in the selectOneMenu component when the button is pressed.
I tried different posts, but don't get it working.
here is my page:
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
template="${pageContext.request.contextPath}/templates/default.xhtml">
<ui:define name="content">
<h:form>
<h1>Maschinenverwaltung</h1>
<p:panelGrid id="editMachinePanelGrid" style="margin-top:200px"
rendered="true">
<f:facet name="header">
<p:row>
<p:column colspan="4">Maschinenverwaltung</p:column>
</p:row>
<p:row>
<p:column colspan="4">Maschine</p:column>
</p:row>
</f:facet>
<p:row>
<p:column colspan="2">
<p:commandButton id="createModeButton2" ajax="true" type="reset"
actionListener="#{machineController.setCreateMode('true')}"
value="Neuanlage" update="machineName, deleteMachine" onclick="PF('machineSelector').selectItem(id='noMachine')">
</p:commandButton>
</p:column>
<p:column colspan="2">
<p:spacer></p:spacer>
</p:column>
</p:row>
<p:row></p:row>
<p:row>
<p:column colspan="2">
<p:selectOneMenu id="machineSelector"
value="#{machineController.currentMachine}" required="true"
var="m" effect="puff" converter="MachineConverter">
<f:selectItem itemLabel="Maschine auswählen" itemValue="" id="noMachine"/>
<f:selectItems value="#{machineController.allMachines}"
var="machine" itemLabel="#{machine.name}" itemValue="#{machine}" />
<p:column>
#{m.name}
</p:column>
<p:ajax listener="#{machineController.machineSelected}"
update="machineName">
</p:ajax>
</p:selectOneMenu>
</p:column>
<p:column colspan="2"
rendered="#{machineController.deleteMachineDisabled()}">
<p:spacer></p:spacer>
</p:column>
<p:column rendered="#{!machineController.deleteMachineDisabled()}">
<p:commandButton id="deleteMachine"
action="#{machineController.deleteCurrentMachine()}"
value="löschen"
disabled="#{machineController.deleteMachineDisabled()}"
rendered="#{!machineController.deleteMachineDisabled()}" />
</p:column>
</p:row>
<p:row>
<p:column colspan="2">Maschinenbezeichnung: </p:column>
<p:column colspan="2">
<p:inputText value="#{machineController.currentMachine.name}"
id="machineName"></p:inputText>
</p:column>
</p:row>
<p:row>
<p:column colspan="2">
<p:commandButton value="Speichern" partialSubmit="true"
process="editMachinePanelGrid"
action="#{machineController.saveMachine()}"></p:commandButton>
</p:column>
<p:column colspan="2">
<p:spacer></p:spacer>
</p:column>
</p:row>
</p:panelGrid>
<h:messages id="messages" />
</h:form>
</ui:define>
<ui:define name="title">Maschinenverwaltung</ui:define>
</ui:composition>
I know, that i have to use the selectValue() Method, but don't know
how to address the Parameter to select the value:
<f:selectItem itemLabel="Maschine auswählen" itemValue="" id="noMachine"/>
I am using Primefaces 5.1
best regards
Heiko

To reset the p:selectOneMenu on client side, you may use the client side API:
First set a widget name for you menu like this:
<p:selectOneMenu widgetVar="wv" ... />
Now you may access and set the value of the menu via the client side API easily:
<p:commandButton
onclick="PF('wv').selectValue('');"
/>
Note that the given value in the selectValue-method should be the value defined by the itemValue-attribute of your select item. As it is empty in your case (itemValue="") you may just pass the empty String '' as value, as shown above.
Unrelated:
I guess your select item should have set the attribute noSelectionOption='true' instead of (only) having set the item value to the empty String.

Related

How to render same list in multiple datatables in primefaces

I'm using primefaces and I want to populate two datatables with same list.
When I select any one of the books, two panels are shown. The first one shows the details of the book and the author(s). The authors being displayed in the first panel is an editable datatable. I also want to display the same datatable in the second panel. But as you can see it says "No records found". How do I achieve it?
My jsf page is as below:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/Layout.xhtml">
<ui:define name="content">
<f:view>
<h:form id="form">
<p:growl id="msgs" showDetail="true"/>
<p:dataTable value="#{webBooks.entries}" var="book" id="bookList"
styleClass="order-table"
rows="3" paginator="true" editMode="true" editable="true">
<div>
<f:facet name="header">
<p:outputLabel value="Books List"/>
</f:facet>
</div>
<p:columnGroup type="header">
<p:row>
<p:column style="width:10px"/>
<p:column headerText="Id" style="width:30px"/>
<p:column headerText="Book Title" style="width:200px"/>
<p:column headerText="Price" style="width:30px"/>
</p:row>
</p:columnGroup>
<p:column>
<p:commandButton update=":form:bookDetail"
onclick="PF('bookDialog').show(), PF('authorDialog').show()"
title="View Book Detail"
icon="fa fa-info-circle">
<f:setPropertyActionListener value="#{book}" target="#{webBooks.selectedBook}"/>
</p:commandButton>
</p:column>
<p:column>
<p:outputLabel value="#{book.id}"/>
</p:column>
<p:column>
<p:outputLabel value="#{book.title}"/>
</p:column>
<p:column>
<p:outputLabel value="#{book.price}"/>
</p:column>
</p:dataTable>
<p:panelGrid columns="2">
<p:panel id="bookDetail"
header="Book Info"
closable="true"
toggleable="true"
widgetVar="bookDialog" visible="false" style="width:420px;height:250px;">
<p:panelGrid columns="2"
rendered="#{not empty webBooks.selectedBook}">
<h:outputLabel value="Id" />
<p:outputLabel value="#{webBooks.selectedBook.id}"
rendered="#{webBooks.selectedBook.editable}"/>
<p:outputLabel value="#{webBooks.selectedBook.id}"
rendered="#{not webBooks.selectedBook.editable}"/>
<p:outputLabel value="Title"/>
<p:inputText value="#{webBooks.selectedBook.title}"
rendered="#{webBooks.selectedBook.editable}"/>
<p:outputLabel value="#{webBooks.selectedBook.title}"
rendered="#{not webBooks.selectedBook.editable}"/>
<p:outputLabel value="Price"/>
<p:inputText value="#{webBooks.selectedBook.price}"
rendered="#{webBooks.selectedBook.editable}"/>
<p:outputLabel value="#{webBooks.selectedBook.price}"
rendered="#{not webBooks.selectedBook.editable}"/>
<p:outputLabel value="Author(s)" />
<p:dataTable value="#{webBooks.selectedBook.authoredBy}"
var="authoredBy"
id="authorList"
scrollable="true"
scrollHeight="70"
scrollWidth="300"
editable="true">
<p:ajax event="rowEdit" listener="#{webBooks.onAuthorEdit}" update=":form:msgs" />
<p:ajax event="rowEditCancel" listener="#{webBooks.onAuthorEditCancel}" update=":form:msgs" />
<p:columnGroup type="header">
<p:row>
<p:column style="width:30px" headerText="Id"/>
<p:column style="width:100px" headerText="Author Name"/>
</p:row>
</p:columnGroup>
<p:column>
<p:outputLabel value="#{authoredBy.id}"/>
</p:column>
<p:column>
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{authoredBy.name}"/></f:facet>
<f:facet name="input"><p:inputText value="#{authoredBy.name}" style="width:100%" label="Author Name"/></f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px">
<p:rowEditor />
</p:column>
</p:dataTable>
</p:panelGrid>
<p:commandButton value="Edit"
action="#{webBooks.edit(webBooks.selectedBook)}"
rendered="#{not webBooks.selectedBook.editable}"
update=":form:bookDetail"/>
<p:commandButton value="Save"
actionListener="#{webBooks.save(webBooks.selectedBook)}"
rendered="#{webBooks.selectedBook.editable}"
update="bookList"
process="#form"
id="save"
oncomplete="PF('bookDialog').close()"/>
<p:commandButton value="Cancel"
actionListener="#{webBooks.cancel(webBooks.selectedBook)}"
rendered="#{webBooks.selectedBook.editable}"
update=":form:bookDetail"/>
<p:commandButton value="Delete"
actionListener="#{webBooks.remove(webBooks.selectedBook)}"
onclick="return confirm('Are you sure?')"
id="remove"
update="bookList"
process="#form"
oncomplete="PF('bookDialog').close()"/>
</p:panel>
<p:panel header="Author Info"
widgetVar="authorDialog"
closable="true"
toggleable="true"
visible="false" style="width:420px;height:250px;">
<p:panelGrid columns="2">
<p:dataTable value="#{webBooks.selectedBook.authoredBy}"
var="authoredBy"
id="authorsList"
scrollable="true"
scrollHeight="150"
scrollWidth="300"
editable="true">
<p:ajax event="rowEdit" listener="#{webBooks.onAuthorEdit}" update=":form:msgs" />
<p:ajax event="rowEditCancel" listener="#{webBooks.onAuthorEditCancel}" update=":form:msgs" />
<p:columnGroup type="header">
<p:row>
<p:column style="width:30px" headerText="Id"/>
<p:column style="width:100px" headerText="Author Name"/>
</p:row>
</p:columnGroup>
<p:column>
<p:outputLabel value="#{authoredBy.id}"/>
</p:column>
<p:column>
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{authoredBy.name}"/></f:facet>
<f:facet name="input"><p:inputText value="#{authoredBy.name}" style="width:100%" label="Author Name"/></f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px">
<p:rowEditor />
</p:column>
</p:dataTable>
</p:panelGrid>
</p:panel>
</p:panelGrid>
</h:form>
</f:view>
</ui:define>
You are only updating update=":form:bookDetail" in your "View Book Detail" button. Add an ID to the panel "Author Info" and update that as well:
<p:commandButton update=":form:bookDetail :form:authorDetail"
...>
...
</p:commandButton>
...
<p:panel id="authorDetail"
header="Author Info"
...>
...
</p:panel>
See also:
Can 'update' attribute update two components simultanously?

How to add Cell Edit by click or edit single column in Datatable using Primefaces 3.4.2

I'm using Primefaces 3.4.2 and due to some restrictions i can't update it to latest version. I have to add a edit option for column "Contact" in the datatable in below code so that user can edit it and update it.
I already tried by using Primefaces inplace and row editing (only for a single column) but it takes ages to submit when clicked on save or cancel button.
Can anyone help me with this?
Thank you very much for your help in advance.
<ui:composition 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:p="http://primefaces.org/ui">
<p:dialog id="viewSitesHistoricAlarm" header="Alarm Information" widgetVar="viewSiteHistoricAlmDialog" modal="false" minWidth="930"
minHeight="600" fixedCenter="false" appendToBody="true" effect="FADE" effectDuration="0.5" close="true" closeListener="#{historicActivity.dlgClose}">
<h:form id="viewsiteHistoricAlmFrm">
<h:panelGrid columns="1" style="margin:5px;" id="printid">
<p:dataTable id="alarmResolution" var="alm" value="#{historicActivity.alarmResolution}"
style="border-right-width: 2px !important;overflow: -moz-scrollbars-vertical;overflow-x: auto;overflow-y: auto; width:895px;max-height:500px !important;" paginatorPosition="top" paginatorTemplate="{PreviousPageLink} {CurrentPageReport}
{NextPageLink}" editable="true" rows="100" paginatorAlwaysVisible="false">
<p:ajax event="rowEdit" listener="#{historicActivity.updateContactName}" />
<p:column style="width:155px">
<f:facet name="header">
<h:outputText value="Action Time"/>
</f:facet>
<h:outputText value="#{alm.timeActioned}"/>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="User"/>
</f:facet>
<h:outputText value="#{alm.user}"/>
</p:column>
<p:column style="width:140px" >
<f:facet name="header">
<h:outputText value="Action"/>
</f:facet>
<h:outputText value="#{alm.action}"/>
</p:column>
<p:column style="width:140px" >
<f:facet name="header">
<h:outputText value="Contact"/>
</f:facet>
<h:outputText value="#{alm.alm.contactName}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Comments"/>
</f:facet>
<h:outputText value="#{alm.comments}"/>
</p:column>
<p:column headerText="Modify">
<p:rowEditor />
</p:column>
</p:dataTable>
<p:toolbar>
<p:toolbarGroup align="left">
<p:commandButton value="CSV" ajax="false" style="color:#A8A6A8!important;">
<p:dataExporter type="csv" target="alarmResolution" fileName="historicalarminfo" preProcessor="#{exporter.preProcessor}" postProcessor="#{exporter.postProcessor}"/>
</p:commandButton>
<p:commandButton value="PDF" style="color:#A8A6A8!important;" update="viewsiteHistoricAlmFrm" onstart= "pdfDownloadDialog.show();" rendered="#{historicActivity.val==true}">
<f:setPropertyActionListener target="#{pdfExp.columnValues}" value="#{historicActivity.exptrColValsAlmSpecific}"/>
<f:setPropertyActionListener target="#{pdfExp.tabColumnsWithSize}" value="#{historicActivity.exptrSpecificAlmCol}"/>
<f:setPropertyActionListener target="#{pdfExp.headerContent}" value="#{historicActivity.exptrHeaderAlmSpecific}"/>
<f:setPropertyActionListener target="#{pdfExp.logo}" value="#{historicActivity.exptrHeaderLogo}"/>
<f:setPropertyActionListener target="#{pdfExp.pageTitle}" value="#{historicActivity.exptrPgTitle}"/>
<f:setPropertyActionListener target="#{pdfExp.fileName}" value="#{historicActivity.exptrFileName}"/>
<f:setPropertyActionListener target="#{pdfExp.redirectTo}" value="HistoricActivityPage?faces-redirect=true"/>
</p:commandButton>
<p:commandButton value="PDF" style="color:#A8A6A8!important;" actionListener
="#{historicActivity.checkHistoricSiteAlmsSize}" update="viewsiteHistoricAlmFrm" rendered
="#{historicActivity.val==false}"/>
<p:commandButton value="XLS" ajax="false" style="color:#A8A6A8!important;">
<p:dataExporter type="xls" target="alarmResolution" preProcessor="#{exporter.preProcessor}" postProcessor="#{exporter.postProcessor}" fileName="historicalarminfo"/>
</p:commandButton>
</p:toolbarGroup>
</p:toolbar>
</h:panelGrid>
</h:form>
</p:dialog>
</ui:composition>

p:treeTable and h:selectOneMenu

I got a <p:treeTable> that works perfectly as showcase, I open a dialog to see the detail of each node... the dialog have a <h:selectOneMenu> and it's not working. I don't know why, send me the error "Target Unreachable" but if I put the attribute into a <h:outputText> it's working (it means that it's not null). What is happening?
<p:row>
<p:column colspan="4" style="width:800px">
<p:dialog id="edit" widgetVar="edit" header="Edit" showEffect="clip"
hideEffect="explode" position="center,center" width="520" modal="true" closable="false"
closeOnEscape="true" resizable="false" dynamic="true">
<h:panelGrid width="100%">
<p:row>
<p:column >
Name
</p:column>
<p:column>
<p:inputText value="#{levelBean.selectedLevel.name}" />
</p:column>
</p:row>
<p:row>
<p:column >
Description
</p:column>
<p:column>
<p:inputText value="#{levelBean.selectedLevel.description}" />
</p:column>
</p:row>
<p:row>
<p:column >
Level
</p:column>
<p:column>
<!-- this its showing OK !! -->
<h:outputText value="#{levelBean.selectedLevel.id.idLevel}"/>
<!-- this mark target unreachable -->
<h:selectOneMenu id="cbo" style="width=200px"
value="#{levelBean.selectedLevel.id.idLevel}" >
<f:selectItems value="#{cboLevelBean.list}" var="levelEdit"
itemValue="#{levelEdit.id.idNivel}"
itemLabel="#{levelEdit.name}"
/>
</h:selectOneMenu>
</p:column>
</p:row>
</h:panelGrid>
</p:dialog>
<p:treeTable id="treeTableLevels" value="#{levelBean.root}" var="subLevel" style="width:800px">
<f:facet name="header">
Levels
</f:facet>
<p:column headerText="#{subLevel.object.levelName}">
<h:outputText value="#{subNivel.object.nameSubLevel}" />
</p:column>
<p:column style="width:24px">
<p:commandLink update=":levelsForm:edit" oncomplete="PF('edit').show()" title="Level Detail" styleClass="ui-icon ui-icon-search">
<f:setPropertyActionListener value="#{subLevel}" target="#{levelBean.selectedLevel}" />
</p:commandLink>
</p:column>
</p:treeTable>
</p:column>
</p:row>
Thanks for any help!!
I fond the reason... I just put the selectonemenu into another form and it works.. but I don't know why.. can somebody explain?
<h:form id="someform">
<p:selectOneMenu id="cbo" style="width: 200px"
value="#{levelBean.selectedLevel.id.idLevel}">
<f:selectItems value="#{cboLevelBean.list}" var="levelEdit"
itemValue="#{levelEdit.id.idNivel}"
itemLabel="#{levelEdit.name}"/>
</p:selectOneMenu>
</h:form>
Anyway hope this help to others!

after editing a cell in datatableEditor the output text still display the old Value primefaces

I am using JSF 2.2 with PrimeFaces 5.0. I have a dataTable with cell-editing.
I am having the dataTable inside dialog when I set editMode="cell", the outputtext after editing it's doesn't appear, but when i put the datatable edit outside dialog, it's work.When I inspect the element of datatable it's empty but if i put the datatable edtor outside dialog the outPut element isn't empty
===>when i click to edit the cell the input have the new value but the outputext still have the old value
===>so here my page
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:form id="lotRecepForm">
<p:dataTable value="#{lotRecpBean.liste}"
var="lotRecp"
id="tbl">
<p:column>
<f:facet name="header">
<span class="nomColonneTab">Lot Réception</span>
</f:facet>
<h:outputText value="#{lotRecp.codeLotReception}"/>
</p:column>
<p:column>
<f:facet name="header">
<span class="nomColonneTab">Entrant</span>
</f:facet>
<h:outputText value="#{lotRecp.entrant.designation}"/>
</p:column>
<p:column>
<f:facet name="header">
<span class="nomColonneTab">Date Réception</span>
</f:facet>
<h:outputText value="#{lotRecp.dateReception}">
<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<span class="nomColonneTab">Quantite Livrée</span>
</f:facet>
<h:outputText value="#{lotRecp.quantiteLivree}"/>
</p:column>
<p:column headerText="Action" exportable="false" styleClass="nomColonneTab">
<p:commandButton icon="ui-icon-arrowrefresh-1-w"
update=":content:modif"
oncomplete="PF('w_edit').show();" styleClass="buttonAction">
<f:setPropertyActionListener value="#{lotRecp}" target="#{lotRecpBean.currentLotReception}" />
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
<p:dialog id="modif" width="80%" widgetVar="w_edit" modal="true" >
<p:tabView >
<p:tab title="Controle de Réception ">
<h:form>
<h:panelGrid>
<p:dataTable id="data1" value="#{normeMicroEBean.listOfNorme(lotRecpBean.currentLotReception.entrant)}"
var="item" editable="true" editMode="cell" >
<p:column headerText="Valeur Controle" styleClass="ui-editable-column">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{item.valeurControle}" /></f:facet>
<f:facet name="input"><p:inputText id="modelInput" value="#{item.valeurControle}" style="width: 50%"/></f:facet>
</p:cellEditor>
</p:column>
<p:column width="15%" headerText="Testeur">
<p:cellEditor >
<f:facet name="output"><h:outputText value="#{item.testeurCR.nom}" /></f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{item.testeurCR.nom}" style="width:50%">
<f:selectItems value="#{personnelBean.liste}" var="perso" itemLabel="#{perso.nom}" itemValue="#{perso}" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</h:panelGrid>
<h:form>
</p:tab>
<p:tab title="Info lot de Réception">
<h:form>
<p:panelGrid id="idPanel">
<p:row>
<p:column><p:outputLabel value="QuantiteLivree:" for="quantiteLivree" /></p:column>
<p:column><p:inputText id="quantiteLivree" value="#{lotRecpBean.currentLotReception.quantiteLivree}" title="QuantiteLivree" /></p:column>
<p:column><p:outputLabel value="QuantiteRecue:" for="quantiteRecue" /></p:column>
<p:column><p:inputText id="quantiteRecue" value="#{lotRecpBean.currentLotReception.quantiteRecue}" title="QuantiteRecue" /></p:column>
<p:column><p:outputLabel value="NumBonLivraison:" for="numBonLivraison" /></p:column>
<p:column><p:inputText id="numBonLivraison" value="#{lotRecpBean.currentLotReception.numBonLivraison}" title="NumBonLivraison" /></p:column>
</p:row>
</p:panelGrid>
<div>
<p:commandButton action="#{lotRecpBean.update()}" value="Enregistrer" styleClass="button"
style="float: right" oncomplete="PF('lotRecepTable').filter();PF('w_edit').hide();" />
</div>
</h:form>
</p:tab>
</p:tabView>
</p:dialog>
I fixed the problem , it's come from the value of datatable ===> the value of datatable editor must be a list and not a method which return a list datatable editor work just with a list 1-
<p:dataTable id="data1" value="#{normeMicroEBean.listOfNorme}"
var="item" editable="true" editMode="cell" >
I create a list in the managed bean t and in the button i execute the method to full the list created in the managed bean . thank you for your response

Multiple error messages for one input field

I am creating a form using facelets. One input field looks like this:
<p:inputText id="initials" value="#{dilution.initials}" />
dilution is a entity bean and the initials field has two validation constraints set on it. One size constraint and one regex pattern constraint. My problem is getting error messages for both constraints to display next to the input field. Using the <h:message> only display one of the messages and using <h:messages> displays all input fields error messages or nothing (when I tried setting <h:messages for="initials" autoUpdate="true" />).
Is there any simple way to do this?
The full form:
<h:form id="addDilForm">
<p:panel>
<p:messages autoUpdate="true" showDetail="TRUE" />
<p:panelGrid>
<f:facet name="header" >
<p:row><p:column colspan="3">Ny spädningsfaktor</p:column></p:row>
</f:facet>
<p:row>
<p:column colspan="1">
<p:outputLabel for="sampT">Provtyp</p:outputLabel>
</p:column>
<p:column>
<p:selectOneMenu id="sampT" required="true" value="#{dilution.dilution.sampleType.ID}" >
<f:selectItem itemLabel="-" itemValue="" />
<f:selectItems value="#{SampleTypeController.samples}" var="samp" itemLabel="#{samp.name}" itemValue="#{samp.ID}" />
</p:selectOneMenu>
</p:column>
<p:column>
<p:message for="sampT" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel for="initials">Initialer</p:outputLabel>
</p:column>
<p:column >
<p:inputText id="initials" value="#{dilution.initials}" />
</p:column>
<p:column>
<p:message for="initials" />
</p:column>
</p:row>
<f:facet name="footer">
<p:row>
<p:column colspan="3">
<p:commandButton value="Save" action="#{dilution.save()}" update="addDilForm" icon="ui-icon-check" />
</p:column>
</p:row>
</f:facet>
</p:panelGrid>
</p:panel>
</h:form>
Using the <h:message> only display one of the messages
Just use <h:messages> with the plural "s" instead of <h:message> while keeping the for attribute.
<h:messages for="initials" />
The <p:messages> works the same way, only with a different UI.

Resources