When a row in <p:dataTable>
is right-clicked, <p:contextMenu>
appears with a delete option. When this option is clicked, <p:confirmDialog>
appears with two buttons Yes
and No
- a conformation warning about deleting the current row as follows.
<p:contextMenu for="dataTable">
<p:menuitem oncomplete="confirmDelete.show()"
value="Delete"
update="confirmDialog"
process="@this dataTable"
actionListener="#{testManagedBean.deleteActionListener}"
icon="ui-icon-close" ajax="true"/>
</p:contextMenu>
<p:confirmDialog id="confirmDialog"
widgetVar="confirmDelete"
message="#{testManagedBean.message}"
header="Message"
severity="alert"
closeOnEscape="true"
showEffect="slide"
hideEffect="fold"
appendTo="@(body)"
closable="true">
<p:commandButton id="btnYes"
value="Yes"
process="@this"
oncomplete="confirmDelete.hide()"
actionListener="#{testManagedBean.deleteActionListener}"
update="dataTable"/>
<p:commandButton id="btnNo"
value="No"
onclick="confirmDelete.hide()"
type="button" />
</p:confirmDialog>
Is there a way to set the message
attribute with a formatted message on this dialog.
For example, the property testManagedBean.message
in its managed bean is set to a string like
You are about to delete <font color='#ff0000'>2</font> rows. <br/>This action will never be undone. <br/>Are you sure?
The confirm dialog displays this string as a whole. HTML in this string should be interpreted as HTML. I don't see any attribute like escape
in <p:confirmDialog>
.
Is there a way to display this string as a formatted message.
I found an
uglysolution nesting of<f:facet name="message">
within<p:confirmDialog>
.Removing the
message
attribute from<p:comfirmDialog>
and nesting<f:facet name="message">
inside it.Note :
<h:outputFormat>
is only needed, if one or more parameters need to be passed by means of nested<f:param>
to be substituted in respective placeholders ({0}
) in the message text. Just keep on using<h:outputText escape="false">
, if no such parameters need to be passed.